w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to select unique child nodes of all siblings in XSLT 1

This XSLT stylesheet will produce the desired output. Note that it relies on there being no duplicate Gases element inside a single Content element.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text"/>

  <xsl:strip-space elements="*"/>

  <!-- Match Gases elements whose value does not appear in a Gases
element inside a previous
       Content element. -->
  <xsl:template match="//Gases[not(. =
ancestor::Content/preceding-sibling::Content//Gases)]">
    <xsl:value-of select="."/>
    <xsl:text> </xsl:text>
  </xsl:template>

  <!-- Need to override the built-in template for text nodes, otherwise
they will still get
       printed out. -->
  <xsl:template match="text()"/>

</xsl:stylesheet>




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.