[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Editing XPath expressions (Was: Replacing = with =

Subject: Re: Editing XPath expressions (Was: Replacing = with == and ===)
From: "John Lumley john.lumley@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 Aug 2014 09:30:01 -0000
Re:  Editing XPath expressions (Was: Replacing = with =
> On 3 Aug 2014, at 04:10, "Michael Kay mike@xxxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Yes, parsing XPath expressions into some XML representation is a fairly
specialized requirement but it arises often enough that it would be nice to
have a generic off-the-shelf solution to it. John Lumley, for example, is
doing it in the streamability analysis tool that he's presenting at Balisage
next week, and Phil Fearon does it in his Saxon-CE-based editor.
>
> A good starting point for such things is the Rex parser from Gunther
Rademacher, which is a superb piece of technology that unfortunately suffers
from very poor documentation and packaging.

I used REx to generate a parser for XPath (3) from the EBNF, with the target
language being XSLT of course, and configuring REx to create code that will
generate the parse tree. You'll get some very deep trees indeed, all the way
down from <XPath>, so a simple collapsing process, something like

         xsl:template match="*[count(*)=1]"
             xsl:apply-templates select="*"

will give you more manageable trees. Other cases of collapsing (e.g. dropping
tokens, coalescing axes into AxisStep) are pretty simple. [I'm not on my
programming machine at present so can't check the details precisely, but once
you've got the hang of it, it isn't difficult.]

I agree with Mike that an off-the-shelf solution would be helpful - perhaps a
nice example for an XSLT3.0 xsl:package?

John Lumley

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.