Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Match processing-instruction()comment()

File: Data.xml <wine grape="Chardonnay">   <product>product 2</product>   <year>1997</year>   <price>10.99</price> </wine> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:template match="wine[@grape='Cabernet']">     <xsl:copy>       <xsl:apply-templates />     </xsl:copy>   </xsl:template>   <xsl:template match="wine" />   <xsl:template match="@*|node()|processing-instruction()|comment()">     <xsl:copy>       <xsl:apply-templates         select="@*|node()|processing-instruction()|comment()" />     </xsl:copy>   </xsl:template> </xsl:stylesheet> Output: <?xml version="1.0" encoding="UTF-8"?>