I'm using spring integration for execute xml element extraction:
<bean id="myDmTypeXPathExpression" class="org.springframework.xml.xpath.XPathExpressionFactoryBean">
<property name="expression" value="/root/level0/*[last()]/local-name()"/>
</bean>
<int-xml:xpath-header-enricher>
<int-xml:header name="dmType" xpath-expression-ref="myDmTypeXPathExpression" overwrite="true"/>
</int-xml:xpath-header-enricher>
In the input I have xml files with ISOEntities into DOCTYPE:
<!DOCTYPE mydocument [
<!ENTITY % ISOEntities PUBLIC "ISO 8879-1986//ENTITIES ISO Character Entities 20030531//EN//XML" "ent/ISOEntities">
%ISOEntities;
]>
all ISOEntities are on my local catalog.
For validate my catalog I have an unitary test like this:
@Test
void check_document_parse() throws Exception {
// GIVEN
Resource xmlResource = loadMyXmlWithISOEntities();
// WHEN
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
documentBuilder.setEntityResolver(loadMyCatalogResolver());
// THEN
documentBuilder.parse(xmlResource.getFile());
}
My spring integration process throw exception:
Caused by: java.io.FileNotFoundException: path/to/my/app/ent/ISOEntities at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1910) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1512) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:646) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1301) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1237) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.startPE(XMLDTDScannerImpl.java:739) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.skipSeparator(XMLDTDScannerImpl.java:2108) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2071) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDInternalSubset(XMLDTDScannerImpl.java:363) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1128)
Is it possible to set entity resolver?