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

SV: xsl-list Digest 14 Aug 2008 05:10:00 -0000 Issue 1

Subject: SV: xsl-list Digest 14 Aug 2008 05:10:00 -0000 Issue 1588
From: "Kjellaug Johansen" <kjellaug.johansen@xxxxx>
Date: Thu, 14 Aug 2008 10:20:33 +0200
 SV: xsl-list Digest 14 Aug 2008 05:10:00 -0000 Issue 1
Thanks, Mukul! It works great!

Kjellaug.

------------------------------

Below is the solution for this ...

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	       version="2.0">

  <xsl:output method="xml" indent="yes" />

  <xsl:template match="test">
    <result>
      <xsl:for-each-group select="*" group-starting-with="Pkt[@type =
'pkt']">
          <Pkt>
            <xsl:for-each select="current-group()">
              <A><xsl:value-of select="." /></A>
            </xsl:for-each>
          </Pkt>
      </xsl:for-each-group>
    </result>
  </xsl:template>

</xsl:stylesheet>

On 8/13/08, Kjellaug Johansen <kjellaug.johansen@xxxxx> wrote:
> Hi!
>
> I've got this source-XML:
>
> <test>
> <Pkt type="pkt">Text</Pkt>
> <Pkt type="uavs">Text 1</Pkt>
> <Pkt type="pkt">More text</Pkt>
> <Pkt type="uavs">More text 1</Pkt>
> <Pkt type="uavs">More text 2</Pkt>
> <Pkt type="pkt">Lot of text</Pkt>
> <Pkt type="pkt">Tons of text</Pkt>
> <Pkt type="uavs">Tons of text 1</Pkt>
> </test>
>
> When I reach a Pkt-element which does NOT have attribute type='uavs' I
should check if the next Pkt-sibling has attribute type='uavs'.
>
> If so, I want to loop through all the Pkt-elements with attribute
type='uavs' that appears right after the current element.
>
> When a new Pkt-element without the 'uavs' attribute value appears, the
loop is fininshed.
>
> I've tried something like this, but that only lists all the elements
with uavs-attribute one time:
>
> <xsl:if test="following-sibling::Pkt[1][@type='uavs'] ">
> <xsl:for-each select="following-sibling::Pkt[@type='uavs']
>
[preceding-sibling::*[1][self::Pkt]][generate-id(preceding-sibling::Pkt[
not(preceding-sibling::*[1][self::Pkt])][1]) = generate-id(current())]">
> <A><xsl:value-of select="."/></A>
>  </xsl:for-each>
> </xsl:if>
>
> My result-XML should look like this:
>
> <Pkt>
>             <A>Text</A>
>             <A>Text 1</A>
> </Pkt>
> <Pkt>
>             <A>More text</A>
>             <A>More text 1</A>
>             <A>More text 2</A>
> </Pkt>
> <Pkt>
>             <A>Lot of text</A>
> </Pkt>
> <Pkt>
>             <A>Tons of text</A>
>             <A>Tons of text 1</A>
> </Pkt>
>
> I use xsl 2.0.
>
> Thanx!!
>
> Kjellaug.

--
Regards,
Mukul Gandhi

------------------------------

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.