[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: building a hierarchical classification out of flat

Subject: Re: building a hierarchical classification out of flat and redundant data
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 24 Jul 2006 12:03:43 +0100
name of hierarchical building
This is a grouping problem, in XSLT2 I think you just want

<xsl:stylesheet version="2.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

  <xsl:template match="x" name="group">
    <xsl:param name="level" select="1"/>
    <xsl:param name="items" select="document"/>
    <xsl:for-each-group select="$items" group-by="*[name()=concat('tag',$level)]">
      <node id="{current-grouping-key()}" name="{*[name()=concat('tag',$level,'a')]}">
	<xsl:call-template name="group">
	  <xsl:with-param name="level" select="$level+1"/>
	  <xsl:with-param name="items" select="current-group()"/>

In XSLT1 you can do the same thing, but just replace for-each-group by
one of the standard XSLT 1 grouping idioms (see faq or Jeni's site)

	<tag1a>Social Sciences</tag1a>
	<tag1a>Social Sciences</tag1a>
	<tag1a>Social Sciences</tag1a>
	<tag1a>Social Sciences</tag1a>

$ saxon8 grp2.xml grp2.xsl

<?xml version="1.0" encoding="UTF-8"?>
<node id="3" name="Social Sciences">
   <node id="32" name="Politics">
      <node id="326" name="Slavery"/>
   <node id="33" name="Economics"/>

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.