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)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Glenn MeadowsSubject: Creating a XML document with nested nodes
Author: Glenn Meadows
Date: 25 Aug 2006 05:25 PM
Hello,

Using XSLT and the mapper utility with Stylus Studio, I have created a XML document with a list of 2 fields being TASK_NAME and TASK_OUTLINE_LEVEL. The TASK_NAME is just that, the description of a task. The TASK_OUTLINE_LEVEL indicates the hierarchy of each task in a tree structure with 0 being the top-most node and 1, 2, 3, etc. being nodes further inside the tree.

I have attached a source XML file and the XSLT file that renders output to a target XML file.

I am doing a eval of SS and so I am new at all this. Could someone tell me if this is achievable?

Thanks,
- Glenn


Unknowntasklist.xsl
XSLT document to render XML target file

Postnext
Glenn MeadowsSubject: Creating a XML document with nested nodes
Author: Glenn Meadows
Date: 28 Aug 2006 04:44 PM
My XML file did not get attached to the first message, so here it is.


Unknowntasklist.xml
XML file

Postnext
Glenn MeadowsSubject: Creating a XML document with nested nodes
Author: Glenn Meadows
Date: 28 Aug 2006 04:58 PM
Thought I might add some additional clarity as to what I am looking for.

A target XML file with a tree structure defined as follows;

<node1>Summary Task
<node2>task1</node2>
<node3>task2
<node4>task3</node4>
<node5>task4</node5>
</node3>
<node6>task5</node6>
</node1>

which would allow a tree control to be populated with this tree structure;

Summary Task
task1
task2
task3
task4
task5

Posttop
Minollo I.Subject: Creating a XML document with nested nodes
Author: Minollo I.
Date: 29 Aug 2006 09:54 AM
Glenn,
you can try code similar to the following; I'm assuming that the position of the nodes in the document is what is determinint the parent/child relationship, as long as the outline-level data.

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<xsl:for-each select="dataroot/MSP_TASKS[not(TASK_OUTLINE_LEVEL)]">
<!-- what to do with tasks with no outline level (and no name)? -->
</xsl:for-each>
<xsl:for-each select="dataroot/MSP_TASKS">
<xsl:if test="TASK_OUTLINE_LEVEL=1">
<node name="{TASK_NAME}">
<xsl:call-template name="getChildren">
<xsl:with-param name="level" select="2"/>
<xsl:with-param name="fromPosition" select="position()+1"/>
</xsl:call-template>
</node>
</xsl:if>
</xsl:for-each>
</dataroot>
</xsl:template>

<xsl:template name="getChildren">
<xsl:param name="level"/>
<xsl:param name="fromPosition"/>
<xsl:choose>
<xsl:when test="/dataroot/MSP_TASKS[$fromPosition]/TASK_OUTLINE_LEVEL = $level">
<node name="{/dataroot/MSP_TASKS[$fromPosition]/TASK_NAME}">
<xsl:call-template name="getChildren">
<xsl:with-param name="level" select="$level+1"/>
<xsl:with-param name="fromPosition" select="$fromPosition+1"/>
</xsl:call-template>
</node>
<xsl:call-template name="getChildren">
<xsl:with-param name="level" select="$level"/>
<xsl:with-param name="fromPosition" select="$fromPosition+1"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="/dataroot/MSP_TASKS[$fromPosition]/TASK_OUTLINE_LEVEL > $level">
<xsl:call-template name="getChildren">
<xsl:with-param name="level" select="$level"/>
<xsl:with-param name="fromPosition" select="$fromPosition+1"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</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.