|
Subject: RE: [xsl] XSLT grouping(?) issue From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 22 Dec 2008 10:52:53 -0000 |
In XSLT 2.0, use
<xsl:for-each-group group-starting-with="StartOrderGroup">
<xsl:variable name="start"
select="current-group()[self::StartOrderGroup]"/>
<xsl:variable name="end" select="current-group()[self::EndOrderGroup]"/>
<xsl:variable name="group" select="current-group()[. >> $start and . <<
$end]
<order>
<xsl:for-each-select="$group">
<xsl:value-of select="name()"/> - <xsl:value-of select="Id"/>
</xsl:for-each>
</order>
</xsl:for-each-group>
plus some formatting as required.
For a 1.0 solution, use sibling recursion, which is a but more difficult.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Fredde Hedberg [mailto:syte_orion@xxxxxxxxx]
> Sent: 22 December 2008 10:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] XSLT grouping(?) issue
>
> > 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
>
>
> ___________________________________________________
> Svk efter kdrleken!
> Hitta din tvillingsjdl pe Yahoo! Dejting:
> http://ad.doubleclick.net/clk;185753627;24584539;x?http://se.m
> eetic.yahoo.net/index.php?mtcmk=148783
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSLT grouping(?) issue, Fredde Hedberg | Thread | Re: [xsl] XSLT grouping(?) issue, Mukul Gandhi |
| Re: [xsl] XSLT grouping(?) issue, Fredde Hedberg | Date | Re: [xsl] XSLT grouping(?) issue, Mukul Gandhi |
| Month |