fixed-size grouping

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

fixed-size grouping

Jan Pour
Hi all!
It seems to be an easy question, but it is tough for me...
Can you give me an example of this paragraph from W3C Candidate Recommendation 3 November 2005?:
 
In addition these facilities allow grouping based on sequential position, for example selecting groups of adjacent para elements. The facilities also provide an easy way to do fixed-size grouping, for example identifying groups of three adjacent nodes, which is useful when arranging data in multiple columns.
 
Input:
   <root>
      <photo>15</photo>
      <photo>2</photo>
      <photo>38</photo>
      <photo>4</photo>
      <photo>5</photo>
      <photo>6</photo>
      <photo>7</photo>
      <photo>8</photo>
      <photo>9</photo>
      <photo>10</photo>
   </root>
 
Output:
   <root>
      <group>
         <photo>15</photo>
         <photo>2</photo>
         <photo>38</photo>
      </group>
      <group>
         <photo>4</photo>
         <photo>5</photo>
         <photo>6</photo>
      </group>
      <group>
         <photo>7</photo>
         <photo>8</photo>
         <photo>9</photo>
      </group>
      <group>
         <photo>10</photo>
      </group>
   </root>
 
Thanks a lot!
Jan
Reply | Threaded
Open this post in threaded view
|

RE: fixed-size grouping

Michael Kay
In future, please use the xsl-list at www.mulberrytech.com for help with XSLT coding questions: this list is intended for questions that are specific to the Saxon implementation.
 
For fixed-size groups of size 3, try
 
group-adjacent="(position() - 1) idiv 3"
 
or
 
group-starting-with="*[position() mod 3 = 1]"
 
Michael Kay


From: [hidden email] [mailto:[hidden email]] On Behalf Of Jan Pour
Sent: 26 December 2005 23:28
To: [hidden email]
Subject: [saxon] fixed-size grouping

Hi all!
It seems to be an easy question, but it is tough for me...
Can you give me an example of this paragraph from W3C Candidate Recommendation 3 November 2005?:
 
In addition these facilities allow grouping based on sequential position, for example selecting groups of adjacent para elements. The facilities also provide an easy way to do fixed-size grouping, for example identifying groups of three adjacent nodes, which is useful when arranging data in multiple columns.
 
Input:
   <root>
      <photo>15</photo>
      <photo>2</photo>
      <photo>38</photo>
      <photo>4</photo>
      <photo>5</photo>
      <photo>6</photo>
      <photo>7</photo>
      <photo>8</photo>
      <photo>9</photo>
      <photo>10</photo>
   </root>
 
Output:
   <root>
      <group>
         <photo>15</photo>
         <photo>2</photo>
         <photo>38</photo>
      </group>
      <group>
         <photo>4</photo>
         <photo>5</photo>
         <photo>6</photo>
      </group>
      <group>
         <photo>7</photo>
         <photo>8</photo>
         <photo>9</photo>
      </group>
      <group>
         <photo>10</photo>
      </group>
   </root>
 
Thanks a lot!
Jan
Reply | Threaded
Open this post in threaded view
|

Re: fixed-size grouping

Stefan Wachter
In reply to this post by Jan Pour
Group by using the the position() function.

--Stefan

Jan Pour wrote:

> Hi all!
> It seems to be an easy question, but it is tough for me...
> Can you give me an example of this paragraph from W3C Candidate
> Recommendation 3 November 2005?:
>  
> In addition these facilities allow grouping based on sequential
> position, for example selecting groups of adjacent para elements. The
> facilities also provide an easy way to do fixed-size grouping, for
> example identifying groups of three adjacent nodes, which is useful
> when arranging data in multiple columns.
>  
> Input:
>    <root>
>       <photo>15</photo>
>       <photo>2</photo>
>       <photo>38</photo>
>       <photo>4</photo>
>       <photo>5</photo>
>       <photo>6</photo>
>       <photo>7</photo>
>       <photo>8</photo>
>       <photo>9</photo>
>       <photo>10</photo>
>    </root>
>  
> Output:
>    <root>
>       <group>
>          <photo>15</photo>
>          <photo>2</photo>
>          <photo>38</photo>
>       </group>
>       <group>
>          <photo>4</photo>
>          <photo>5</photo>
>          <photo>6</photo>
>       </group>
>       <group>
>          <photo>7</photo>
>          <photo>8</photo>
>          <photo>9</photo>
>       </group>
>       <group>
>          <photo>10</photo>
>       </group>
>    </root>
>  
> Thanks a lot!
> Jan




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help