Saturday, February 5, 2011

How to get line number information from XMLBeans' XMLError

The subject basically says it all.

XmlBeans' XmlError.getLine() always returns -1.

Is there any way to get at least an approximate position for an error?

I have already tried the XmlObject, but since whitespace, quotes, et al. are stripped or changed, that's not much help.

  • The documentation suggests you can do this by providing XmlOptions:

    setLoadLineNumbers

    If this option is set, line number annotations are placed in the store when parsing a document. This is particularly useful when you want XmlError objects to contain line numbers. Note: This adds line numbers info only for start tags. For line number info on end tags use: setLoadLineNumbers(java.lang.String) Example: xmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT)

    From McDowell

0 comments:

Post a Comment