OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: building XML while referring to DTD

> I don't want to have to hard-code a different method for every XML
> document I'm building. Is there a way to "parse" a DTD and then build
> the XML as I iterate over the DTD? Or perhaps a tool or utility that
> makes this easier? Or even some way to check before/during adding an
> element whether it is valid for that DTD? Thanks, Wendi

Most SAX2 parsers expose all the important DTD information [1, 2, 3].
You can save that information and use it later.  Depending on how you
save your DTD and document data, you may be able to validate your data
at any time by turning your data into SAX events [4].  

- Dave

[1] http://sax.sourceforge.net/apidoc/org/xml/sax/ext/DeclHandler.html
[2] http://sax.sourceforge.net/apidoc/org/xml/sax/ext/LexicalHandler.html
[3] http://sax.sourceforge.net/apidoc/org/xml/sax/DTDHandler.html
[4] http://www.gnu.org/software/classpathx/jaxp/apidoc/gnu/xml/pipeline/ValidationConsumer.html