Re: [xsl] XPath equivalent to xsl:apply-templates?

Subject: Re: [xsl] XPath equivalent to xsl:apply-templates?
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 12 Jun 2022 20:22:19 -0000
Hi Dimitre,

> Perhaps, if we have a more understandable and simple example,
> we could understand what it exactly is that you need, and why
> you need it in the first place?

Okay, a bit more context to my question.

I am mapping one XML vocabulary to another (a military air navigation standard
to the commercial air navigation standard).

I have a sample XML instance document of the commercial air navigation
standard:

<airports>
    <airport>
        <identifier>____</identifier>
        ....
    </airport>
</airports>

I want to:

(1) Show the mapping in a simple way.
(2) Create a tool which does the mapping; i.e., use the military air nav data
to populate an XML instance document that conforms to the commercial air nav.

I have found a nice way to show the mapping: In the commercial air nav
instance document, embed XPath expressions that shows the mapping, e.g.,

<airports>
    <airport>
        <identifier>$ARPT_row/ICAO</identifier>
        ....
    </airport>
</airports>

For the second part (create a tool that does the mapping) I wrote some code
that extracts the XPath expressions within each element and generates an XSLT
template for each element, e.g.,

    <xsl:template match="airports/airport/identifier">
        <xsl:param name="ARPT_row" tunnel="yes"/>
        <identifier>
            <xsl:value-of select="$ARPT_row/ICAO"/>
        </identifier>
    </xsl:template>

The tricky element is mapping each military airport to commercial airports,
i.e., for each military airport create an <airport> element in the commercial
instance document:

<airports>
    for $i in $ARPT.XML/ARPT/row return the result of applying the template
rule for <airport> for $i
    <airport>
        <identifier>$ARPT_row/ICAO</identifier>
        ....
    </airport>
</airports>

Obviously, "the result of applying the template rule for <airport> for $i" is
not XPath; it's just English.

So my question is: what would be the XPath equivalent of "the result of
applying the template rule for <airport> for $i"?

> Suppose we could write an XSLT processor in pure XPath,
> then the result will still be essentially XSLT with its
> fundamental principles and ideas.

Ah! I guess that is what I was remembering. Sorry for the error.

/Roger

Current Thread