XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Phil PatchSubject: LGCL XSLT transformation
Author: Phil Patch
Date: 03 Oct 2006 01:15 PM
Originally Posted: 03 Oct 2006 01:14 PM
Hi,

I am currently evaluating your product with a problem i am having with a customer. I am quite new to XML / XSLT but am needing to transform the governemt LGCL.xml to display in a tree like structure.

My query is how can i use XSLT to sort the XML document into this tree structure.

ie -

each item has an ID, and a possible broader term. this broader term will then link to an item Id and should appear below the item it links too..

example XML below:

<Item Id="49" ConceptId="49" Obsolete="false"
AddedinVersion="2.00" LastUpdatedInVersion="2.00"
AToZ="false" Category="true" Preffered="true">
<Name>Children looked after in care</Name>
<ScopeNotes>Information on children in care.</ScopeNotes>
<BroaderItem Id="35" ConceptId="35" Default="true">Children and families services</BroaderItem>
</Item>

<Item Id="50" ConceptId="50" Obsolete="false"
AddedinVersion="2.00" LastUpdatedInVersion="2.00"
AToZ="false" Category="true" Preffered="true">
<Name>Registration</Name>
<ScopeNotes>Consolidated listing of children looked after in care.</ScopeNotes>
<BroaderItem Id="49" ConceptId="49" Default="true">Children looked after in care</BroaderItem>
</Item>

<Item Id="51" ConceptId="51" Obsolete="false"
AddedinVersion="2.00" LastUpdatedInVersion="2.00"
AToZ="false" Category="true" Preffered="true">
<Name>Communications</Name>
<ScopeNotes>Communication on child services.</ScopeNotes>
<BroaderItem Id="50" ConceptId="35" Default="true">Children and families services</BroaderItem>
</Item>

Should appear as:

Children looked after in care
----Registration
--------Communications

Thanks in advance
If anyone is able to assist.

Postnext
Ivan PedruzziSubject: LGCL XSLT transformation
Author: Ivan Pedruzzi
Date: 03 Oct 2006 05:49 PM
In XSLT you can define keys based on a XPath expression to group your data, see http://www.w3.org/TR/xslt#key

Have a look to the Jeni's grouping tutorials
http://www.jenitennison.com/xslt/grouping/index.xml

Ivan Pedruzzi
Stylus Studio Team
http://www.stylusstudio.com/xml_download.html

Posttop
James DurningSubject: LGCL XSLT transformation
Author: James Durning
Date: 05 Oct 2006 06:06 PM
http://www.experts-exchange.com/Web/Web_Languages/XML/Q_21780401.html
My assumption in this is that the root elements are the ones without any broader items. If I'm wrong, please correct me.

I believe the key parts are:
1. First apply-templates to all the main ControlledList elements. that is, the ones without a BroaderItem.
2. Then recursively apply templates to all of those.

This is how the base of it might look.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:esd="http://www.esd.org.uk/standards" exclude-result-prefixes="esd" version="2.0">
<xsl:key name="broads" match="esd:Item" use="esd:BroaderItem/@Id"/>

<!-- base template -->
<xsl:template match="/esd:ControlledList">
<xsl:apply-templates select="esd:Item[not(esd:BroaderItem)]"/>
</xsl:variable>
</xsl:template>

<!-- Recursive template -->
<xsl:template match="esd:Item">
<Item>
<xsl:copy-of select="@Id"/>
<xsl:apply-templates select="key('broads', $Id)"/>
</Item>
</xsl:template>
</xsl:stylesheet>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.