【问题标题】:How to read the processing-instructions properties?如何读取处理指令属性?
【发布时间】:2013-04-18 10:01:10
【问题描述】:

我有 XML 中的处理指令。

当我们应用

时,如何在处理指令中获取 id
<xsl:template match="Dest" >
    <?abc ?abc:Dest id="e47529cb-4d17-461b-8438-e3b6d9ec1a68"??>
</xsl:template>

【问题讨论】:

    标签: xml xslt xslt-1.0 xslt-2.0


    【解决方案1】:

    解决办法是:

    输入:

    <abc>
    <?abc ?abc:Dest id="e47529cb-4d17-461b-8438-e3b6d9ec1a68"??>
    </abc>
    

    XSLT:

    <?xml version='1.0' ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:template match="processing-instruction('abc')">
        <P-I><xsl:value-of select="substring-before(substring-after(.,'id=&quot;'),'&quot;')"/></P-I>
      </xsl:template>
    </xsl:stylesheet>
    

    输出:

    <P-I>e47529cb-4d17-461b-8438-e3b6d9ec1a68</P-I>
    

    【讨论】:

      猜你喜欢
      • 2012-10-15
      • 1970-01-01
      • 1970-01-01
      • 2013-06-11
      • 2020-09-05
      • 2013-11-26
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      相关资源
      最近更新 更多