Hi,
when I correct the error in createDocument the output I get is:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE company
SYSTEM "exp.dtd"><company><product>Xerces-C</product><category
idea="great">XML Parsing Tools</category><developedBy>Apache Software
Foundation</developedBy></company>
which I thin kis what you are expecting. If this is not what you are
getting try downloading the nightly build and giving it another go.
Gareth
On Mon, 7 Oct 2002, Paulo David Oliveira wrote:
> Hi,
>
> In the heading the SYSTEM part, on the left of DOCTYPE, doesn�t appear in my
>output XML file. Can you tell me why!
>
> The Code:
>
>
> int main(int argC, char* argV[])
> {
> // Initialize the XML4C2 system.
> try
> {
> XMLPlatformUtils::Initialize();
> }
>
> catch(const XMLException& toCatch)
> {
> char *pMsg = XMLString::transcode(toCatch.getMessage());
> cerr << "Error during Xerces-c Initialization.\n"
> << " Exception message:"
> << pMsg;
> delete [] pMsg;
> return 1;
> }
>
> // Watch for special case help request
> if (argC > 1)
> {
> cout << "\nUsage:\n"
> " CreateDOMDocument\n\n"
> "This program creates a new DOM document from scratch in memory.\n"
> "It then prints the count of elements in the tree.\n"
> << endl;
> XMLPlatformUtils::Terminate();
> return 1;
> }
>
> {
> // Nest entire test in an inner block.
> // The tree we create below is the same that the XercesDOMParser would
> // have created, except that no whitespace text nodes would be created.
>
> // <company>
> // <product>Xerces-C</product>
> // <category idea='great'>XML Parsing Tools</category>
> // <developedBy>Apache Software Foundation</developedBy>
> // </company>
>
> DOMImplementation* impl =
>DOMImplementationRegistry::getDOMImplementation(X("Core"));
>
> DOMDocumentType* type =
>impl->createDocumentType(X("company"),X(""),X("exp.dtd"));
>
> DOMDocument* doc = impl->createDocument(
> 0, // root element namespace URI.
> X("company"), // root element name
>
> DOMElement* rootElem = doc->getDocumentElement();
>
> DOMElement* prodElem = doc->createElement(X("product"));
> rootElem->appendChild(prodElem);
>
> DOMText* prodDataVal = doc->createTextNode(X("Xerces-C"));
> prodElem->appendChild(prodDataVal);
>
> DOMElement* catElem = doc->createElement(X("category"));
> rootElem->appendChild(catElem);
>
> catElem->setAttribute(X("idea"), X("great"));
>
> DOMText* catDataVal = doc->createTextNode(X("XML Parsing Tools"));
> catElem->appendChild(catDataVal);
>
> DOMElement* devByElem = doc->createElement(X("developedBy"));
> rootElem->appendChild(devByElem);
>
> DOMText* devByDataVal = doc->createTextNode(X("Apache Software
>Foundation"));
> devByElem->appendChild(devByDataVal);
>
> //DOMWriter* theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
> XMLFormatTarget *myFormTarget = new LocalFileFormatTarget("exp.xml");
> ((DOMImplementationLS*)impl)->createDOMWriter()->writeNode(myFormTarget,
>*doc);
> //
> // Now count the number of elements in the above DOM tree.
> //
>
> unsigned int elementCount = doc->getElementsByTagName(X("*"))->getLength();
> cout << "The tree just created contains: " << elementCount
> << " elements." << endl;
> doc->release();
>
> }
>
> XMLPlatformUtils::Terminate();
> return 0;
> }
>
>
>
--
Gareth Reakes, Head of Product Development
DecisionSoft Ltd. http://www.decisionsoft.com
Office: +44 (0) 1865 203192
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]