0

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?

3
  • Please, share more stack trace about that error, so we would know the place of failure. Also you just don't share what exactly transformer you are talking about. Commented Dec 18, 2024 at 18:53
  • Hi Artem, I edited my question. Commented Dec 19, 2024 at 9:52
  • Still not clear what exactly is your configuration which throws that exception. Commented Dec 19, 2024 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.