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

RE: get the first of the following with Attribute equ

Subject: RE: get the first of the following with Attribute equals
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 4 Feb 2003 17:32:12 -0000
xslt get element
The trick here is 

following-sibling::paragraphe[generate-id(preceding-sibling::title[1]) =
generate-id(current())]

That is, select those following paragraphs whose immediately preceding
title is the node you are currently at.

In XSLT 2.0 you can use

<xsl:for-each-group select="*" 
              group-starting-with="title">

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Cedric Claus
> Sent: 04 February 2003 15:57
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  get the first of the following with Attribute equals
> 
> 
> Hi, I have the following XML:
> 
> <document xmlns:fo="http://www.w3.org/1999/XSL/Format">
>    <elements>
>        <element type="title" position="1">text1</element>
>        <element type="paragraphe" position="2">text2</element>
>        <element type="paragraphe" position="3">text3</element>
>        <element type="title" position="4">text4</element>
>        <element type="paragraphe" position="5">text5</element>
>        <element type="paragraphe" position="6">text6</element>
>        <element type="title" position="7">text7</element>
>        <element type="paragraphe" position="9">text9</element>
>        <element type="paragraphe" position="10">text10</element>
>        <element type="title" position="11">text11</element>
>        <element type="paragraphe" position="12">text12</element>
>        <element type="paragraphe" position="13">text13</element>
>    </elements>
> </document>
> 
> ---------------XSL--------------
> 
> xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
>    <xsl:template match="/">
>        <document>
>            <xsl:apply-templates/>
>        </document>
>    </xsl:template>
>    <xsl:template match="document/elements/element">
> 
>        <xsl:if test="./@type='title'">
>            <element>
>                <group>
>                    <title>
>                        <xsl:value-of select="."/>
>                    </title>
>                                      <xsl:for-each 
> select="following::element[@type='paragraphe']">
>                                  <xsl:if test="./@position &lt; 
> following::element [@type='title']/@position">
>                            <paragraphe>
>                                <xsl:value-of select="."/>
>                            </paragraphe>
>                        </xsl:if>
>                    </xsl:for-each>
>                    <xsl:if 
> test="not(following-sibling::element[@type='title'])">
>                        <xsl:for-each 
> select="following::element[@type='paragraphe']">
>                            <paragraphe>
>                                <xsl:value-of select="."/>
>                            </paragraphe>
>                        </xsl:for-each>
>                    </xsl:if>
>                </group>
>            </element>
>        </xsl:if>
>    </xsl:template>
> </xsl:stylesheet>
> 
> I want to have only the *first *following with the attribute 
> Type = title or with my test : <xsl:if test="./@position &lt; 
> following::element 
> [@type='title']/@position"> I have : <document 
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
>    <element>
>        <group>
>            <title>text1</title>
>            <paragraphe>text2</paragraphe>
>            <paragraphe>text3</paragraphe>
>            <paragraphe>text5</paragraphe>
>            <paragraphe>text6</paragraphe>
>            <paragraphe>text9</paragraphe>
>            <paragraphe>text10</paragraphe>
>        </group>
>    </element>
>    ...
> What I want is only text2 and text 3, I don't want text5 --> 
> text10 with 
> this title
> 
> Any Idea? I become nuts....
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


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.