如何僅使用 XSLT 取消注釋特定元素 'navref',任何人都可以研究一下并提出建議嗎?
XML 輸入:
<?xml version="1.0" encoding="UTF-8"?>
<topicgroup collection-type="sequence">
<!--Handling topicref with navref-->
<topicref collection-type="sequence" id="107746"
href="../../../../../../Section_General_Notes/107746.dita">
<topicmeta>
<navtitle/>
<critdates>
<created date="09-Apr-2009" golive="01-Jul-2009" expiry=""/>
</critdates>
<data name="section_num" value="55"/>
</topicmeta>
</topicref>
<!--<navref mapref="../../../../../../Section_General_Notes/107746.ditamap"/>-->
</topicgroup>
預期輸出:
<?xml version="1.0" encoding="UTF-8"?>
<topicgroup collection-type="sequence">
<!--Handling topicref with navref-->
<topicref collection-type="sequence" id="107746"
href="../../../../../../FASB_Section_General_Notes/107746.dita">
<topicmeta>
<navtitle/>
<critdates>
<created date="09-Apr-2009" golive="01-Jul-2009" expiry=""/>
</critdates>
<data name="section_num" value="55"/>
</topicmeta>
</topicref>
<navref mapref="../../../../../../Section_General_Notes/107746.ditamap"/>
</topicgroup>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="comment()" priority="1">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
</xsl:stylesheet>
參考網址: https ://xsltfiddle.liberty-development.net/6qtiBni/1
uj5u.com熱心網友回復:
代替:
<xsl:template match="comment()" priority="1">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
嘗試:
<xsl:template match="comment()[starts-with(., '<navref')]" >
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/484393.html
