You can always derive a new class from DOMParser and use your parser
instead of DOMParser. You just override just the XMLDecl event from the
scanner and store that information in your parser object. Then later, you
can get the info from the parser. You can't store it in the DOM at this
point, I don't think. But if getting it out fo the parser is sufficient you
can do that.
----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
[EMAIL PROTECTED]
"KRAUSE,MIKE (HP-FtCollins,ex1)" <[EMAIL PROTECTED]> on 03/08/2000
03:18:40 PM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc:
Subject: RE: Getting DOCTYPE from xml file
It's not implemented? Why doesn't it say so in the XML4C documentation?
Anyway, this means that, for now, I have to hard code somewhere knowledge
of
WHICH type of XML file I am saving (I am dealing with many different DTDs
validating different XML files). This is certainly not what I desired.
In order to accomplish this I would have to get the document element from
the DOM_Document, see what it is, then do a lookup in a table that would
give me the appropriate <!DOCTYPE...> string to write out.
Isn't there a nicer way to do this? (He asks pleadingly...)
- Mike
-----Original Message-----
From: Jeff Lewis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 08, 2000 4:05 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Getting DOCTYPE from xml file
The DOM_DocumentType::getDocType function is not yet implemented in the C++
DOM.
What I did is I have an DOM_WRITER class that I use to, you guessed it,
write out a DOM to an XML file, character buffer, etc.
The constructor for that class accepts the doctype specification and then,
when DOM_WRITER::Write() gets called, it sneaks the doctype line into the
XML.
-----Original Message-----
From: KRAUSE,MIKE (HP-FtCollins,ex1) [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 08, 2000 3:59 PM
To: [EMAIL PROTECTED]
Subject: Getting DOCTYPE from xml file
Hi,
I'm using the DOMPrint example as the basis for a SaveFile function I'm
writing. One problem I'm encountering is that the DOMPrint example does
not
print the <!DOCTYPE ...> declaration in my XML file.
If I have the following sample XML file...
<?xml version="1.0" standalone="no"?>
<!DOCTYPE foo SYSTEM "foo.dtd">
<foo>
...
</foo>
And the following code... (assume that doc is a valid DOM_Document node
returned from the parser and that it refers to the aforementioned file)
void somefunc(DOM_Document &doc) {
DOM_DocumentType docType = doc.getDoctype();
DOMString dtdName = docType.getName();
}
Why is it that if I call the DOM_Document's getDoctype() method I get a
null
DOM_DocumentType node? Should I be doing something else in order to print
out the "<!DOCTYPE foo SYSTEM "foo.dtd">" line?
One last thing... how do I output the first line of my XML document
verbatim?
Regards,
Mike Krause
Hewlett-Packard Company