4

I have an XML document with a © entity represented as a string.

<URL IMAGEARTIST="" IMAGESUPPLIER="&copy;salzburg.info "
 URLDESCRIPTION="Skip the Line: Vatican Museums Walking Tour including Sistine Chapel, Raphael&apos;s Rooms and St Peter&apos;s"
 URLLINK="http://www.dynamic.viator.com/graphicslib/3731/SITours/skip-the-line-vatican-museums-walking-tour-including-sistine-chapel-in-rome-115004.jpg" URLType="IMAGE"/>

The Persister throws an exception when it comes across the "copy" reference and tries to deference it:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,42]
Message: The entity "copy" was referenced, but not declared.
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:598)
    at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:83)
    at org.simpleframework.xml.stream.StreamReader.read(StreamReader.java:110)
    at org.simpleframework.xml.stream.StreamReader.read(StreamReader.java:122)
    at org.simpleframework.xml.stream.StreamReader.next(StreamReader.java:94)
    at org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:111)
    at org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:85)
    at org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:84)
    at org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:71)
    at org.simpleframework.xml.core.Persister.read(Persister.java:562)
    at org.simpleframework.xml.core.Persister.read(Persister.java:499)

The Persister doesn't provide any hooks into setting any properties on the XMLInputFactory as recommend in this post "Is there a Java XML API that can parse a document without resolving character entities?"

XMLInputFactory inputFactory = XMLInputFactory.newInstance();
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);

How can I set the IS_REPLACING_ENTITY_REFERENCES to false?

4

0 回答 0