This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: XPath selection using //


I am a little unsure of what you are trying to do and your xml
sample is not well formed but here goes;

This template will produce the result you are after;

 <xsl:template match="m">
   Attribute a of the following m is: <xsl:value-of
select="following::m/@a"/>
 </xsl:template>

The 'following-sibling' axes will only match nodes of the same depth 
of the xml document. 

Cheers,
Ben


-----Original Message-----
From: Filipe Correia [mailto:filipe.correia@paradigmaxis.pt]
Sent: 17 July 2002 15:11
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] XPath selection using //



  Hi,

Here's a tree wich is a part of my xml document:

<b>
  <m a="attribute">
    text text text
    <t>
      <r>
        <d>more text</d>
      <r/>
    </t>
  </m>
  <t>
    <r>
      <d/>
      <d><m a="attribute">text</m></d>
    <r/>
  </t>
  <m/>
  text
</b>

what I want to do is to evaluate only the
contents of the "m" elements. For each "m"
element I also need to output the next "m"'s
"a" atribute.
Everything else should be ignored.

In the stylesheet that I use I'm applying the
respective templates like this:

   ...

   <xsl:apply-templates select="b//m"/>

   ...

 using the following template to apply
 templates to all descendants of the
 current "m" node and to get the next "m"'s
 "a" atribute:

   <xsl:template match="m">
	<xsl:apply-templates/>
      Atribute a of the following m is: 
      <xsl:value-of
select="ancestor::*[parent::b]/following-sibling::node()//m/@a"/>
   </xsl:template>

 but getting the next "m"'s "a" atribute is
 not working as I expected...

 Any idea on what I may be doing wrong?


     Thanks in advance,

       Filipe


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
=====================================================================
DISCLAIMER

1. The information contained in this E-mail is confidential. 
   It is intended only for the stated addressee(s) and access 
   to it by any other person is unauthorised. 
   If you are not an addressee, you must not disclose, copy, 
   circulate or in any other way use or rely on the information 
   contained in this E-mail. Such unauthorised use may be unlawful. 
   If you have received this E-mail in error, please inform us 
   immediately and delete it and all copies from your system.

2. The views expressed in this E-mail are those of the author, 
    and do not represent the views of AMT-Sybex Group Ltd., its 
    associates or subsidiaries, unless otherwise expressly indicated.
    In the avoidance of doubt, the insertion of the name of AMT-Sybex 
    Group Ltd., its associate or subsidiary under the name of the sender 
    may constitute an express indication that the views stated in the Mail 
    are those of the named company.
=====================================================================
For more information on the AMT Sybex group visit: http://www.amt-sybex.com 



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]