Hello,
Kerscaven Marc <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]