I suspect that your code is not actually doing DTD validation, but that it *is* reading the DTD.  You can switch DTD validation off (in fact, it is off by default) but you cannot stop the XML parser reading the DTD, because it is needed for things such as entity expansion as well as validation. If you don't want the XML parser to read the DTD, the only way to achieve this (if you can't remove the reference from the source file) is to use an EntityResolver which redirects the parser to a local copy of the DTD or to a dummy DTD. Most people do this by using XML Catalogs, which provide a list of DTD locations and the places to fetch them from. There's plenty of information you can google about how to use XML Catalogs with Saxon.

Michael Kay

On 08/06/2011 20:29, Tim McCardle wrote:



The code below is being used to generate HTML by applying XSL to XML.


However, it is unclear how to turn off the validation of the XML due to a DTD references in the XML.






public static String applyXslToXml(String sourceID, String xslID) throws TransformerException,

TransformerConfigurationException {


// Create a transform factory instance.

TransformerFactory tfactory = TransformerFactory.newInstance();


// Create a transformer for the stylesheet.

Transformer transformer = tfactory.newTransformer(new StreamSource(new File(xslID)));

TransformerFactory ByteArrayOutputStream out = new ByteArrayOutputStream();


// Transform the source XML to System.out.

transformer.transform(new StreamSource(new File(sourceID)), new StreamResult(out));

String outString = out.toString();

return outString;

------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help