The XML SQL2XML Method

Previous Next

See Also

The XML SQL2XML method converts SQL syntax to XML format. The SQL statement must be syntactically and semantically correct. If the SQL statement cannot be parsed, for example if tables or columns used in the SQL statement are not defined, an error is given.

SYNTAX

INVOKE    XML.SQL2XML

WITH

SELECT     <SQL statement> SQLStatement

       [,<schema path> SchemaPath]

[FROM]

PARAMETERS

The parameter names and values are not case-sensitive.

Parameter

Description

SQLStatement

The SQL statement to be converted to XML.

A single quote (') in this SQL statement needs to be escaped with two single quotes: ''. For example:

SELECT ''constant'' SQLStatement

SchemaPath

Contains a path to an XML schema definition (XSD) file. A schema file with extension .xsd is delivered with USoft installation:

<USoft installation folder>/xsl/ExtendedConditions/

SQL2XML.xsd

To validate the generated XML against this schema, the schema path must be included. If no schema path is defined, then no reference to a schema is generated into the XML document.

XmlDeclaration

Yes specifies that the default Rules Engine encoding is to be returned in XML processing instructions.

No specifies that no encoding processing instruction is added to the returned XML document.

 

EXAMPLE

INVOKE XML.SQL2XML

WITH

SELECT

   'SELECT * FROM TOUR' SQLStatement,

   'C:\Program Files\USD70\xsl\ExtendedConditions\SQL2XML.xsd'

This results in the generation of the schema path in the XML file:

<?xml version="1.0" encoding="Windows-1252"?>

<SqlNode version="1.0"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xsi:noNamespaceSchemaLocation=

       "C:\Program Files\USD70\xsl\ExtendedConditions\SQL2XML.xsd">

<Select>

   <SelectList>

    <SelectListElement position="1">

    <Column name="*" table_name="TOUR" table_info_window_name="Tours" position="1"/>

    </SelectListElement>

   </SelectList>

   <TableList>

    <TableListElement name="TOUR" info_window_name="Tours" position="1"/>

   </TableList>

</Select>

</SqlNode>

A complete description of all SQL syntax elements and how they are converted to XML elements and attributes can be found in:

C:\<USoft installation folder>\Help\SQL2XML.doc