Xml 匹配多个OR值,但知道何时使用XSLT
我使用的XSLT可以搜索特定的元素/属性组合,并且(1)在搜索属性值时重命名元素(2)添加包含原始元素名称的属性,以及(3)删除搜索属性。我已经为两个不同的搜索元素使用了相同的属性名,但是我想让它成为一个单独的OR'ed匹配Xml 匹配多个OR值,但知道何时使用XSLT,xml,xslt,Xml,Xslt,我使用的XSLT可以搜索特定的元素/属性组合,并且(1)在搜索属性值时重命名元素(2)添加包含原始元素名称的属性,以及(3)删除搜索属性。我已经为两个不同的搜索元素使用了相同的属性名,但是我想让它成为一个单独的OR'ed匹配 <xsl:template match="Values/Value|MultiValue"> 是否有一种方法可以“捕获”匹配的值,以避免在下面的XSLT中为StepClass属性提供特定的属性值?我尝试了元素的值,但那就是获取元素值 <xsl:s
<xsl:template match="Values/Value|MultiValue">
是否有一种方法可以“捕获”匹配的值,以避免在下面的XSLT中为StepClass属性提供特定的属性值?我尝试了元素的值,但那就是获取元素值
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Change Values/Value value of AttributeID -->
<xsl:template match="Values/Value">
<xsl:element name="{@AttributeID}">
<xsl:attribute name="StepClass">Value</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<!-- Change MultiValue to value of AttributeID -->
<xsl:template match="MultiValue">
<xsl:element name="{@AttributeID}">
<xsl:attribute name="StepClass">MultiValue</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<!--empty template suppresses this attribute-->
<xsl:template match="@AttributeID" />
价值
多值
有没有办法“捕获”匹配的价值
没有(至少不容易),但有一种方法可以捕获匹配元素的名称:
<xsl:attribute name="StepClass">
<xsl:value-of select="name()" />
</xsl:attribute>
正是我想要的!太感谢你了!我想我需要更好地表达我的问题。。。。