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

Re: XSL:FO - How to group on a preceeding-sibling valu

Subject: Re: XSL:FO - How to group on a preceeding-sibling value
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 24 Jan 2012 15:39:56 -0500
Re:  XSL:FO - How to group on a preceeding-sibling valu
Hi Chris,

If using XSLT 2.0 (and why not?), you should look up xsl:for-each-group, which as the name implies is designed to support grouping.

If you are using XSLT 1.0 and don't have this option, there are several others, all of which share a single characteristic: they are less graceful than xsl:for-each-group.

The method you are attempting might be one of them, except for one thing. XPath ($nodesetA != $nodesetB) returns true if any member of $nodesetA is unequal to any member of $nodesetB.

You want not(mainGroupCodes = preceding-sibling::*/mainGroupCodes), which returns false as long as the value of mainGroupCodes is equal to the value of any of preceding-sibling::*/mainGroupCodes.

There is a subtle but important difference there.

Cheers,
Wendell

On 1/24/2012 10:17 AM, Chris Booth wrote:
Hi,

I am after a litte bit guidance and help please.

Using XSL:FO I need to be able to group parts of my data together.

From the XML below, I am looking for a way where I loop over Lines/Line and based on the value in LineGroup/GroupCode, if it's the first occurance then display the GroupDescription.

I am trying all sorts of variations on the below but with no joy- <xsl:if test="mainGroupCodes != preceding-sibling::*/mainGroupCodes"> DISPLAY GROUP DESC </xsl:if>

REQUIRED OUTPUT:
Main Group One
	LINE DATA
	LINE DATA


Main Group Three LINE DATA LINE DATA

Sub Group 1
	LINE DATA
	LINE DATA

SAMPLE XML:
<Lines Type="Quote">
	<Line Type="Quote">
		<DocumentLine>1.00</DocumentLine>
		<LineGroup>14.00</LineGroup>
		<LineDisplaySequence>1</LineDisplaySequence>
		<mainGroupCodes>1</mainGroupCodes>
		<LineGroup>
			<GroupId>14.00</GroupId>
			<GroupCode>1</GroupCode>
			<GroupDescription>Main Group One</GroupDescription>
			<FloorGroup>1</FloorGroup>
			<CeilingGroup>2</CeilingGroup>
			<SubGroupLineValueTotal>8000.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>8000.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>31.00</DocumentLine>
		<LineGroup>16.00</LineGroup>
		<LineDisplaySequence>10</LineDisplaySequence>
		<mainGroupCodes>3</mainGroupCodes>
		<LineGroup>
			<GroupId>16.00</GroupId>
			<GroupCode>3</GroupCode>
			<GroupDescription>Main Group Three</GroupDescription>
			<FloorGroup>3</FloorGroup>
			<CeilingGroup>4</CeilingGroup>
			<SubGroupLineValueTotal>518.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>3806.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>2.00</DocumentLine>
		<LineGroup>16.00</LineGroup>
		<LineDisplaySequence>11</LineDisplaySequence>
		<mainGroupCodes>3</mainGroupCodes>
		<LineGroup>
			<GroupId>16.00</GroupId>
			<GroupCode>3</GroupCode>
			<GroupDescription>Main Group Three</GroupDescription>
			<FloorGroup>3</FloorGroup>
			<CeilingGroup>4</CeilingGroup>
			<SubGroupLineValueTotal>518.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>3806.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>13.00</DocumentLine>
		<LineGroup>19.00</LineGroup>
		<LineDisplaySequence>12</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>19.00</GroupId>
			<GroupCode>4.1</GroupCode>
			<GroupDescription>Sub group 1</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>4960.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>14.00</DocumentLine>
		<LineGroup>19.00</LineGroup>
		<LineDisplaySequence>13</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>19.00</GroupId>
			<GroupCode>4.1</GroupCode>
			<GroupDescription>Sub group 1</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>4960.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>15.00</DocumentLine>
		<LineGroup>19.00</LineGroup>
		<LineDisplaySequence>14</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>19.00</GroupId>
			<GroupCode>4.1</GroupCode>
			<GroupDescription>Sub group 1</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>4960.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>17.00</DocumentLine>
		<LineGroup>19.00</LineGroup>
		<LineDisplaySequence>15</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>19.00</GroupId>
			<GroupCode>4.1</GroupCode>
			<GroupDescription>Sub group 1</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>4960.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>23.00</DocumentLine>
		<LineGroup>19.00</LineGroup>
		<LineDisplaySequence>16</LineDisplaySequence>
		<OriginalOrderLine>0.00</OriginalOrderLine>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>19.00</GroupId>
			<GroupCode>4.1</GroupCode>
			<GroupDescription>Sub group 1</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>4960.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>24.00</DocumentLine>
		<LineGroup>20.00</LineGroup>
		<LineDisplaySequence>17</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>20.00</GroupId>
			<GroupCode>4.2</GroupCode>
			<GroupDescription>Subgroup 2</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>0.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>25.00</DocumentLine>
		<LineGroup>20.00</LineGroup>
		<LineDisplaySequence>18</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>20.00</GroupId>
			<GroupCode>4.2</GroupCode>
			<GroupDescription>Subgroup 2</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>0.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>9.00</DocumentLine>
		<LineGroup>21.00</LineGroup>
		<LineDisplaySequence>19</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>21.00</GroupId>
			<GroupCode>4.3</GroupCode>
			<GroupDescription>Sub group 3</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>500.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>20.00</DocumentLine>
		<LineGroup>14.00</LineGroup>
		<LineDisplaySequence>2</LineDisplaySequence>
		<mainGroupCodes>1</mainGroupCodes>
		<LineGroup>
			<GroupId>14.00</GroupId>
			<GroupCode>1</GroupCode>
			<GroupDescription>Main Group One</GroupDescription>
			<FloorGroup>1</FloorGroup>
			<CeilingGroup>2</CeilingGroup>
			<SubGroupLineValueTotal>8000.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>8000.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
	<Line Type="Quote">
		<DocumentLine>8.00</DocumentLine>
		<LineGroup>18.00</LineGroup>
		<LineDisplaySequence>20</LineDisplaySequence>
		<mainGroupCodes>4</mainGroupCodes>
		<LineGroup>
			<GroupId>18.00</GroupId>
			<GroupCode>4</GroupCode>
			<GroupDescription>Main Group 4</GroupDescription>
			<FloorGroup>4</FloorGroup>
			<CeilingGroup>5</CeilingGroup>
			<SubGroupLineValueTotal>1574.00</SubGroupLineValueTotal>
			<AllGroupLineValueTotal>7034.00</AllGroupLineValueTotal>
		</LineGroup>
	</Line>
</Lines>

-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

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.