You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Kerscaven Marc <mk...@yahoo.fr> on 2004/05/03 18:45:42 UTC
Disable DTD validation for Xalan_j 2.6.0
Hello,
I need to disable DTD validation for the java XSLT
processor Xalan_j 2.6.0.
I found a setValidating() for xerces but I can't find
the method for Xalan.
Have-you got a property for this example :
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("birds.xsl"));
transformer.transform(new StreamSource("birds.xml"),
new StreamResult(new FileOutputStream("birds.out")));
Thanks.
Marc
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com
Re: Disable DTD validation for Xalan_j 2.6.0
Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hello,
Kerscaven Marc <mk...@yahoo.fr> wrote on 2004-05-03 12:45:42 PM:
> I need to disable DTD validation for the java XSLT
> processor Xalan_j 2.6.0.
>
> I found a setValidating() for xerces but I can't find
> the method for Xalan.
>
> Have-you got a property for this example :
> TransformerFactory tFactory =
> TransformerFactory.newInstance();
> Transformer transformer = tFactory.newTransformer(new
> StreamSource("birds.xsl"));
> transformer.transform(new StreamSource("birds.xml"),
> new StreamResult(new FileOutputStream("birds.out")));
Xalan-J doesn't provide any means of configuring the XML parser that
it uses to parse a StreamSource. If you need to configure your XML
Parser, the right thing to do is to create an XMLReader, configure it the
way you would like, and use a SAXSource object to pass the XMLReader and
your InputSource to the Transformer. For example,
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
public class Birds {
public static final void main(String[] args) {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(false); // Turn off validation
XMLReader rdr = spf.newSAXParser().getXMLReader();
t.transform(new SAXSource(rdr, new InputSource("birds.xml")),
new StreamResult("birds.out"));
}
}
I hope that helps.
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro Xalan development
IBM SWS Toronto Lab T/L 969-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com