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

Re: XSLT grouping(?) issue

Subject: Re: XSLT grouping(?) issue
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Mon, 22 Dec 2008 16:40:33 +0530
Re:  XSLT grouping(?) issue
Here is a different algorithm, than Mike

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

  <xsl:output method="text" />

  <xsl:template match="Orders">
    <xsl:for-each-group select="*" group-starting-with="StartOrderGroup">
      <xsl:text>&#xa;Order&#xa;</xsl:text>
      <xsl:text>-----&#xa;</xsl:text>
      <xsl:variable name="curr-group" select="current-group()" />
      <xsl:variable name="indx" select="index-of(for $x in $curr-group
return $x/local-name(), 'EndOrderGroup')" />
      <xsl:for-each select="$curr-group[position() &gt; 1 and
position() &lt; $indx]">
        <xsl:value-of select="local-name()" /> - <xsl:value-of
select="Id" /><xsl:text>&#xa;</xsl:text>
      </xsl:for-each>
    </xsl:for-each-group>
  </xsl:template>

</xsl:stylesheet>


On Mon, Dec 22, 2008 at 4:07 PM, Fredde Hedberg <syte_orion@xxxxxxxxx> wrote:
>> The problem is solvable with XSLT, provided your input XML
>> is well
>> formed. But your input is not a valid XML document.
>>
>> for e.g., <Id=1/> is not a valid XML fragment, and
>> XML parser
>> complains about it.
>
> My mistake, I apologize. When I simplified my XML I made it more bad formed than it really is...
>
> <Orders>
>  <StartOrderGroup>
>    <Id>1</Id>
>  </StartOrderGroup>
>  <Car>
>    <Id>2</Id>
>  </Car>
>  <Car>
>    <Id>3</Id>
>  </Car>
>  <Bus>
>    <Id>4</Id>
>  </Bus>
>  <EndOrderGroup>
>    <Id>5</Id>
>  </EndOrderGroup>
>  <Car>
>    <Id>6</Id>
>  </Car>
>  <Truck>
>    <Id>7</Id>
>  </Truck>
>  <StartOrderGroup>
>    <Id>8</Id>
>  </StartOrderGroup>
>  <Truck>
>    <Id>9</Id>
>  </Truck>
>  <EndOrderGroup>
>    <Id>10</Id>
>  </EndOrderGroup>
> </Orders>
>
> That's at least valid XML :)
> You've given me hope by saying it is solvable. Will this new XML-fragment allow you to show me how? That would basically save christmas for me...
>
> Regards
>
> Fredde



-- 
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.