is there a way to disable DTD validation in an XSLT transformer through XML configuration?
I have a specific response from a client that i don't want to validate (for business reasons)
Can I do this in Spring Integration?
Thanks in advance,
Carl
is there a way to disable DTD validation in an XSLT transformer through XML configuration?
I have a specific response from a client that i don't want to validate (for business reasons)
Can I do this in Spring Integration?
Thanks in advance,
Carl
I found this solution:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// stop the network loading of DTD files
factory.setValidating(false);
factory.setNamespaceAware(true);
factory.setFeature("http://xml.org/sax/features/namespaces", false);
factory.setFeature("http://xml.org/sax/features/validation", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
(see here TransformerFactory - avoiding network lookups to verify DTDs)
Since we know that <int-xml:xslt-transformer>
supports source-factory
and result-factory
, there will be just need to provide your onw implementation for them, e.g. based on exisiting DomSourceFactory
and DomResultFactory
, respectivally, and inject that code there in the constructor.
Of course you can inject DocumentBuilderFactory
to that DomSourceFactory
and DomResultFactory
, but you should write some custom FactoryBean<DocumentBuilderFactory>
to initialize DocumentBuilderFactory
in its getObject()
.