Subject: Re: [xsl] Parsing XPath in XSLT? From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 1 Apr 2020 13:22:46 -0000 |
Dear Gerrit, Thanks indeed for the thorough analysis. I had gotten so far as to detect the XPath 1.0 EBNF wasn't complete, but no further. You have shown me the way. And what a beautiful PR! Best regards -- Wendell OT - hey can I mention how inspiring the current work is with XProc 3.0! Very much looking forward to using that. On Tue, Mar 31, 2020 at 7:45 PM Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Wendell, > > After comparing your XPath 1 EBNF with the XQuery 1.0 EBNF, I thought > that there must be some incantation in the latter that makes REx > understand patterns such as [^"]*. I analyzed the strange error message > about EquivalenceLookAhead that came with 'Literal'. It dawned on me > that REx must have been parsing the EBNF with a REx-generated parser, > for which there must be an EBNF, and there it is: > https://bottlecaps.de/rex/REx.ebnf. > I saw that EquivalenceLookAhead also starts with '[', and then I thought > "there must be a switch token in an EBNF that allows patterns like [^"]* > to appear, and without that token everything that starts with '[' will > be expected to be an EquivalenceLookAhead". And then I remembered that I > already struggled with the <?TOKENS?> PI when editing an EBNF for CSS. > All the terminals (but also other rules that depend on them, I guess) > need to be defined after this token. > > After I fixed it I noticed another issue that REx is not to blame for: > Many productions such as NCName were used but not defined in your XPath > 1 schema. I copied the corresponding definitions from the XQuery schema. > After that, there were different messages, some of them declared as > errors, but there was still no output. > > It seems that you need to move not only all terminals after <?TOKENS?>, > but also most (but not all) productions that directly or indirectly > depend on the terminals. > > I finally managed to get *something* out of REx and I filed a pull > request for that.(https://github.com/wendellpiez/metaschema/pull/2). > > I think the use and the overall necessity of the <?TOKENS?> PI in and > EBNF need to be documented better in REx. > > b Gerrit > > > On 31.03.2020 21:36, Wendell Piez wapiez@xxxxxxxxxxxxxxx wrote: > > Dear XSL-List, > > > > Last week readers helped me with this interesting question of parsing > > a formal language (specifically XPath) in XSLT. A couple of you (John > > L, Christophe) pointed me to Gunther Rademacher's awesome work on the > > REx parser generator. > > > > This is good stuff and I was indeed able to get XPath 2.0 parsing > > running very readily. Fantastic! > > > > What I haven't managed to do yet is get XPath 1.0 parsing. > > > > For that, I need a formal grammar in EBNF that will work in Gunther's > > tool. Conveniently, his other tool that draws railroad diagrams offers > > one -- https://www.bottlecaps.de/rr/ui -- which indeed appears to be > > pulled straight out of the XPath 1.0 Recommendation (see its initial > > comment). Sounds good. > > > > However, while it makes a pretty railroad diagram, this EBNF doesn't > > work in REx. (There is no good reason to think, I suppose, that it > > should, but it is hard not to hope. :-) Possibly it is only partial. > > In any case I need either an EBNF that works, or an education, to > > provide me with the skills to repair this one. > > > > Do you have any helpful hints? What should implementers be looking at, > > for formal descriptions of XPath 1.0 (assuming they want to do that > > today, as I do)? In particular might there be somewhere a > > complete-and-working variant of the XPath 1.0 grammar such as REx can > > consume, or should it actually be pretty easy to make? > > > > Regards, Wendell > > > > PS - If anyone wishes to try the XPath 1.0 EBNF I have copied down > > (which does not work :-): > > > > - REx parser generator: https://www.bottlecaps.de/rex/ > > - non-functioning EBNF: > > https://github.com/wendellpiez/metaschema/blob/issue39-pipeline-refactor/tool chains/xslt-proto-v04/metapath/REx/xpath1.ebnf > > > > Maybe it is not that far off. REx chokes on the production for "Literal". > > Thanks ! wap > > > > On Thu, Mar 26, 2020 at 7:16 PM Liam R. E. Quin liam@xxxxxxxxxxxxxxxx > > <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > >> > >> On Thu, 2020-03-26 at 22:49 +0000, Christophe Marchand > >> cmarchand@xxxxxxxxxx wrote: > >>> I've used REx parser (exactly the URL mentioned by John) during XML > >>> Prague to convert XQuery code into syntax hilighted code in slides, > >>> for a XQuery course. > >> > >> Yes - i used it in XSLT at one point for some simple XSLT coverage > >> checking. (perhaps i should talk about that a bit in the course on > >> analytical XSLT) > >> > >> -- > >> Liam Quin, https://www.delightfulcomputing.com/ > >> Available for XML/Document/Information Architecture/XSLT/ > >> XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. > >> Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org > >> > > > > > > > -- ...Wendell Piez... ...wendell -at- nist -dot- gov... ...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org... ...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Thread | [xsl] XSL-List Guidelines, B Tommie Usdin btusd | |
Date | [xsl] XSL-List Guidelines, B Tommie Usdin btusd | |
Month |