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

position() problem

Subject: position() problem
From: Maik Stührenberg <maik.stuehrenberg@xxxxxxxxxxxxxxxx>
Date: Tue, 11 Jul 2006 15:14:46 +0200
select position
Hello list,

I have a problem with position(). I know that its value is the position
of the context node. I need a way to get a position of a
following-sibling node and want to compute its distance form the context
Here's an example:

<sentence id="w441">
<token text="Schlie_lich" pos="N" id="w442">Schlie_lich</token>
<token text="werden" pos="V" id="w443">werden</token>
<token text="in" pos="PREP" id="w444">in</token>
<token text="Punkt" pos="N" id="w445">Punkt</token>
<token text="4" pos="NUM" id="w446">4</token>
<token text="einzelne" pos="A" id="w447">einzelne</token>
<token text="lexikalische" pos="A" id="w448">lexikalische</token>
<token text="," id="w449">,</token>
<token text="syntaktische" pos="A" id="w450">syntaktische</token>
<token text="und" pos="CC" id="w451">und</token>
<token text="prosodische" pos="A" id="w452">prosodische</token>
<token text="Mittel" pos="N" id="w453">Mittel</token>
<token text="genannt" pos="V" id="w454">genannt</token>
<token text="," id="w455">,</token>
<token text="die" pos="PRON" id="w456">die</token>
<token text="zu" pos="PREP" id="w457">zu</token>
<token text="r" pos="DET" id="w458">r</token>
<token text="Bestimmung" pos="N" id="w459">Bestimmung</token>
<token text="der" pos="DET" id="w460">der</token>
<token text="jeweiligen" pos="A" id="w461">jeweiligen</token>
<token text="Lesart" pos="N" id="w462">Lesart</token>
<token text="beitragen" pos="V" id="w463">beitragen</token>
<token text="." id="w464">.</token>

What I want is to select all token elements with the attribute/value
pair pos='N'. Having selected a token/@pos='N' I'd like to select its
following sibling token/@pos='N' if and only if it is in a specified
distance (e.g., 5 tokens away).
If both tokens are in the specified distance all tokens should be
displayed (starting from N1 up to N2 with all other tokens between them).

I've tried several different attempts but didn't managed to get the
value of the position of the current node (N1) and its following sibling
node to check if they are in the right distance. So all I have is a
template which displays all tokens (the special ones in bold).

Any help would be appreciated.

Thanks in advance,

Maik St|hrenberg

<xsl:template match="sentence">
  <xsl:text>sentence: </xsl:text>
  <xsl:value-of select="@id" />
 <br />
  <xsl:when test="count(token[@pos='N'])>1">
   <xsl:for-each select="token">
     <xsl:when test="@pos='N'">
       <xsl:value-of select="@text" />
       <span style="font-size: x-small">
       <xsl:text> (</xsl:text>
       <xsl:value-of select="@id" />
       <xsl:text>) [</xsl:text>
       <xsl:value-of select="position()" />
       <xsl:text>] </xsl:text>
      <xsl:value-of select="@text" />
      <span style="font-size: x-small">
      <xsl:text> (</xsl:text>
      <xsl:value-of select="@id" />
      <xsl:text>) [</xsl:text>
      <xsl:value-of select="position()" />
      <xsl:text>] </xsl:text>
   <xsl:text>only one token with pos='N'</xsl:text>

Current Thread


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.
First Name
Last Name
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.