[Home] [By Thread] [By Date] [Recent Entries]
On 05/04/2025 16:35, Roger L Costello costello@xxxxxxxxx wrote:
Is there any way to do indirect referencing in XSLT/XPath? I think it would boil to having a parser and an evaluator that perhaps uses xsl:evaluate the number of times you findB a $ in front of what would be an variable/parameter name, with the handicap that I think you need to make sure you have all global parameters passed to xsl:evaluate. So a hack would be e.g.
B <xsl:output method="text"/> B <xsl:function name="mf:evaluate" as="item()*"> B B B <xsl:param name="expression" as="xs:string"/> B B B <xsl:param name="context-item" as="item()?"/> B B B <xsl:param name="params" as="map(xs:QName, item()*)"/> B B B <xsl:evaluate xpath="$expression" context-item="$context-item" with-params="$params"/> B </xsl:function> B <xsl:param name="UNITS" as="xs:string">METERS</xsl:param> B <xsl:param name="ALTITUDE" as="xs:string">UNITS</xsl:param> B <xsl:param name="AIRCRAFT" as="xs:string">ALTITUDE</xsl:param> B <xsl:template match="/" name="xsl:initial-template">
B B B <xsl:value-of select="analyze-string('$$$AIRCRAFT',
'(\$+)(\p{L}[\p{L}0-9]*)')!*:match!fold-left((1 to
string-length(*:group[@nr = 1])), *:group[@nr = 2], function($name, $n)
{ mf:evaluate('$' || $name, (), map { QName('', 'AIRCRAFT') : $AIRCRAFT,
QName('', 'ALTITUDE') : $ALTITUDE, QName('', 'UNITS'): $UNITS }) })"/>
B </xsl:template></xsl:stylesheet>
|

Cart



