Subject: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
tasklist.xsl XSLT document to render XML target file
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>