[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Choosing the a specific following node

Subject: Choosing the a specific following node
From: "Huditsch Roman" <Roman.Huditsch@xxxxxxxxxxxxx>
Date: Fri, 15 Oct 2004 13:10:37 +0200
xsl following node
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.