M
M
mindgrow2021-02-24 22:22:53
Java
mindgrow, 2021-02-24 22:22:53

JAXB - how to disable ampersand checking in xml values?

Good afternoon.

I use JDK8
For deserialization I use regular jaxb

In the nodes of the deserialized xml, there are URLs that contain unescaped ampersands (&).
This is how it should be and should be done so that jaxb does not swear at such values

​​error:
org.xml.sax.SAXParseException; systemId: file: /C: lineNumber: 36; columnNumber: 95; The reference to entity "action" must end with the ';' delimiter.

There is an ampersand at the specified location.

Tried to disable validation:
CharacterEscapeHandler escapeHandler = NoEscapeHandler.theInstance;
jaxbUnmarshaller.setProperty("com.sun.xml.bind.characterEscapeHandler", escapeHandler);

but package com.sun.xml.internal.bind.marshaller.NoEscapeHandler; I don't have it and I can't use it.

How can I disable this check so that the values ​​in the tags are accepted as is?

CharacterEscapeHandler
link 1

ValidationEventHandler
link 1
link 2
link 3

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question