Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Lexical information?

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Michael Kay <mike AT saxonica.com>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Lexical information?
  • Date: Tue, 31 May 2016 22:05:13 +0100

There is of course no universal definition of what constitutes "lexical"
information.

However, the use cases for retaining line/column information are perhaps
stronger than for the things like CDATA sections and entity references that
we often classify under this heading. Almost anything that can be described
as "validation" - whether it's XSD-like validation, or semantic validation
such as an XSLT processor performs on XSLT input, needs to give the user
feedback in terms of line/column locations, and a tree model that preserves
line and column information is almost essential for such applications.

Michael Kay
Saxonica


> On 31 May 2016, at 19:31, Elliotte Rusty Harold <elharo AT ibiblio.org> wrote:
>
> No, Xerces/SAX throws away a lot of lexical information; and XOM throws
> away more. General purpose parsers are not adequate for the rare use cases
> such as editors that actually need to preserve the lexical information.
>
> On Tue, May 31, 2016 at 8:04 AM, <nu.xom AT io7m.com> wrote:
>
>> Hello.
>>
>> I'm writing a program that accepts a XOM-produced AST and performs
>> various operations on it.
>>
>> There are various properties of the AST that cannot be expressed by a
>> RELAX-NG or XSD schema, so there are inevitably errors that need to be
>> raised when the AST is invalid in some way. In order to allow those
>> errors to be acceptable to users, I need to be able to show them
>> line and column numbers indication the locations of the errors.
>>
>> The problem: XOM appears to discard all lexical information (if any is
>> even provided by the underlying parser). Is there any way I can arrange
>> for lexical information to be preserved in any way? I'm open to any
>> suggestion whatsoever (even populating an IdentityHashMap that maps XOM
>> produced nodes to lexical information would be fine).
>>
>> I would assume that the solution would first involve getting SAX or
>> whatever is doing the parsing to supply that information (which it
>> presumably does at some point, because many of the exception types have
>> line and column information). I would then somehow need to intercept
>> that information before XOM consumes it, and then somehow associate the
>> produced XOM nodes with the information I intercepted.
>>
>> M
>> _______________________________________________
>> XOM-interest mailing list
>> XOM-interest AT lists.ibiblio.org
>> http://lists.ibiblio.org/mailman/listinfo/xom-interest
>>
>
>
>
> --
> Elliotte Rusty Harold
> elharo AT ibiblio.org
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest






Archive powered by MHonArc 2.6.24.

Top of Page