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

Re: grouping after a group using 1.0

Subject: Re: grouping after a group using 1.0
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 Nov 2008 11:03:47 -0500
Re:  grouping after a group using 1.0
At 2008-11-21 10:23 -0500, Friend, Darris E wrote:
I tried to use the example. I was confused on how to alter the syntax
for the  example's
<xsl:if test="generate-id(.)=generate-id($games[game=current()/game])">
to my needs.

Yes, I can understand that might be confusing. Thankfully it is quite straightforward once you recognize the design pattern.

My XML seems more complicated, sorry I don't know the terms to describe
the format of my XML data.

Posting the documents made things very obvious ... thank you for doing so. It was quick to come up with a solution.

I posted my XML and XSL on to Google Documents for anyone to review if
they desire to help with my problem (which is a lack of understanding
XML/XSL). I am reading websites and books to help with the knowledge,
however this is a solution I need sooner rather than later.

The XML http://docs.google.com/Doc?id=dc7n2j2g_10fcjnwhgr
The XSL http://docs.google.com/Doc?id=dc7n2j2g_11c6xh6dcr

You'll find below a complete grouping solution (in text, not HTML) that I think meets your requirements.

I hope this helps and reveals the benefits of variable-based grouping, which I teach for sub-document and multiple-document uses when using XSLT 1.0. Of course if you could move to XSLT 2.0 things would be a *lot* easier.

. . . . . . . . . . . Ken

p.s. I'm teaching XSLT in Prague March 16-20, 2009 ... a full five-day hands-on class covering every element, every attribute and every function of both XSLT 1.0 and XSLT 2.0, and in that I cover three kinds of XSLT 1.0 grouping: axis-based, variable-based and key-based, and when to choose which to use.

T:\ftemp>call xslt darris.xml darris2.xsl darris.txt

T:\ftemp>type darris.txt

Connection object ID: 8221
  Premise ID: 74250
    Install number and type: 52120,WATR
    Install number and type: 52126,WSTU
    Install number and type: 512129,ELEC
  Premise ID: 742580
    Install number and type: 52125,NTGS
Connection object ID: 8228
  Premise ID: 74258
    Install number and type: 52124,WSTU
    Install number and type: 52127,WATR
    Install number and type: 52121,ELEC
T:\ftemp>type darris2.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<xsl:output method="text"/>

<xsl:template match="/">
<xsl:variable name="objects" select="//ObjectClassRow"/>
<!--work with all connections-->
<xsl:for-each select="$objects">
<xsl:if test="generate-id(.)=
generate-id($objects[ObjectClassField[@name='SAP ConnectionObject ID']=
current()/ObjectClassField[@name='SAP ConnectionObject ID']][1])">
Connection object ID: <xsl:value-of
select="ObjectClassField[@name='SAP ConnectionObject ID']"/>
<!--now work with only the subset of connections-->
<xsl:variable name="premises"
select="$objects[ObjectClassField[@name='SAP ConnectionObject ID']=
current()/ObjectClassField[@name='SAP ConnectionObject ID']]"/>
<xsl:for-each select="$premises">
<xsl:if test="generate-id(.)=
generate-id($premises[ObjectClassField[@name='SAP Premise ID']=
current()/ObjectClassField[@name='SAP Premise ID']][1])">
Premise ID: <xsl:value-of select="ObjectClassField[@name='SAP Premise ID']"/>
select="$premises[ObjectClassField[@name='SAP Premise ID']=
current()/ObjectClassField[@name='SAP Premise ID']]">
Install number and type: <xsl:value-of
select="concat(ObjectClassField[@name='SAP Install Number'],',',
ObjectClassField[@name='SAP Install Type'])"/>


T:\ftemp>type darris.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='C:\GISData\MobileConfiguration\SAPConnectionIDatGAP.xsl'?>
<ReportObject name="SAPConnectionIDatGAP">
<ObjectClass name="GRU Address Points">
<ObjectClassFieldDefinition />
<ObjectClassRow OBJECTID="30582" />
<ObjectClassRow OBJECTID="30583" />
<ObjectClass name="SAP_INSTALLATION">
<FieldDefinition>SAP ConnectionObject ID</FieldDefinition>
<FieldDefinition>SAP Premise ID</FieldDefinition>
<FieldDefinition>SAP Install Number</FieldDefinition>
<FieldDefinition>SAP Install Type</FieldDefinition>
<ObjectClassRow OBJECTID="120552">
<ObjectClassField name="SAP ConnectionObject ID">8221</ObjectClassField>
<ObjectClassField name="SAP Premise ID">74250</ObjectClassField>
<ObjectClassField name="SAP Install Number">52120</ObjectClassField>
<ObjectClassField name="SAP Install Type">WATR</ObjectClassField>
<ObjectClassRow OBJECTID="120481">
<ObjectClassField name="SAP ConnectionObject ID">8221</ObjectClassField>
<ObjectClassField name="SAP Premise ID">742580</ObjectClassField>
<ObjectClassField name="SAP Install Number">52125</ObjectClassField>
<ObjectClassField name="SAP Install Type">NTGS</ObjectClassField>
<ObjectClassRow OBJECTID="120558">
<ObjectClassField name="SAP ConnectionObject ID">8221</ObjectClassField>
<ObjectClassField name="SAP Premise ID">74250</ObjectClassField>
<ObjectClassField name="SAP Install Number">52126</ObjectClassField>
<ObjectClassField name="SAP Install Type">WSTU</ObjectClassField>
<ObjectClassRow OBJECTID="120475">
<ObjectClassField name="SAP ConnectionObject ID">8221</ObjectClassField>
<ObjectClassField name="SAP Premise ID">74250</ObjectClassField>
<ObjectClassField name="SAP Install Number">512129</ObjectClassField>
<ObjectClassField name="SAP Install Type">ELEC</ObjectClassField>
<ObjectClassRow OBJECTID="120643">
<ObjectClassField name="SAP ConnectionObject ID">8228</ObjectClassField>
<ObjectClassField name="SAP Premise ID">74258</ObjectClassField>
<ObjectClassField name="SAP Install Number">52124</ObjectClassField>
<ObjectClassField name="SAP Install Type">WSTU</ObjectClassField>
<ObjectClassRow OBJECTID="120569">
<ObjectClassField name="SAP ConnectionObject ID">8228</ObjectClassField>
<ObjectClassField name="SAP Premise ID">74258</ObjectClassField>
<ObjectClassField name="SAP Install Number">52127</ObjectClassField>
<ObjectClassField name="SAP Install Type">WATR</ObjectClassField>
<ObjectClassRow OBJECTID="120563">
<ObjectClassField name="SAP ConnectionObject ID">8228</ObjectClassField>
<ObjectClassField name="SAP Premise ID">74258</ObjectClassField>
<ObjectClassField name="SAP Install Number">52121</ObjectClassField>
<ObjectClassField name="SAP Install Type">ELEC</ObjectClassField>

T:\ftemp>rem Done!

Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes:
:  Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg
Video course overview:  http://www.youtube.com/watch?v=VTiodiij6gE
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread


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.
First Name
Last Name
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.