DB2®Connection.RegisterXmlSchema(string, string, string[ ], string[ ], string[ ], string, bool) Method
Registers the XML schema with the database, including the URLs for the files containing the XML document property data, and a URL for the file containing the XML schema properties document.
- Namespace:
IBM.Data.DB2- Assembly:
IBM.Data.DB2(inIBM.Data.DB2.dll)
Syntax
[Visual Basic]
Public Sub RegisterXmlSchema(
ByVal schema As String,
ByVal name As String,
ByVal ParamArray schemaLocations() As String,
ByVal ParamArray docUrls() As String,
ByVal ParamArray docPropertyUrls() As String,
ByVal schemaPropertyUrl As String,
ByVal isUsedForDecomposition As bool
) As String
[C#]
public String RegisterXmlSchema(
String schema,
String name,
String[] schemaLocations,
String[] docUrls,
String[] docPropertyUrls,
String schemaPropertyUrl,
bool isUsedForDecomposition
);
[C++]
public: String RegisterXmlSchema(
String schema,
String name,
String[] schemaLocations,
String[] docUrls,
String[] docPropertyUrls,
String schemaPropertyUrl,
bool isUsedForDecomposition
);
[JScript]
public function RegisterXmlSchema(
schema : String,
name : String,
schemaLocations : String[] *,
docUrls : String[] *,
docPropertyUrls : String[] *,
schemaPropertyUrl : String,
isUsedForDecomposition : bool
) : String;
Parameters
- schema
- SQL schema name for the XML document. The schema argument can have a NULL value, which indicates that the default SQL schema, as defined in the CURRENT SCHEMA special register, is used.
- name
- Name of the XML schema. When a NULL value is provided for the name argument, a unique value is generated and stored within the XML schema repository (XSR).
- schemaLocations
- String array containing one or more schema locations to be added. The XML schema at index 0 of schemaLocations arrays is taken to be the primary schema.
- docUrls
- String array containing one or more schema documents to be added. The XML schema at index 0 of docUrls arrays is taken to be the primary schema.
- docPropertyUrls
- String array containing one or more property documents for the specified schema documents.
- schemaPropertyUrl
- Specifies XML schema properties for the primary XML schema.
- isUsedForDecomposition
- The value of TRUE indicates that the XML schema is used for decomposition.
Example
Sample order.xsd contains:
<xsd:schema
targetNamespace="http://www.test.com/po"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:po="http://www.test.com/po"
xmlns:prod="http://www.test.com/prod"
xmlns:cust="http://www.test.com/cust">
<xsd:include schemaLocation="header.xsd"/>
<xsd:import namespace="http://www.test.com/prod" schemaLocation="prod.xsd"/>
<xsd:import namespace="http://www.test.com/cust" schemaLocation="cust.xsd"/>
<xsd:complexType name="itemType">
<xsd:sequence>
<xsd:element name="Item" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ItemDescription" type="prod:prodType"/>
<xsd:element name="NumberOrdered" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="potype">
<xsd:sequence>
<xsd:element name="Header" type="po:headerType"/>
<xsd:element name="Items" type="po:itemType"/>
<xsd:element name="Customer" type="cust:customerType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="PurchaseOrder" type="po:potype"/>
</xsd:schema>Sample header.xsd contains:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="headerType">
<xsd:sequence>
<xsd:element name="Id" type="xsd:integer" />
<xsd:element name="date" type="xsd:date" />
<xsd:element name="description" type="xsd:string" />
<xsd:element name="value" type="xsd:integer" />
<xsd:element name="status" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>Sample cust.xsd contains:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.test.com/cust" >
<xsd:complexType name="customerType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" />
<xsd:element name="Address" type="xsd:string" />
<xsd:element name="Phone" type="xsd:string" />
<xsd:element name="email" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
</xsd:schema>Sample prod.xsd contains:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.test.com/prod" >
<xsd:complexType name="prodType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string" />
<xsd:element name="SKU" type="xsd:string" />
<xsd:element name="Price" type="xsd:integer" />
<xsd:element name="Comment" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="color" type="xsd:string" />
<xsd:attribute name="weight" type="xsd:integer" />
</xsd:complexType>
</xsd:schema>The following C# code example demonstrate
use of the RegisterXmlSchema method:
using (DB2Connection conn = new DB2Connection(connStr))
{
try
{
String[] schemaLocs = new String[4]
{
"http://www.test.com/po",
"header.xsd",
"prod.xsd",
"cust.xsd"
};
String[] xsdFiles = new String[4]
{
"order.xsd",
"header.xsd",
"prod.xsd",
"cust.xsd"
};
// Register xml schema
conn.RegisterXmlSchema("NEWTON", "POXSD", schemaLocs, xsdFiles, null, null, false);
}
catch (Exception e)
{
// exception handling
}
}Return value
Function return the schema name, as supplied or as generated by Db2®.