How to read the processing-instructions properties

2019-06-07 18:33发布

I have processing-instructions in XML.

How can I get the id value in processing-instruction when we apply the

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

1条回答
够拽才男人
2楼-- · 2019-06-07 19:07

The solution is:

INPUT:

<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>

OUTPUT:

<P-I>e47529cb-4d17-461b-8438-e3b6d9ec1a68</P-I>
查看更多
登录 后发表回答