Package com.github.oowekyala.ooxml.messages


package com.github.oowekyala.ooxml.messages
Simple API to produce nice error messages when reading an XML file.

Use

invalid reference
XmlErrorUtils::parse
to get an instance of an XmlPositioner. This object is used to associate Nodes with their location, and create message entries (under the form of an XmlException) featuring context information.

For example, if an XML parse exception occurs, instead of

javax.xml.transform.TransformerException: The entity "amb" was referenced, but not declared.
the exception has the following message:
XML parsing error (in /some/file.xml)
    1| <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2| <list>
    3|     <list foo="&amb;"/>
                           ^ The entity "amb" was referenced, but not declared.

    4| </list>
or
Error at /some/file.xml:3:21 - The entity "amb" was referenced, but not declared.
if you use eg NiceXmlMessageFormatter.SINGLE_LINE.

This API is also useful to validate an XML file after it's parsed, and emit targeted error messages that come with the same kind of file help. See XmlMessageReporter.

XmlPositioner is meant as a low-level utility, to build helpers such as XmlMessageReporter.