You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Matt Budd <ma...@madentec.com> on 2004/01/14 16:35:08 UTC
Specifying a DTD at parse-time
Hello..
I am a bit new to XML, and have decided to try and use the Xerces C++
DOM-parser instead of Microsoft's offerings. Here's my problem:
I'm reading in an XML file as input to the program. I also have defined
a valid DTD that describes the format of the file. What I want to do
is, when the parser is reading in the file, tell the parser to use my
DTD. I want to do this in code, I don't want the XML to have to say
what DTD it is following (via its "<!DOCTYPE" tag). I'd also prefer to
tell the parser to use this DTD string, instead of having to write the
DTD string out to a temp file and telling the parser to use that file.
I couldn't really see any obvious way in the documentation to do it. I
think it would be possible using Schema, but I'd rather stay with the
simple DTD architecture if possible.
And also, maybe I'm going about this the wrong way. However, if I leave
it up to the XML file to specify its DTD, then a syntactically-valid,
yet functionally-invalid XML file will pass through the parser. For
example, an XML file describing authors, while syntactically-valid
because it specifies its own DTD, doesn't make sense for an application
that expects an XML file describing car parts. Shouldn't this kind of
checking be done using the parser and the DTD? If you were then to tell
the parser to use the car-part DTD when parsing _all_ incoming XML
files, only those that are valid car-part files would pass, right?
Would that be the best way to go about it?
Thanks for any info...
- Matt
P.S. - Sorry if this is a double post. I sent the first one before I
joined the mailing list and it didn't seem to get through...so now I've
joined the list and hopefully this one gets to you guys..
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org