XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + get the current position as pa... (2)
-> - unable to get Parameter from x... (1)
-> + get key value from xslt to jav... (2)
-> + Xpath insensitive search? (3)
-> + relative path 2 (10)
-> + sum and group attrs, list only... (3)
-> - Simple multiplication.... but ... (1)
-> + .NET issue (2)
-> - Grouping items (9)
-> ->Grouping items
-> ->Grouping items
-> ->Grouping items
-> ->Grouping items
-> ->Grouping items
-> ->Grouping items
-> ->Grouping items
-> ->Grouping items
-> + Group Move (4)
-> + Problem with DateTime manipula... (2)
-> + xls fo positioning in block (2)
-> + Filtering with XSLT not workin... (3)
-> + Petri net to BPEL model transf... (3)
-> + Selecting specific child eleme... (2)
-> + Grouping and summing ... (3)
-> + XSL-FO question: can't get ext... (2)
-> + for each with a parallel nodel... (3)
-> + unable to load schmea with tar... (5)
-> + Translating svg path data to x... (5)
-- Previous [1321-1340] [1341-1360] [1361-1380] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Neal WaltersSubject: Grouping items
Author: Neal Walters
Date: 05 Sep 2006 02:46 PM
My other task is take an element and group it into groups of 14.
I recall from the past that even incrementing a counter is kind of tricky. So while I'm looping, if the counter is < 14 I move a group to a a group, but once the counter is 14, I have to reset counter to 1, and start a new group on the target doc.

Any suggestions or tricks? Seems like last time I needed a counter the easiest way to do it was with a C# subroutine (I'm in the .NET world).

Thanks in advance,
Neal

Postnext
Ivan PedruzziSubject: Grouping items
Author: Ivan Pedruzzi
Date: 05 Sep 2006 04:22 PM

Could please post a concrete example and the desired result?

Ivan Pedruzzi
Stylus Studio Team

Postnext
Neal WaltersSubject: Grouping items
Author: Neal Walters
Date: 05 Sep 2006 05:37 PM
See attached. The goal in this simplified version is to group the line-items by 3. The first three line items go together, then the second three, then the 7th one is left by itself.

Thanks,
Neal


Documentgroupdemoin.xml
demo input

Unknowngroupdemoout.xml
demo output

Postnext
Neal WaltersSubject: Grouping items
Author: Neal Walters
Date: 05 Sep 2006 07:05 PM
I'm thinking about using position() and trying to use modular division - maybe then I don't need a counter.

Neal

Postnext
Neal WaltersSubject: Grouping items
Author: Neal Walters
Date: 05 Sep 2006 07:20 PM
Here's where I'm headed, ( am properly displaying the position() and the mods, but what's confusing me is how to write out the <body> tag optionally - and to keep the XML in the XSLT well-formed i.e. "balanced".


<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<groupdemoin>
<xsl:for-each select="groupdemoin/body/bodylineitem/bodyline">
<xsl:if test="position() mod 3 = 0">
<body>
</body>
</xsl:if>


<bodylineitem>
<bodyline>
<xsl:value-of select="position()"/>
</bodyline>
<bodydivision>
<xsl:value-of select="position() mod 3"/>
</bodydivision>
<bodystuff>temp</bodystuff>
</bodylineitem>
</body>
</xsl:for-each>
</groupdemoin>
</xsl:template>
</xsl:stylesheet>

Postnext
Neal WaltersSubject: Grouping items
Author: Neal Walters
Date: 05 Sep 2006 08:53 PM
Originally Posted: 05 Sep 2006 08:54 PM
Please see attached. It seems to work, but I'd like a second opinion if it is the best way or not. I had to put some of the <body> tags in CDATA to fool the parser.

Thanks,
Neal


UnknownGroupBy14Test.xslt
My Sample working XSLT

Postnext
Ivan PedruzziSubject: Grouping items
Author: Ivan Pedruzzi
Date: 05 Sep 2006 09:03 PM

This is a basic paging problem, see the attached solution



Ivan Pedruzzi
Stylus Studio Team


Documentgroupdemo.xsl

Postnext
Neal WaltersSubject: Grouping items
Author: Neal Walters
Date: 07 Sep 2006 12:35 PM
That is so cool!

Can you send me a reference that explains the pipe symbol
in this statement:
". | following-sibling::bodylineitem[position() < $pagesize]">

Is it acting as an "OR" here? Select current node or the other node?
If so, I didn't know you could put an "OR" in a for-each...

Thanks,
Neal

Posttop
Ivan PedruzziSubject: Grouping items
Author: Ivan Pedruzzi
Date: 07 Sep 2006 01:02 PM

| is the nodeset union operator see http://www.w3.org/TR/xpath#node-sets

Ivan Pedruzzi
Stylus Studio Team

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.