CursorToXML Function |
Namespace: XSharp.VFP
FUNCTION CursorToXML( uArea, cOutput, nOutputFormat, nFlags, nRecords, cSchemaName, cSchemaLocation, cNameSpace ) AS USUAL CLIPPER
Note |
---|
Use this parameter only when you are deploying your schema to a location other than the location of the XML data. |
1CURSORTOXML("LABELS", "myXMLFile.xml", 1, 512, 0, ; 2"mySchema.xsd", "http://www.microsoft.com/mySchema.xsd")
1xsi:noNamespaceSchemaLocation=" http://www.microsoft.com/mySchema.xsd"
Note |
---|
CURSORTOXML( ) output adheres to the cursor index order, Set Fields TO, and current filter settings. |
1Create Table test (col1 b(6))
1Select orderid, EVL(shippeddate,.NULL.) as ShippedDate From orders
1Select orderid, IIF(EMPTY(shippeddate),{^1899-12-30 00:00:00},tc11);
Flag 16 | Flag 32 | Flag 32768 is Set |
Not set | Not set |
XML documents: Window-1252. Unicode data: code page 1252. Character data: default code page, unless a field is marked as NOCPTRANS. |
True (.T) | Not set |
XML documents: Plus-CodePage property of the cursor. If XMLField CodePage property is greater than zero (0) and it doesn’t match the cursor’s code page, an error is reported. Unicode data: the Code page property of the cursor object. Character data: none. Raw data from the X# tables (.dbf) are used instead. |
Not set | Set |
XML documents: UTF-8 code page. Unicode data: UTF-8 code page. Character data: Default code page unless field is marked as NOCPTRANS, in which case no additional character translation to UTF-8 occurs. |
Set | Set |
XML documents: UTF-8 code page. Unicode data: UTF-8 code page. Character data: default code page unless a field is marked as NOCPTRANS, in which case the data are translated to UTF-8 using the SYS(3005) setting. |
Flag 16 | Flag 32 | Without the 32768 flag |
Not set | Not set |
XML documents: Window-1252. Unicode data: code page 1252. Character data: default code page unless a field is marked as NOCPTRANS. |
True (.T) | Not set |
XML documents: CodePage property of the cursor. Character data: none. Raw data from the X# tables (.dbf) are used instead. Unicode data: code page property of the cursor object. |
Not set | Set |
XML documents: UTF-8 code page. Unicode data: UTF-8 code page. Character data: default code page unless field is marked as NOCPTRANS, in which case no additional character translation to UTF-8 occurs. |
Set | Set |
XML documents: UTF-8 code page. Unicode data: UTF-8 code page. Character data: default code page unless field is marked as NOCPTRANS, in which case, they are translated to UTF-8 using code page for the current SYS(3005) setting. |
nOutputFormat | Description |
---|---|
1 – ELEMENTS | (Default) Element-centric XML |
2 – ATTRIBUTES | Attribute-centric XML |
3 – RAW | Generic, attribute-centric XML |
nFlags | Bit | Output description |
---|---|---|
0 | 0000 |
(Default) Produce XML in UTF-8 format. This setting creates a memory variable if one does not exist when specified by cOutput and returns XML to the memory variable. The XML declaration does not contain an Encoding= attribute; that is, no encoding attribute is set to UTF-8. |
1 | 0001 | Produce unformatted XML as a continuous string. |
2 | 0010 | Enclose empty elements with open and closing elements, for example, <cc04><cc04/>. |
4 | 0100 | Preserve white space in fields. |
8 | 1000 | Wrap Memo fields in CDATA sections. |
16 | 10000 |
Output encoding. Output is set to the cursor code page. To ensure accurate character translation, the X# default code page must match the code page of the cursor. You can accomplish this by setting character and memo fields in the cursor to NOCPTRAN (character binary/memo binary). When setting this value with tables using any of the code pages, the encoding attribute in the XML is set to an empty string (""). To change to the correct encoding attribute, use the STRTRAN( ) function. For example, for code page 936, provide the following to the resulting XML string: X# 1strxml=STRTRAN(strxml, 'encoding=""', 'encoding="gb2312"' |
32 | 100000 | Output encoding. |
512 | 1000000000 | Output to the file specified by cOutput. If a file does not exist, it is created. If the file already exists, it is overwritten. The setting for Set SAFETY is observed. |
4096 | 1000000000000 |
Disables base64 encoding. CURSORTOXML( ) exports Memo (Binary) fields as xsd:base64binary unless you use nFlags set to 4096. In X#, base64 encoding is meant for encoding only binary data. |
32768 | none | Indicates that a code page should be used. |
Note |
---|
Encoding flags are set by combining bits 4 and 5 (0010000). |
Encoding flag | Bits 4 and 5 | Description |
---|---|---|
+0 | 00 | (Default) Windows-1252 |
+16 | 01 | Set output encoding attribute to the cursor code page. |
+32 | 10 | Set output encoding attribute to UTF-8 with no character translation. |
+48 | 11 | Set output encoding attribute to UTF-8 and translate character data to UTF-8. |
Code page | Platform | Encoding attribute in XML Declaration | Comments |
---|---|---|---|
437 | MS-DOS, US | ibm437 | |
850 | MS-DOS, International | ibm850 | |
865 | MS-DOS, Nordic | Empty string ("") | |
866 | MS-DOS, Russian | cp866 | |
932 | Windows, Japanese | shift-jis | |
936 | Simplified Chinese | gb2312 | |
949 | Windows, Korean | iso-2022-kr |
or: ks_c_5601-1987 |
950 | Windows, Traditional Chinese (Taiwan) | big5 | |
1250 | Windows, East European | Windows-1250 | Note case. |
1251 | Windows, Russian | Windows-1251 | |
1252 | Windows, U.S., West European | Windows-1252 | |
1253 | Windows, Greek | Windows-1253 | |
1254 | Windows, Turkish | Windows-1254 | |
1255 | Windows, Hebrew | Windows-1255 | |
1256 | Windows, Arabic | Windows-1256 |
Note |
---|
X# uses Windows-1252 as the default encoding. You can specify that the encoding attribute be set to match the code page, such as Big5 (code page 950), when using double-byte character sets (DBCS) for DBCS languages for which X# supports code pages. |
cSchemaName | Description | ||
---|---|---|---|
cSchemaName |
Specifies the name and path of the external file for the schema (scoped to the root element of the XML).
X# 1CURSORTOXML("LABELS", "myXMLFile.xml", 1, 512, 0, "mySchema.xsd") | ||
"1" |
Specifies an inline schema is produced. For example, the following code produces an inline schema:
X# 1CURSORTOXML("LABELS", "myXMLFile.xml", 1, 512, 0, "1") | ||
"" | Specifies that no schema is produced. |