xsl-list
[Top] [All Lists]

RE: [xsl] Grouping using group-starting-with=

2006-09-07 10:13:57
The value of group-starting-with is a pattern that must match a node in the
population. Since the population consists of Item elements, none of them
match the pattern RepresentationTerm[.='Code']. Use

group-starting-with="Item[RepresentationTerm='Code']"

A bit of a gotcha - only this morning I found someone doing select="para"
group-by="para/title". Oh for a context-free language!

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: G. Ken Holman [mailto:gkholman(_at_)CraneSoftwrights(_dot_)com] 
Sent: 07 September 2006 17:37
To: XSL List
Subject: [xsl] Grouping using group-starting-with=

Hi folks,

I'm using Saxon 8.8J and I'm trying to group a bunch of 
sibling items into groups of items that start with the item 
that has a particular child with a particular value.

It would seem that the following does not work:

     <xsl:for-each-group select="/*/Item"
                         
group-starting-with="RepresentationTerm[.='Code']">

Looking at XSLT 2.0, group-starting-with= requires the 
population to all be nodes, and there are a number of nodes 
that match the pattern test supplied ... yet running the 
example I am only getting a single group ... which I suspect 
is just the first node in the population.

I'm missing something obvious ... could someone please point 
me to the correct chapter and verse?

I have my example below of test data and stylesheet ... my 
real data has much more information and more representation 
terms, but it should still be the same.

Thanks!

. . . . . . . . . . Ken


t:\ftemp>type test.xml
<?xml version="1.0" encoding="utf-8"?>
<Model file="UBL-qDT-2.0">
    <Item>
       <DictionaryEntryName>Allowance Charge Reason_ Code. 
Type</DictionaryEntryName>
       <RepresentationTerm>Code</RepresentationTerm>
    </Item>
    <Item>
       <DictionaryEntryName>Allowance Charge Reason_ Code. 
Content</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Allowance Charge Reason_ Code 
List. Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Allowance Charge Reason_ 
Language. Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Channel_ Code. Type</DictionaryEntryName>
       <RepresentationTerm>Code</RepresentationTerm>
    </Item>
    <Item>
       <DictionaryEntryName>Channel_ Code. 
Content</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Channel_ Code List. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Channel_ Language. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Chip_ Code. Type</DictionaryEntryName>
       <RepresentationTerm>Code</RepresentationTerm>
    </Item>
    <Item>
       <DictionaryEntryName>Chip_ Code. Content</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Chip_ Code List. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Chip_ Language. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Country
Identification_ Code. Type</DictionaryEntryName>
       <RepresentationTerm>Code</RepresentationTerm>
    </Item>
    <Item>
       <DictionaryEntryName>Country
Identification_ Code. Content</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Country
Identification_ Code List. Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Country
Identification_ Language. Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Currency_ Code. Type</DictionaryEntryName>
       <RepresentationTerm>Code</RepresentationTerm>
    </Item>
    <Item>
       <DictionaryEntryName>Currency_ Code. 
Content</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Currency_ Code List. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Currency_ Language. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Document Status_ Code. 
Type</DictionaryEntryName>
       <RepresentationTerm>Code</RepresentationTerm>
    </Item>
    <Item>
       <DictionaryEntryName>Document Status_ Code. 
Content</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Document Status_ Code List. 
Identifier</DictionaryEntryName>
    </Item>
    <Item>
       <DictionaryEntryName>Document Status_ Language. 
Identifier</DictionaryEntryName>
    </Item>
  </Model>
t:\ftemp>type test.xsl
<?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="2.0">

<xsl:output indent="yes"/>

<xsl:template match="/">
   <All>
     <xsl:for-each-group select="/*/Item"
                         
group-starting-with="RepresentationTerm[.='Code']">
       <Identification>
         <xsl:value-of select="DictionaryEntryName"/>
       </Identification>
     </xsl:for-each-group>
   </All>
</xsl:template>

</xsl:stylesheet>

t:\ftemp>call xslt2 test.xml test.xsl test.out

t:\ftemp>type test.out
<?xml version="1.0" encoding="UTF-8"?>
<All>
    <Identification>Allowance Charge Reason_ Code. 
Type</Identification> </All>

--
UBL/XML/XSLT/XSL-FO training: Vårø, Denmark 
2006-10-02/06,11-20/24 UBL International 2006  2006-11-13/17 
http://www.ublconference.com World-wide corporate, govt. & 
user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>