ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
[xsl] XPath problem: Checking if imidiately preceding sibling is of a certain kind
by Ragulf Pickaxe other posts by this author
Feb 27 2004 9:37AM messages near this date
RE: RE: [xsl] Re: Network diagram - node set intersection | [xsl] What is the future of XSL-FO
Hi all,

What I want achieved is the following:

With the following XML:

<root> 
  <X> <A a="1"/><A a="1"/><A a="2"/>Some text</X>
  <X> <A a="4"/>Some text<br/>
        <A a="5"/> More text<br/>
        <A a="7"/> Even more text</X>
</root> 

I want to group the A nodes that are next to each other, but not those that 
are not next to each other, all the while keeping the structure of the 
original document.

In the XSL document, which has some template much like this

<xsl:template match="/"> 
  <xsl:apply-templates select="*"/> 
</

I have tried the following:

<xsl:template match="A[1]"> 
<!-- This groups all the A elements in a given X element
This means that the second X gets the grouped too much --> 
</

Or:

<xsl:template match="A"> 
<!-- This one does not group any of them --> 
</


In the second implementation I have the tried a choose, when, otherwise to 
get the grouping.

What I want to achieve is (in pseudocode):

<xsl:choose> 
  <xsl:when test="not('The preceding sibling is an A node')"/> 
    <!-- Do something --> 
  </
  <xsl:otherwise> 
    <!-- At the moment do nothing --> 
  </
</

I have tried to look at the name() function, but I don't think I understand 
it correctly
test="not(preceding-sibling::*[1]/name()='A'" goes totally wrong.

I think it must be really simple, but I can't get my mind to work, it seems.

Any help will be greatly appreciated.

If anyone has a different approach, I will be grateful, but please bear in 
mind this is but an example.

Regards,
Ragulf Pickaxe :)

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved