The ForXmlTree function described in “Using ForXmlTree to map SQL data to hierarchic XML” maps a collection of SQL tables or result sets to a hierarchic XML document. The OpenXml function reverses this process, and extracts the data for a SQL table from an input XML document.
OpenXml is similar to the xmlextract function, introduced in Adaptive Server 12.5.1, which extracts a specified data value from a given XML document. xmlextract specifies an XML document and a single XPath query expression. It returns the result of applying the XPath query to the XML document.
The new Java-based OpenXml function:
Can be invoked from either a client command line or a client Java application. It is not intended for use in the SQL server.
Requires arguments that include the specified XML document and a set of options that specify the XPath query that extracts the desired output rows and the Xpath queries that extract the desired columns in each output row.
Thus, you can regard OpenXml as a two-dimensional xmlextract.
OpenXml performs either or both of these actions:
Generates a SQL script to create and populate a SQL table with the extracted data.
Executes that script to create the SQL tables with the extracted data.
The following examples assume that the XML document in “Sample data and its tree-structured XML representation” is stored in example-document.xml.
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |