Details
-
Type:
Wish
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 4.0.7
-
Fix Version/s: None
-
Labels:None
-
Number of attachments :
Description
I'm sure there is a good reason for this, but I couldn't find any documentation telling me why.
I currently want to process an XML document and leave it exactly as it comes in. I.E. no resolving of entities.
XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES or XMLInputFactory.SUPPORT_DTD will do this for entities within elements, but there seems to be no way of leaving entities in attributes unresolved.
I tried using SUPPORT_DTD == false, and then using a custom "com.ctc.wstx.undeclaredEntityResolver" that just returns the entity as is:
public class UndeclaredEntityResolver implements javax.xml.stream.XMLResolver { @Override public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) throws XMLStreamException { String entity = "&" + namespace + ";"; return new ByteArrayInputStream(entity.getBytes()); } }
but this will just result in a recursive entity problem.
Am I missing something?
Is there any nice way I fan accomplish this?