Parsing an XML Document

Adaptive Server Enterprise provides several Transact-SQL extensions for accessing and processing XML documents in SQL statements. These extensions include the following functions.

XML query functions

FunctionDescription

xmlextract

A built-in function that applies an XML query expression to an XML document and returns the selected result.

xmltest

A SQL predicate that applies an XML query expression to an XML document and returns the boolean result.

xmlparse

A built-in function that parses and indexes an XML document for more efficient processing.

xmlrepresentation

A built-in function that determines whether a given image column contains a parsed XML document.

xmlvalidate

A built-in function that validates an XML document against a DTD or XML schema.

The xmlextract, xmltest, xmlparse, and xmlrepresentation functions can be used within Workspace. To parse XML data in Sybase WorkSpace with these functions, use the following procedure.

  1. From Database Explorer under your ASE connection profile, expand the Procedures and Functions folder or, for triggers, expand the Tables folder and expand the table, then the Triggers folder.

  2. Select the procedure for which you want to parse an XML document. Right-click and select Edit Procedure. Alternatively, select the trigger for which you want to parse an XML document. Right-click and select Edit Trigger.

    The procedure or trigger code appears in SQL Editor.

  3. Place the cursor in the desired location in the code, right-click and select Adaptive Server Enterprise | SQL/XML Wizard. You can also open the SQL/XML Wizard from the SQL/XML Wizard icon on the toolbar. The Select a Wizard dialog appears. Select the appropriate XML Query function:

    • Apply XML query expression – Select this wizard to use the xmlextract function to apply an XML query to an XML document and return the selected results.

      See Parsing an XML Document with xmlextract to continue.

    • Evaluate XML query expression – Select this wizard to use the xmltest function to apply an XML query to an XML document and return a boolean result.

      See Parsing an XML Document with xmltest to continue.

    • Parse XML to image – Select this wizard to use the xmlparse function to parse and index an XML document to improve processing efficiency.

      See Parsing an XML Document with xmlparse to continue.

    • Examine parsed images – Select this wizard to use the xmlrepresentation function to determine whether a given image column contains a parsed XML document.

      See Parsing an XML Document with xmlrepresentation to continue.

Using Mapping Functions

Real-Time Messaging Services

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com