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)
-> + How to sum the values (2)
-> + Grouping nodes between like no... (3)
-> - Group and display the min valu... (1)
-> - Creating a XML document with n... (4)
-> ->Creating a XML document w...
-> ->Creating a XML document w...
-> ->Creating a XML document w...
-> + Remove duplicates - different ... (2)
-> + Remove duplicates in a list - ... (3)
-> + Sort before paging (4)
-> + Min template (11)
-> + Recursion Help (2)
-> + Help needed with XSLT / XPATH (4)
-> + Axis (6)
-> + Carriage return / line feed (4)
-> + Adding a level with repeating ... (2)
-> + Group by function (2)
-> + xsl variable problems (simple) (10)
-> + XSLT Conditional Statements (2)
-> + XPST0003: XPath syntax error (3)
-> - myspace (1)
-> + XSLT to XML: Urgent Help Neede... (7)
-> + hyperlink in xslt (2)
-- Previous [1381-1400] [1401-1420] [1421-1440] 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.