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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + sort by variable (11)
-> + [XSLT Recursive Template Help]... (2)
-> + Adding values with document() ... (7)
-> + merging xml files in to single... (2)
-> + Limit description characters i... (2)
-> + problem parsing xml as text in... (2)
-> + Summarize/Distinct (5)
-> + unix epoch seconds to date str... (3)
-> + xml, xslt question (5)
-> - LGCL XSLT transformation (3)
-> ->LGCL XSLT transformation
-> ->LGCL XSLT transformation
-> + Dynamic include (3)
-> + .rdbxml as XML within Stylus ... (3)
-> + Array of Values From XSL (2)
-> + Problem Saving output (2)
-> + Base 64 encoded data embedded ... (2)
-> + XML-XML Mapping (2)
-> - Parameterized 'Document()' ...... (1)
-> + Newbie prob - Elements with sa... (3)
-> - .net 1.1 incorrectly processin... (1)
-> + xs:key and xs:keyref question (5)
-> + pass xsl-variable to javascrip... (2)
-- Previous [1321-1340] [1341-1360] [1361-1380] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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>

   
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.