You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Marco <br...@tin.it> on 2004/05/14 23:47:31 UTC

Processing xml without dtd

Is it possible to process xml files with unreachable (or unavailable) DTDs?
Even using a non-validating sax parser as source, xalan still throws
the

javax.xml.transform.TransformerException: java.io.FileNotFoundException: 
office.dtd

where office.dtd is the input file dtd.
Here's the source:

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
spf.setNamespaceAware(true);
XMLReader xmlr = spf.newSAXParser().getXMLReader();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource("notes.xsl"));
t.transform(new SAXSource(xmlr, new InputSource("content.xml")), new 
StreamResult("output.html"));

Thanks in advance,
Marco



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Processing xml without dtd

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Marco,

If you want to prevent Xerces from loading an external DTD, you can 
accomplish this by setting the load-external-dtd [1] feature to false. 
Alternatively if you actually want to load the DTD but it points to an 
inaccessible resource, try setting an entity resolver on the parser which 
returns an input stream to the DTD directly or redirects to another URI, 
perhaps a local file.

[1] 
http://xml.apache.org/xerces2-j/features.html#nonvalidating.load-external-dtd

Marco <br...@tin.it> wrote on 05/14/2004 05:47:31 PM:

> Is it possible to process xml files with unreachable (or unavailable) 
DTDs?
> Even using a non-validating sax parser as source, xalan still throws
> the
> 
> javax.xml.transform.TransformerException: java.io.FileNotFoundException: 

> office.dtd
> 
> where office.dtd is the input file dtd.
> Here's the source:
> 
> SAXParserFactory spf = SAXParserFactory.newInstance();
> spf.setValidating(false);
> spf.setNamespaceAware(true);
> XMLReader xmlr = spf.newSAXParser().getXMLReader();
> TransformerFactory tf = TransformerFactory.newInstance();
> Transformer t = tf.newTransformer(new StreamSource("notes.xsl"));
> t.transform(new SAXSource(xmlr, new InputSource("content.xml")), new 
> StreamResult("output.html"));
> 
> Thanks in advance,
> Marco
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org