[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|