Trying to implement match function in XSL using TXE 2.0 specs for conflict resolution for template rules. Basically want to check the priority and wondering if for the below attributes I am doing anything wrong as I dont get results. Want to do the following in my match statements:
attribute(*, T) whose priority is 0
attribute(A, T) whose priority is 0.25
More on priorities: http://www.w3.org/TR/xslt20/#conflict
Want my match statements to pass through the above 2 attributes so what changes should I make to help me achieve the result. so basically I want some test case that passes my match statements for above 2 attributes
My effort:
Here is my XML:
<CCC>ccc1</CCC>
<CCC attr2="1">ccc2</CCC>
<XXX>XXX1</XXX>
<XXX attr6="1">XXX10</XXX>
XSL:
<xsl:template match="attribute(*, CCCtype)">
<match>CCC type: <xsl:value-of select="."/></match>
</xsl:template>
<xsl:template match="attribute(attr6, XXXtype)">
<match>attr 6 with XXX: <xsl:value-of select="."/></match>
</xsl:template></xsl:template>
schema:
<xsd:element name="XXX" type="XXXtype"></xsd:element>
<xsd:complexType name="XXXtype">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="attr6" type="xsd:string" use="optional"></xsd:attribute>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:element name="CCC" type="CCCtype"></xsd:element>
<xsd:complexType name="CCCtype">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="attr2" type="xsd:string" use="optional"></xsd:attribute>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
The type in an attribute(name, type)
pattern is the type of the attribute , whereas in your examples the CCCtype
and XXXtype
types are the types of the elements that the attributes belong to. For "any attribute of an element of type CCCtype
" you'd need
element(*, CCCtype)/@*
and for "the attr6
attribute on any element whose type is XXXtype
element(*, XXXtype)/@attr6
Both of these patterns have the same default priority, but they couldn't match the same nodes anyway as there's no inheritance relation between the two types - an element can't be both CCCtype
and XXXtype
at the same time.
And finally it goes without saying that this will require a schema-aware XSLT 2.0 processor such as Saxon-EE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.