【发布时间】:2020-07-13 02:58:04
【问题描述】:
我有一个xml
<PiecesTransportationQuantity unitCode="EA" text="1.0"/>
需要将“text”属性的值转换为相同的字段值,属性unitCode应保留为属性:
<PiecesTransportationQuantity unitCode="EA"> 1.0 </PiecesTransportationQuantity>
请求提供相同的 xslt。
我用过
<xsl:template match="PiecesTransportationQuantity/@unitCode/@text">
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
模板>
【问题讨论】:
-
模式
PiecesTransportationQuantity/@unitCode/@text永远不会匹配任何东西:一个属性不能是另一个属性的子属性。 -
不能使用像
/@unitCode/@text这样的模式。正如上面@michael.hor257k 指出的那样,您可以一次使用一个属性来匹配。
标签: xml xslt attributes