[xsl] Searching for the longest path in a tree

Subject: [xsl] Searching for the longest path in a tree
From: Norman Rosner <normanrosner@xxxxxx>
Date: Thu, 7 Apr 2005 18:32:40 +0200
Hi everyone,

i'm sure that theres help in the archive but i didn't find something that i can understand :)

Here's my XML-Document:

<?xml version="1.0" encoding="UTF-8"?>

<corpus>
	<phrase id="syntax_7"> <!-- Diskurs-Baum -->

		<phrase id="syntax_5"> <!-- Satz 1 -->
			<phrase id="syntax_1" cat="NP" func="PD" case="NOM">
				<tok id="tok_1" lemma="dies" pos="PDS">Dies</tok>
				<tok id="tok_2" lemma="sein" pos="VAFIN">ist</tok>
			</phrase>

			<phrase id="syntax_2" cat="NP" func="SB" case="NOM">
				<tok id="tok_3" lemma="eine" pos="ART">ein</tok>
				<tok id="tok_4" lemma="Beispielsatz" pos="NN">Beispielsatz</tok>
			</phrase>

			<tok id="tok_5" pos="$.">.</tok>
		</phrase>

		<phrase id="syntax_5"> <!-- Satz 2 -->
			<tok id="tok_6" lemma="und" pos="KON">Und</tok>
			<tok id="tok_7" lemma="hier" pos="ADV">hier</tok>
			<tok id="tok_8" lemma="folgen" pos="VVFIN">folgt</tok>

			<phrase id="syntax_3" cat="NP" func="IOBJ" case="DAT">
				<tok id="tok_9" lemma="er" pos="PPER">ihm</tok>
			</phrase>

			<tok id="tok_10" lemma="zum Beispiel" pos="ADV">z.B.</tok>
			<tok id="tok_11" lemma="noch" pos="ADV">noch</tok>

			<phrase id="syntax_4" cat="NP" func="SB" case="NOM">
				<tok id="tok_12" lemma="eine" pos="ART">ein</tok>
				<tok id="tok_13" lemma="weiter" pos="ADJA">weiterer</tok>
				<tok id="tok_14" lemma="Beispielsatz" pos="NN">Beispielsatz</tok>
			</phrase>

			<tok id="tok_15" pos="$.">.</tok>
		</phrase>
	</phrase>
</corpus>



and here's my XSL-File that i would like to apply to the above XML-Document.

The problem i have according to the xsl-file is that i want to have the maximal depth of the tree. In the example XML it is 4 i think.

Is there any simple Opportunity to find it out? I need ir because i want to transform the tree into a svg.

Thanks a lot

Norman

Current Thread