代码之家  ›  专栏  ›  技术社区  ›  bobber205

XSLT和XPATH:无法读取某些属性

  •  0
  • bobber205  · 技术社区  · 15 年前
    <field type="math" size="12"  unitText="%" unitPos="back"/>
    

    我可以从各自的字段中选择“type”和“12”,但我不能对unitText和unitPos执行相同的操作。知道为什么吗?

    下面是我用来打印字体和大小的。

    <xsl:value-of select="@size"/>
    

    我用这一行输入“字段”标签

    <xsl:template match="field" mode="all">
    

    谢谢你的帮助。我的头撞在墙上有一段时间了P

    1 回复  |  直到 15 年前
        1
  •  0
  •   user357812 user357812    15 年前

    我无法重现这个问题。此样式表:

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
        <xsl:template match="field">
            <xsl:apply-templates select="@*"/>
        </xsl:template>
        <xsl:template match="@*">
            <xsl:value-of select="concat(name(),': ',.,'&#xA;')"/>
        </xsl:template>
    </xsl:stylesheet>
    

    输入:

    <field type="math" size="12"  unitText="%" unitPos="back"/>
    

    输出:

    type: math
    size: 12
    unitText: %
    unitPos: back
    
    推荐文章