Match processing-instruction()|comment() : processing instruction « XSLT stylesheet « XML






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

 








Related examples in the same category

1.Generate processing-instruction
2.processing-instruction with xlink
3.match="processing-instruction()"
4.match="processing-instruction('xml-stylesheet')"