Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 28th, 2008, 04:06 PM
sac sac is offline
Registered User
 
Join Date: Jul 2008
Location: gurgaon, haryana, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Grouping xmls

Hi all

I am trying to combine 2 or more xmls having same tags to a single xml.
Following is my xml:
<root>
    <data>
        <row>
            <id>1</id>
            <address>368 hbs</address>
            <image>1.jpg</image>
        </row>
        <row>
            <id>1</id>
            <address>368 hbs</address>
            <image>2.jpg</image>
        </row>
        <row>
            <id>2</id>
            <address>407 hbs</address>
            <image>1.jpg</image>
        </row>
    </data>
</root>

I want it to be grouped by id. Like first and second row (having same id) get combine to form one xml etc....

Please help.....

Thanks
Sac
  #2 (permalink)  
Old July 28th, 2008, 06:00 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

5 hours before your post someone else asked about grouping: check the answer to that post.

If you are producing multiple output documents you will want to use XSLT 2.0 with its xsl:result-document instruction.

<xsl:for-each-group select="row" group-by="id">
  <xsl:result-document href="{current-grouping-key()}.xml">
    <xsl:copy-of select="current-group()"/>
  </xsl:result-document>
</xsl:for-each-group>

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old July 28th, 2008, 06:32 PM
sac sac is offline
Registered User
 
Join Date: Jul 2008
Location: gurgaon, haryana, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks for the help.

I have tried various ways but everytime I try xslt 2.0 my browser says "Error during XSLT transformation: XSLT transformation failed."

So it may be the case that I have to stick with xslt 1.0. Any idea?

Thanks
Sac

Thanks
Sac
  #4 (permalink)  
Old July 29th, 2008, 01:10 AM
Authorized User
 
Join Date: Jul 2008
Location: , , .
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Before working with XSL 2.0 be aware either it supports for your installed xslt processor. I am not sure about the required xslt processor / software to work with XSLT 2.0. But i am sure about if you r using with Xalan-C++ you dont have support for XSL2.0...
  #5 (permalink)  
Old July 29th, 2008, 04:16 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

None of the browsers yet support XSLT 2.0 unfortunately.

There's no point writing XSLT 2.0 code unless you have an XSLT 2.0 processor.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple xmls and xsls pasupathy.b XSLT 6 June 4th, 2007 01:07 PM
XML element referencing to other xmls alexhinz XSLT 0 February 8th, 2007 09:32 AM
Protect cells and allow grouping/un-grouping sfreuden Excel VBA 4 December 14th, 2006 08:01 AM
Grouping by attribute aiyer0912 XSLT 1 November 13th, 2006 06:47 AM
Grouping and totals btado XSLT 3 June 22nd, 2005 01:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.