xsl-list
[Top] [All Lists]

Grouping-by appropriate values from external document.

2005-10-21 03:44:16
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"
group-by="document('registry.xml')//goods[(_at_)id=current()/pr_id]/@name"/>

----------
Extended discription:


I have a registry looks like

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


Incoming XML documents looks like


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


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

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


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"
group-by="document('registry.xml')//goods[(_at_)id=current()/pr_id]/@name">

</xsl:for-each-group>


Would you be so kind to prompt to solution?

Thanks in advance.



--
Regards,
          ~ Xasima Xirohata ~

--~------------------------------------------------------------------
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>
--~--