XML parsing with SAX | how to handle special characters?

We have a JAVA application that retrieves data from SAP, analyzes it and displays it to users. Data is retrieved using the JCO connector.

Recently, we have been excluded:

org.xml.sax.SAXParseException: Character reference "&#00" is an invalid XML character.

So, we plan to write a new level of indirection, where all special / illegal characters are replaced before parsing XML.

My questions are here:

  • Is there any existing (open source) utility that does the job of replacing illegal characters in XML?
  • Or, if I needed to write such a utility, how should I handle it?
  • Why is the above exception selected?

Thank.

+3
source share
4

, (SAP) . , , XML, .

'&' '&' String.replaceAll(...) from to toXML(), (, "<" " > " ).

+1

. XMLWriter, XML, , XML, SAP.

, & # 00, :

String goodXml = badXml.replaceAll("&#00;", "");
+1

, , 1 XSLT. -, , xsl: param.

, , , XML, , , , .

JCO, , .

0

You can encode / decode non-ASCII characters in XML using the Apache Commons Lang class StringEscapeUtils escapeXML. Cm:

http://commons.apache.org/lang/api-2.4/index.html

To find out how XML character references work, search for “numeric characters” on Wikipedia.

0
source

Source: https://habr.com/ru/post/1737469/


All Articles