I have group definitions in an XML schema. Like so:
<attributeGroup name="my_attributes">
<attribute ref="ns:foo" />
<attribute ref="ns:bar" />
</attributeGroup>
Also, I have an XML transformation, in which I want to be able to reuse these definitions. Is it possible to create a template that matches such a group? Something like this maybe:
<xsl:template matchGroup="my_attributes">
<foobar>
<xsl:copy-of select="@*"/>
<xsl:value-of select="." />
</foobar>
</xsl:template>
No, the XSLT
<xsl:template>instruction doesn’t have amatchGroupattribute andany compliant XSLT processor must raise a syntax error for this reason.
Something like this is probably close to what you are looking for:
The meaning of the match pattern above:
Match any attribute with
local-name()foothat is in the namespace to which the prefix"ns:"is associated, and whose “parent” (the ellement this attribute is attached to) *has also another attribute that is named*ns:bar.