[Home] [By Thread] [By Date] [Recent Entries]
Am 2/11/2023 um 12:57 PM schrieb John Lumley john@xxxxxxxxxxxx:
On 11/02/2023 11:34, Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx wrote:The approach is limited by its use of template matches and regular expressions. For some reason, I donbt feel inclined to write an XPath grammar parser in XSLT. But still, some low-hanging fruit can be obtained. Note that the entry page to the XSLT 3 fiddle with support for Invisible XML through John's library is not https://martin-honnen.github.io/xslt3fiddle/ but https://martin-honnen.github.io/xslt3fiddle/index-iXML.html. There you could then make use of the XPath 3.1 grammar with code like e.g. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" B version="3.0" B xmlns:xs="http://www.w3.org/2001/XMLSchema" B xmlns:jwL="https://github.com/johnlumley" B exclude-result-prefixes="#all" B expand-text="yes"> B <xsl:include href="https://martin-honnen.github.io/xslt3fiddle/xslt/jwiXML.processor.xsl"/
B <xsl:variable name="parsed-xpath31-grammar" select="jwL:compileGrammar(unparsed-text($xpath31-grammar-uri))"/> B <xsl:mode on-no-match="shallow-copy"/> B <xsl:output cdata-section-elements="parsed-tree"/> B <xsl:template match="xpath">
B B B <xsl:copy>
B B B B B <input>{.}</input>
B B B B B <parsed-tree>{jwL:parse($parsed-xpath31-grammar, .)?tree =>
serialize(map{'method':'xml','indent':true()})}</parsed-tree>
B B B </xsl:copy>
B </xsl:template></xsl:stylesheet> and parse e.g. <root> B <examples> B B B <xpath>random-number-generator()?permute(1 to 5)</xpath> B </examples> </root> into
|

Cart



