[xsl] Choosing the a specific following node

Subject: [xsl] Choosing the a specific following node
From: "Huditsch Roman" <Roman.Huditsch@xxxxxxxxxxxxx>
Date: Fri, 15 Oct 2004 13:10:37 +0200
Hi there,

I am trying to transform a keyword list at the moment, which is giving
me some troubles.
I have the following source doc:

<keywords>
	<keyword>
		<term>Aufbewahrung</term>
		<number>970-970c;</number>
		<term>s.</term>
		<term>also</term>
		<term>Einstweilige</term>
		<term>Verwahrung</term>
	</keyword>
	<keyword>
		<term>Auto</term>
		<number>10-13c;</number>
		<term>s.</term>
		<term>Kraftfahrzeug</term>
	</keyword>
	...
</keywords>

I'd like to get an output file like:

<keywords>
	...
	<keyword>
		<term>Aufbewahrung</term>
		<number>970-970c;</number>
		<see_also>Einstweilige Verwahrung</see_also>
	</keyword>
	<keyword>
		<term>Auto</term>
		<number>10-13c;</number>
		<see>Kraftfahrzeug</see>
	</keyword>
	...
</keywords>


I tried to achieve this via this template:

<xsl:template match="term[string(.)='s' or string(.)='s.']">
		<xsl:variable name="pos" select="position()+2"/>
		<xsl:choose>
			<xsl:when
test="following-sibling::term[string(.)='auch']">
				<siehe_auch>
					<xsl:for-each
select="following-sibling::term[position()>=$pos]">
						<xsl:value-of
select="text()"/>
						<xsl:if
test="position()!=last()">

<xsl:text>&#160;</xsl:text>
						</xsl:if>
					</xsl:for-each>
				</siehe_auch>
			</xsl:when>
			<xsl:otherwise>
				<siehe>
					<xsl:for-each
select="following-sibling::term">
						<xsl:value-of
select="text()"/>
						<xsl:if
test="position()!=last()">

<xsl:text>&#160;</xsl:text>
						</xsl:if>
					</xsl:for-each>
				</siehe>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

Unfortunately, I get an empty <see_also> element in my output.
I found a solution via outputting every node, which does not contain the
content "also", but this is a little bit dangerous....

Can you help me?

Wbr,
Roman


**********************************************************************
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