DB2®Connection.GetXmlSchemaSet Method
Gets the XML schema registered with the database.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Sub GetXmlSchemaSet(
ByVal schema As String,
ByVal name As String
) As XmlSchemaSet
[C#]
public XmlSchemaSet GetXmlSchemaSet(
String schema,
String name
);
[C++]
public: XmlSchemaSet GetXmlSchemaSet(
String schema,
String name
);
[JScript]
public function GetXmlSchemaSet(
schema : String,
name : String
) : XmlSchemaSet;
Parameters
- schema
- Name of the schema containing the registered XML schema.
- name
- Name of the registered XML schema.
Data server restrictions
- Informix®
- This method is not supported.
Example
Sample book.xsd contains:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="www.samplebookstore.com" >
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
</xs:sequence>
<xs:attribute name="year" type="xs:unsignedShort" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
Sample book.xml contains:
<?xml version="1.0" encoding="utf-8"?>
<book xmlns = "www.samplebookstore.com" year="2000">
<title>Book1</title>
</book>
<book xmlns = "www.samplebookstore.com" year="2001">
<title>Book2</title>
</book>
<book xmlns = "www.samplebookstore.com" year="2002">
<title>Book3</title>
</book>
The following C# code example demonstrate
use of the GetXmlSchemaSet method:
using (DB2Connection conn = new DB2Connection(connStr))
{
String xmlDoc =null;
try
{
conn.Open();
// Get xml schema
XmlSchemaSet xmlSchema = conn.GetXmlSchemaSet("NEWTON", "BOOKXSD");
XmlReaderSettings bookSettings = new XmlReaderSettings();
bookSettings.Schemas = xmlSchema;
bookSettings.ValidationType = ValidationType.Schema;
bookSettings.ValidationEventHandler += new ValidationEventHandler(bookSettingsValidationEventHandler);
XmlReader books = XmlReader.Create("book.xml", bookSettings);
while (books.Read()) { ... }
}
catch (Exception e)
{
// exception handling
}
}
Return value
Function returns the XmlSchemaSet object representing all the XML schema documents registered under the specified name.