You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@logging.apache.org by Ceki Gülcü <ce...@qos.ch> on 2004/11/22 14:45:39 UTC
Ensuring well-formedness of XML document
Hello,
Given the open-ended nature of log4j configuration files in log4j 1.3,
log4h configuration files do not have a DTD. However, assuming a
non-validating javax.xml.parsers.SAXParser, is there a way for an
application to make sure that an XML document is well-formed before
attempting to parse it?
I guess not since most SAX parsers seem to make only one pass through
the file...
Any suggestions or pointers would be highly appreciated.
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
Re: Ensuring well-formedness of XML document
Posted by Ceki Gülcü <ce...@qos.ch>.
At 04:43 PM 11/22/2004, Endre Stølsvik wrote:
>| > I guess not since most SAX parsers seem to make only one pass through
>| > the file...
>| >
>
>Parse it twice..
Yep, that's exactly what I'm doing now. Parsing it twice. The first time to
ensure well-formedness and the second time to actually do something useful
with the document.
>:)
>
>Endre
--
Ceki Gülcü
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
Re: Ensuring well-formedness of XML document
Posted by Endre Stølsvik <En...@Stolsvik.com>.
| > I guess not since most SAX parsers seem to make only one pass through
| > the file...
| >
..
| JDOM could bring the feature you request but I don't know any valuable
| method in the JAXP API...
Parse it twice..
:)
Endre
Re: Ensuring well-formedness of XML document
Posted by jerome moliere <jm...@nerim.net>.
>
> Hello,
>
Hi Ceki,
> Given the open-ended nature of log4j configuration files in log4j 1.3,
> log4h configuration files do not have a DTD.
yes of course like the ANT build.xml files...
However, assuming a
> non-validating javax.xml.parsers.SAXParser, is there a way for an
> application to make sure that an XML document is well-formed before
> attempting to parse it?
>
as far as I know it's impossible because SAX expects the contents from the
stream to be well-formed...
http://www.jguru.com/faq/view.jsp?EID=103043
> I guess not since most SAX parsers seem to make only one pass through
> the file...
>
that's one of the best reason to choose SAX rather than DOM for huge
documents parsing..
JDOM could bring the feature you request but I don't know any valuable
method in the JAXP API...
HTH
Jerome
> Any suggestions or pointers would be highly appreciated.
>
>
> --
> Ceki Gülcü
>
> The complete log4j manual: http://qos.ch/eclm
> Professional log4j support: http://qos.ch/log4jSupport
>
>
>
--
Auteur cahier du programmeur Java tome 2 - Eyrolles 10/2003
http://www.eyrolles.com/php.informatique/Ouvrages/ouvrage.php3?ouv_ean13=9782212111941