SAXParser doesn't allow Xinclude



I'm trying to unmarshal an xml document that has the <xi:include> tag inside it. But SAXParser doens't allow this even though I specificly tell the SAXParserFactory to allow it.


The Java code:



SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setXIncludeaware(true);
spf.setNamespaceAwere(true);

spf.setFeature("http://ift.tt/1qvpWgX", true);
spf.setFeature("http://ift.tt/1msygOw", true);

XMLReader xr = spf.newSAXParser().getXMLReader();
SAXSource source = new SAXSource(xr, new InputSource(inputStream));
JAXBElement<MyClass> el = unmarshaller.unmarshal(source, MyClass.class);


XML Document to read



<?xml version="1.0" encoding="UTF-8"?>
<extension xmlns="http://ift.tt/PRJYjT" xmlns:ext="http://ift.tt/PRJYjT" xmlns:xi="http://ift.tt/1t29o5P">
<visibility>
<resourceConstraints>
<resourceConstraint ext:resourceId="resourceOne">
<role ext:show="true">AdminUsers</role>
</resourceConstraint>
<resourceConstraint ext:resourceId="resourceTwo">
<role ext:show="true">AdminUsers</role>
</resourceConstraint>
</resourceConstraints>
<xi:include href="extraContent.xml" />
</visibility>
</extension>


When I run it I get this exception:



org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 50; cvc-complex-type.2.4.a: Invalid content was found starting with element 'xi:include'. One of '{"http://ift.tt/PRJYjT":resourceConstraints}' is expected.


When I remove the <xi:include> tag from the XML document, the file is unmarshalled just fine. The unmarshaller has a schema attached to it. The schema doens't allow the <xi:include>.


No comments:

Post a Comment