How to read the processing-instructions properties?

霸气de小男生 提交于 2020-01-03 01:47:26

问题


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:


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>


来源:https://stackoverflow.com/questions/16079923/how-to-read-the-processing-instructions-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!