www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Phrases
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web & Internet
XML
xmlagg
xmlattributes
xmladdattribute
xmlappendchildren
xmlconcat
xmlelement
xmlforest
xmlinsertafter
xmlinsertbefore
xmlreplace
xmltype.xmltype
xmltype.createnonsch...
xmltype.createschema...
xmltype.createxml
xmltype.existsnode
xmltype.extract
xmltype.getclobval
xmltype.getnamespace
xmltype.getnumval
xmltype.getrooteleme...
xmltype.getschemaurl
xmltype.getstringval
xmltype.isfragment
xmltype.isschemabase...
xmltype.isschemavali...
xmltype.isschemavali...
xmltype.schemavalida...
xmltype.setschemaval...
xmltype.toobject
xmltype.transform
xmlupdate
xper navigation
createxml
isentity
serialize_to_utf8_xm...
tidy_html
tidy_list_errors
updatexml
xml_add_system_path
xml_auto
xml_auto_dtd
xml_auto_schema
xml_create_tables_fr...
xml_cut
xml_doc_output_optio...
xml_get_system_paths
xml_load_mapping_sch...
xml_load_schema_decl
xml_namespace_scope
xml_persistent
xml_set_ns_decl
xml_template
xml_tree
xml_tree_doc
xml_tree_doc_media_t...
xml_uri_get
xml_validate_dtd
xml_validate_schema
xml_view_dtd
xml_view_schema
xmlsql_update
xpath_eval
xper_cut
xper_doc
xper_locate_words
xpf_extension
xpf_extension_remove
xquery_eval
xslt
xslt_format_number
xslt_sheet
xslt_stale
xte_head
xte_node
xte_node_from_nodebl...
xte_nodebld_acc
xte_nodebld_final
xte_nodebld_init
xtree_doc
XPATH & XQUERY

Functions Index

xml_auto_schema

returns an XML schema for the result of an SQL query with a FOR XML clause
varchar xml_auto_schema (in query varchar, in root_element varchar);
Description

This function returns an XML schema for the results of an SQL query with a FOR XML clause. The returned schema will apply to the output generated by xml_auto() with the query in question after wrapping it in the specified root element.

Parameters
query – SQL query
root_element – name of root element container
Return Types

varchar result containing the schema of the XML document.

Errors

If the query argument is not a valid SQL statement, i.e. SQL compiler signals an error message, the function resignals the error.

Examples
Simple Schema Generation
SQL> select xml_auto_schema ('  select "category"."CategoryID", "CategoryName",
		"ProductName", "ProductID"
	from "Demo".."Categories" "category", "Demo".."Products" as "product"
	where "product"."CategoryID" = "category"."CategoryID"
	for xml auto element', 'root');
 callret
VARCHAR
_______________________________________________________________________________

<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema">

 <xsd:annotation>
  <xsd:documentation>
   Schema for output of the following SQL statement:
   <[CDATA[  select "category"."CategoryID",
     "CategoryName", "ProductName", "ProductID"
     from "Demo".."Categories" "category",
     "Demo".."Products" as "product"
     where "product"."CategoryID" = "category"."CategoryID"
     for xml auto element]]>
  </xsd:documentation>
 </xsd:annotation>

 <xsd:element name="root" type="root__Type"/>

 <xsd:complexType name="root__Type">
  <xsd:element name="category" type="category_Type"
  minOccurs="0" maxOccurs="unbounded"/>
 </xsd:complexType>

 <xsd:complexType name="category_Type">
  <xsd:element name="CategoryID" type="xsd:int" precision="10"/>
  <xsd:element name="CategoryName" type="xsd:string" maxLength="15"/>
  <xsd:element name="product" type="product_Type" minOccurs="0" maxOccurs="unbounded"/>
 </xsd:complexType>

 <xsd:complexType name="product_Type">
  <xsd:element name="ProductName" type="xsd:string" maxLength="40"/>
  <xsd:element name="ProductID" type="xsd:int" precision="10"/>
 </xsd:complexType>

</xsd:schema>

1 Rows. -- 5 msec.
See Also

xml_auto()

xml_auto_dtd()