0

I have a xml structure like

<TT TXT1="Mouse"/><TT TXT1="Computer"/><TT TXT1="Electronics"/>

I want to select each TXT1 from this xml.I tried some code .my code is like

<xsl:variable name="category" select="cate.xml"/>
<xsl value-of select ="$category/TT/TXT1"/>

But I didn't get the answer. Anyone help?

4

1 回答 1

1
<xsl:variable name="cat-doc" select="document('cate.xml')"/>
<xsl:variable name="txt1-atts" select="$cat-doc//TT/@TXT1"/>

应该允许您选择文档中所有元素的所有TXT1属性。TTcate.xml

如果您想输出这些属性值,那么在 XSLT 2.0 中使用就足够了

<xsl:value-of select="$txt1-atts" separator=", "/>

使用 XSLT 1.0 但是您需要

<xsl:for-each select="$txt1-atts">
  <xsl:if test="position() > 1">, </xsl:if>
  <xsl:value-of select="."/>
</xsl:for-each>
于 2013-05-29T08:56:53.097 回答