[xsl] Problem with a for-each in xsl:variable

Subject: [xsl] Problem with a for-each in xsl:variable
From: "Huditsch Roman" <Roman.Huditsch@xxxxxxxxxxxxx>
Date: Tue, 19 Oct 2004 16:51:10 +0200
Hi,

I need to split up value ranges like "14-24" with the help of an xslt
stylesheet. The difficulty doing this task is, that these ranges can also look
like "13 13a 13b 14 15 15a 16..."

I can just find out the exact items of this range by parsing the doc tree.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="split_ranges.xslt"?>
<norm id="abgb" xmlns="http://myNamespace/schema/norm";>
	<normtext>
		<stichworte>
			<stichwort xmlns="">
				<term>Abgerissenes Land</term>
				<nummer>412-419</nummer>
			</stichwort>
			<stichwort xmlns="">
				<term>Abhandlung der Erbschaft</term>
				<nummer>797-824</nummer>
			</stichwort>
		<stichworte>
		<sektion id="N11990">
			<titel>Kundmachung des allgemeinen b|rgerlichen Gesetzbuches</titel>
			<jur_block id="N11994">
				<zaehlung zaehlungsart="Paragraf">412</zaehlung>
				<absatz>Aus der Betrachtung</absatz>
			</jur_block>
			<jur_block id="N11998">
				<zaehlung zaehlungsart="Paragraf">412a</zaehlung>
				<absatz>Der wdhrend Unserer Regierung </absatz>
			</jur_block>
			<jur_block id="N1199C">
				<zaehlung zaehlungsart="Paragraf">412b</zaehlung>
				<absatz>Nachdem auf solche Art</absatz>
			</jur_block>
			<jur_block id="N119A0">
				<zaehlung zaehlungsart="Paragraf">413</zaehlung>
				<absatz>Dadurch wird das bis jetzt an</absatz>
			</jur_block>
	...


I tried this stylesheet:


<?xml version="1.0" encoding="UTF-8"?>
<!--
Creator:	Huditsch Roman, Mag.(FH)
Date:		2004-10-14
Version:	00.90
Changes to prior version: -
Description: This XSLT Stylesheet is intended to splitt all value ranges
within <nummer> elements
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:ln="http://www.lexisnexis.at/schema/norm"; exclude-result-prefixes="ln
common" xmlns:common="http://exslt.org/common";>
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<!-- Every node within the source document is copied to the result file -->
	<xsl:template match="node()| @*">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="nummer[contains(., '-')]">
		<xsl:param name="n" select="number(substring-after(. , '-') -
substring-before(. , '-'))"/>
		<xsl:variable name="start" select="substring-before(. , '-')"/>
		<xsl:variable name="end" select="substring-after(. , '-')"/>
		<xsl:variable name="sum" select="$n + $start"/>
		<!-- This variable should contain <lit>a</lit><lit>b</lit>.. -->
		<xsl:variable name="lit">
			<xsl:for-each select="//ln:jur_block[preceding-sibling::ln:jur_block[.
=$sum]]/ln:zaehlung[@zaehlungsart='Paragraf' and contains(., $sum)]">
				<xsl:if test="number(substring-after(. , $sum))='NaN'">
					<lit>
						<xsl:value-of select="."/>
					</lit>
				</xsl:if>
			</xsl:for-each>
		</xsl:variable>
		<nummer>
			<xsl:value-of select="$start + $n"/>
		</nummer>
		<xsl:for-each select="common:node-set($lit)/*">
			<nummer>
				<xsl:value-of select="$start + $n"/>
				<xsl:value-of select="."/>
			</nummer>
		</xsl:for-each>
		<xsl:if test="$n >= 1">
			<xsl:apply-templates select=".">
				<xsl:with-param name="n" select="$n - 1"/>
			</xsl:apply-templates>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

I suppose there is a problem with my for-each, since all works fine, when I
fill my variable manually with <lit>a</lit><lit>b</lit>


But unfortunately it doesn't work out...
My instant saxon 6.5.2 is transforming and transforming and transforming...

How can I solve this problem?

Thank you very much for your help!

Wbr,
Roman


_______________________________________

Mag.(FH) Roman Huditsch
IT und Electronic Publishing
LexisNexis Verlag ARD ORAC GmbH & Co KG
Marxergasse 25
A-1030 Wien
Tel. +43-1-534 52-1514, Fax +43-1-534 52-148
roman.huditsch@xxxxxxxxxxxxx


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

Current Thread