How to uncomment particular element 'navref' only using XSLT, Can anyone look into that and suggest?
XML Input:
<?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>
Expected Output:
<?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>
Reference URL : https://xsltfiddle.liberty-development.net/6qtiBni/1
CodePudding user response:
Instead of:
<xsl:template match="comment()" priority="1">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
try:
<xsl:template match="comment()[starts-with(., '<navref')]" >
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>