xml editor

   XML Editor
   XML Author
      DITA Editor
      DocBook Editor
      TEI Editor
      XHTML Editor
      Schema Editor
      XML Schema Editor
      RelaxNG Editor
   XQuery
   SVN Client
      Office Open XML
      XSL:FO Editor
      SVG Editor
      WSDL Editor
Supported platforms
Compatible with Windows7 & Mac OS X Snow Leopard
Ready for
data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Grouping problem


Subject: [xsl] Grouping problem
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Mon, 1 Aug 2005 12:26:50 +0530

I have the following XML file -
<?xml version="1.0" encoding="UTF-8"?>
<root>
   <a>1</a>
   <b>2</b>
   <d>3</d>
   <d>4</d>
   <b>5</b>
   <b>6</b>
   <c>7</c>
   <c>8</c>
   <a>9</a>
</root>

I am trying to do grouping operation with the following XSL -
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

	<xsl:template match="/root">
	   <groups>
  	     <xsl:for-each select="*[not(name() = name(preceding-sibling::*))]">
            <group name="{name()}" />
   	     </xsl:for-each>
	   </groups>
	</xsl:template>

</xsl:stylesheet>

I am expecting output -
<groups>
   <group name="a" />
   <group name="b" />
   <group name="c" />
   <group name="d" />
</groups>

But I get output -
<?xml version="1.0" encoding="UTF-8"?>
<groups>
<group name="a"/>
<group name="b"/>
<group name="d"/>
<group name="d"/>
<group name="b"/>
<group name="b"/>
<group name="c"/>
<group name="c"/>
</groups>

Where is the problem?

This is tested with Xalan-J 2.6.0 and Saxon 8.4

Regards,
Mukul


Current Thread
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2009 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>® XML Editor