-
Notifications
You must be signed in to change notification settings - Fork 20
Closed
Labels
FeatureA change that introduces a new featureA change that introduces a new featurePR PendingA PR has been raised to resolve this issueA PR has been raised to resolve this issueXSLTAn issue related to XSLTAn issue related to XSLT
Description
In the case study #1786 (comment) I encountered a use case where an instruction xsl:xpath would be useful.
<xsl:xpath>
{ "class":
{ "name": f:degenerify(name/@identifier),
"abstract": ? abstract,
"extends": array{? extendedTypes =!> map:merge(apply-templates()) },
"implements": array{? implementedTypes =!> map:merge(apply-templates()) }
...
}
}
</xsl:xpath>
The instruction is very simple: <xsl:xpath>EXPR</xsl:xpath> is equivalent to <xsl:sequence select="EXPR"/>. It's particularly useful because XPath constructors for maps and arrays are so much more concise than the XSLT equivalents. Compared with using xsl:sequence, it means that:
- XML attribute value normalization doesn't kick in, so your formatting is better protected (meaning also that the system has some chance of computing line numbers correctly for diagnostics)
- You haven't tied up either single or double-quotes as an attribute delimiter; both can be freely used within the expression.
- You aren't creating the false impression that you're returning a (multi-item) sequence
Note that the content is NOT a sequence constructor; no child elements are allowed; and the content is not interpreted as a text value template. Unlike xsl:evaluate, the XPath expression is statically fixed.
(This example also introduces apply-templates as a function, but that will be a separate proposal).
Metadata
Metadata
Assignees
Labels
FeatureA change that introduces a new featureA change that introduces a new featurePR PendingA PR has been raised to resolve this issueA PR has been raised to resolve this issueXSLTAn issue related to XSLTAn issue related to XSLT