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

Re: Grouping-by appropriate values from external docu

Subject: Re: Grouping-by appropriate values from external document.
From: omprakash.v@xxxxxxxxxxxxx
Date: Fri, 21 Oct 2005 18:21:33 +0530
product grouping

Please see this stylesheet.

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="2.0"

 <xsl:output method="xml"/>

 <xsl:key name="prd" match="product" use="@pr_id"/>

 <xsl:template match="/shop">

 <xsl:variable name="goods" select="document('registry.xml')"/>

  <xsl:for-each-group select="product" group-by="@pr_id">
  <xsl:sort select="$goods/registry/goods[@id=current()/@pr_id]/@name"/>


      <xsl:copy-of select="key('prd', current-grouping-key())"/>





                      Xasima Xirohata                                                                                           
                      <xasima@xxxxxxxx         To:      xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                         
                      m>                       cc:      (bcc: omprakash.v/Polaris)                                              
                                               Subject:  Grouping-by appropriate values from external document.            
                      10/21/2005 04:14                                                                                          
                      Please respond                                                                                            
                      to xsl-list                                                                                               

My question could be expressed shorty as the following.
How to make correct the idea that marked in this XSLT 2.0 wrong expression:
 <xsl:for-each-group  select="/shop/product"

Extended discription:

I have a registry looks like

    <goods id="g123" name="Sweet Cake">
    <goods id="g124" name="Big Cake">
    <goods id="g125" name="Royal">

Incoming XML documents looks like

    <product pr_id="g123">
        <!--smth additional like package, container number,
    <product pr_id="g124"> <!-the same--></product>

I'd like to group "product" by the name of this product (goods) in
registry base, and sort them it that order.

For Example:
<group name="Big Cake">
    <product pr_id="g124"></product>
     <!-- all product with this pr_id -->
<group name="Sweet Cake">
    <product pr_id="g123"></product>
     <!-- blah-blah -->

Draw attention, that the ordering of "group" is the string ordering of
goods name in registry (B  - first) .

By the way, I seem  not be agreed with the exploring registry first
(apply-template select="document('registry.xml')//product" + sort
select="name") and populate appropriate product in in.xml. The
registry may be much more greater than in.xml.

Well, I tried the following code, but caught the failure

<xsl:for-each-group  select="/shop/product"


Would you be so kind to prompt to solution?

Thanks in advance.

          ~ Xasima Xirohata ~

This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

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.