Registers the DTD with the database.
[Visual Basic]
Public Sub RegisterDTD(
ByVal schema As String,
ByVal name As String,
ByVal systemID As String,
ByVal publicID As String,
ByVal dtdContent As String
) As String
[C#]
public String RegisterDTD(
String schema,
String name,
String systemID,
String publicID,
String dtdContent
);
[C++]
public: String RegisterDTD(
String schema,
String name,
String systemID,
String publicID,
String dtdContent
);
[JScript]
public function RegisterDTD(
schema : String,
name : String,
systemID : String,
publicID : String,
dtdContent : String
) : String;
<!ELEMENT HeadCount (Name)*>
<!ELEMENT Name (Name)*>
<!ATTLIST Name First CDATA #REQUIRED>
<!ATTLIST Name Last CDATA #REQUIRED>
<!ATTLIST Name Relation (self | spouse | child) "self">
<!ENTITY MyFirst "Jeff">
<!ENTITY MyLast "Smith">
<!DOCTYPE HeadCount SYSTEM "HeadCount.dtd">
<HeadCount>
<Name First="Waldo" Last="Pepper">
<Name First="Salt" Last="Pepper" Relation="spouse"/>
<Name First="Red" Last="Pepper" Relation="child"/>
</Name>
<Name First="&MyFirst;" Last="&MyLast;">
<Name First="Sharon" Last="&MyLast;" Relation="spouse"/>
<Name First="Morgan" Last="&MyLast;" Relation="child"/>
<Name First="Shelby" Last="&MyLast;" Relation="child"/>
</Name>
</HeadCount>
using (DB2Connection conn = new DB2Connection(connStr))
{
String dtdContent = null;
String xmlDoc =null;
try
{
TextReader rd = new StreamReader("HeadCount.dtd");
dtdContent = rd.ReadToEnd();
// Register the DTD
conn.RegisterDTD("NEWTON", "HEADCOUNTDTD", "http://dtd1", null, dtdContent);
rd = new StreamReader("HeadCount.xml");
xmlDoc = rd.ReadToEnd();
// insert XML doc into a table validating it using registered DTD
DB2Command cmd = conn.CreateCommand();
cmd.CommandText = "insert into myXmlTable(xmlColumn) values( xmlvalidate( ? ) )";
cmd.Parameters.Add("p1", DB2Type.Xml);
cmd.Parameters[0].Value = xmlDoc;
cmd.ExecuteNonQuery();
//Drop the DTD
conn.DropDTD("NEWTON", "HEADCOUNTDTD");
}
catch (Exception e)
{
// exception handling
}
}
Function returns the DTD name, as supplied or as generated by DB2®.