|
Subject: Re: [xsl] Building a tree from path-like strings From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 03 Jan 2009 14:11:15 -0500 |
Hi there,
I'm trying to make a tree-hierarchic document from a flat list of elements which have id-like values which define the hierarchy I need.
So here is simplified version of the source document: ... which should become this after transformation: ... <li id="FOO/2"> FOO/3 </li>
So far I have the following: ... This attempt at a solution is not only protracted and incomprehensible, it doesn't actually work either.
Can anyone think of a solution to this? Preferably disregarding my existing attempt.
T:\ftemp>type richard.xml
<btc>
<record table="works">
<record table="external_records">
<field name="external_id"><value>FOO/1</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/1/1</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/1/2</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/2</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/2/1</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/2/1/1</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/2/1/2</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/2/2</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
<record table="external_records">
<field name="external_id"><value>FOO/3</value></field>
<field name="ds_name"><value>ms-sources</value></field>
</record>
</record>
</btc>T:\ftemp>type richard.out
<?xml version="1.0" encoding="utf-8"?>
<ol>
<li id="FOO/1">FOO/1<ol>
<li id="FOO/1/1">FOO/1/1</li>
<li id="FOO/1/2">FOO/1/2</li>
</ol>
</li>
<li id="FOO/2">FOO/2<ol>
<li id="FOO/2/1">FOO/2/1<ol>
<li id="FOO/2/1/1">FOO/2/1/1</li>
<li id="FOO/2/1/2">FOO/2/1/2</li>
</ol>
</li>
<li id="FOO/2/2">FOO/2/2</li>
</ol>
</li>
<li id="FOO/3">FOO/3</li>
</ol>
T:\ftemp>type richard.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="/">
<xsl:call-template name="recurse-this">
<xsl:with-param name="records" select="btc/record/record"/>
</xsl:call-template>
</xsl:template>
-- Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes: : Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Building a tree from path-lik, Richard Lewis | Thread | Re: [xsl] Building a tree from path, Richard Lewis |
| [xsl] Building a tree from path-lik, Richard Lewis | Date | Re: [xsl] xml cells transformed in , Brendan Sleight |
| Month |