DB2 10.5 for Linux, UNIX, and Windows

DB2Connection.DropXmlSchema Method

Drops the XML schema registered with the database.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax

[Visual Basic]
Public Sub DropXmlSchema(
   ByVal schema As String,
   ByVal name As String

)
[C#]
public void DropXmlSchema(
   String schema,
   String name
);
[C++]
public: void DropXmlSchema(
   String schema,
   String name

);
[JScript]
public function DropXmlSchema(
   schema : String,
   name : String
);

Parameters

schema
Name of the schema containing the registered document type definition (DTD).
name
Name of the DTD.

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 DropXmlSchema method:
using (DB2Connection conn = new DB2Connection(connStr))
{
	String xmlDoc =null;

	try 
	{
		// Register xml schema
		conn.RegisterXmlSchema("NEWTON", "BOOKXSD", new string[1] { "http://www.test.com/book.xsd" }, new String[1] { "book.xsd"});

		TextReader rd = new StreamReader("book.xml");
		xmlDoc = rd.ReadToEnd();

		// insert XML doc into a table validating it using registered schema
		DB2Command cmd = conn.CreateCommand();
		cmd.CommandText = "insert into myXmlTable(xmlColumn) values( xmlvalidate( ? according to xmlschema id NEWTON.BOOKXSD) )";
		cmd.Parameters.Add("p1", DB2Type.Xml);
		cmd.Parameters[0].Value = xmlDoc;
		cmd.ExecuteNonQuery();

		//Drop the xml schema
		conn.DropXmlSchema("NEWTON", "BOOKXSD");
	}
	catch (Exception e)
	{
		// exception handling
	}
}

Return value

Function does not return a value.