This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
merge tree structure with no redundancy
- From: Benoit Guyon <ben at dataset dot fr>
- To: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Date: Fri, 2 Aug 2002 17:42:50 +0200
- Subject: [xsl] merge tree structure with no redundancy
- Reply-to: xsl-list at lists dot mulberrytech dot com
hello,
I have a XML file with nodes that are representing a tree structure. i want
to modify this file (with a XSL stylesheet) to get a new XML file with a
unified tree structure that don't have redundancy.
the original file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<subscribers>
<subscriber>
<id="1" />
<path>
<node type="T1" name="N1">
<node type="T2" name="N2">
<node type="T3" name="N3" />
</node>
</node>
</path>
</subscriber>
<subscriber>
<id="2" />
<path>
<node type="T1" name="N1">
<node type="T2" name="N2">
<node type="T3" name="N4" />
</node>
</node>
</path>
</subscriber>
</subscribers>
</a>
the wanted file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<node type="T1" name="N1">
<node type="T2" name="N2">
<node type="T3" name="N3" id="1" />
<node type="T3" name="N4" id="2" />
</node>
</node>
</a>
I don't know how to make that ... can i test output to detect if a node
(identified with type and name atributes) is
already present ?
when i'm in the second <subscriber> node, how can i detect that i already
wrote the ancestor nodes, and how can i write the final node under the right
ancestor ?
does anybody have an idea or a general algorithm to help me ?
best regards
ben
PS : i use MSXML, i don't have the saxon:path() :/ ;)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list