SophiaFramework UNIVERSE 5.3 |
DTD and XML Schema are the grammars to validate whether or not a XML document is correctly formated when being parsed by a XML parser.
In DTD, data type cannot be defined, and its grammar is not described in XML.
In XML Schema, the syntax is described in XML format, features such as data type definition and namespace handling that not included in DTD are available.
SophiaFramework supports DTD and XML Schema. When DTD or XML Schema is used to parse a XML document, if there is some data that is not regulated by the grammar, error will occur.
The processing of a XML document with DTD uses the following functions of SFXXMLDOMParser/SFXXMLSAXParser
Table 19.10. Function of processing XML documents with DTD
Purpose | Function Name of the SFXXMLDOMParser class | Function Name of the SFXXMLSAXParser class |
---|---|---|
Set the grammar used by the parser. | SFXXMLDOMParser::SetGrammar | SFXXMLSAXParser::SetGrammar |
Verify the XML document by DTD. | SFXXMLDOMParser::SetValidationDTD | SFXXMLSAXParser::SetValidationDTD |
Load the extended DTD file into the XML document with DTD. | SFXXMLDOMParser::SetLoadExternalDTD | SFXXMLSAXParser::SetLoadExternalDTD |
Function of Loading External DTD File | |
---|---|
If DTD is defined as a separate file with the XML document, SetLoadExternalDTD is set to true and DTD file is loaded. |
The following operations can be used to get a SFXXMLDocumentType object from the XML tree object.
Table 19.11. Function of Processing DTD file
Function Name | Description |
---|---|
GetEntities | Get all the entities declared in DTD. |
GetNotations | Get all the notations declared in DTD. |
GetPublicID | Get the public ID of the external subset. |
GetSystemID | Get the system ID of the external subset. |
When processing XML documents with XML Schema, use the following functions of SFXXMLDOMParser or SFXXMLSAXParser class.
Table 19.12. Function of Processing XML Documents with XML Schema
Purpose | Function Name of the SFXXMLDOMParser class | Function Name of the SFXXMLSAXParser class |
---|---|---|
Set the grammar used by parser. | SFXXMLDOMParser::SetGrammar | SFXXMLSAXParser::SetGrammar |
Proccess the XML schema. | SFXXMLDOMParser::SetDoSchema | SFXXMLSAXParser::SetDoSchema |
Verify the XML document by XML schema. | SFXXMLDOMParser::SetValidationSchema | SFXXMLSAXParser::SetValidationSchema |
Specify the XSD file of the XML document with the XML Schema. | SFXXMLDOMParser::SetSchemaLocation | SFXXMLSAXParser::SetSchemaLocation |
Function of Setting Namespace | |
---|---|
If SetDoNamespaces is "true", namespace can be set. |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |