Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old February 20th, 2009, 06:24 PM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Grouping and referencing repeated elememts

Hi

I have been trying to solve the following problem if anyone can help. Given the following input:

<contactInformation>

...

<person>
<personId>5</personId>
<phoneNumberId>100</phoneNumberId>
</person>
<person>
<personId>5</personId>
<phoneNumberId>200</phoneNumberId>
</person>
<person>
<personId>4</personId>
<phoneNumberId>500</phoneNumberId>
</person>
<person>
<personId>5</personId>
<phoneNumberId>300</phoneNumberId>
</person>
<person>
<personId>4</personId>
<phoneNumberId>400</phoneNumberId>
</person>

...

<contactPhoneNumbers>
<contactNumber>
<phoneNumberId>400</phoneNumberId>
<number>444.4444</number>
</contactNumber>
<contactNumber>
<phoneNumberId>500</phoneNumberId>
<number>555.5555</number>
</contactNumber>
<contactNumber>
<phoneNumberId>600</phoneNumberId>
<number>666.6666</number>
</contactNumber>
<contactNumber>
<phoneNumberId>300</phoneNumberId>
<number>333.3333</number>
</contactNumber>
<contactNumber>
<phoneNumberId>100</phoneNumberId>
<number>111.1111</number>
</contactNumber>
</contactPhoneNumbers>

...

</contactInformation>


I would like to produce the following output:


<contactInformation>
<contact id="4">
<phoneNumber id="400">444.4444</phoneNumber>
<phoneNumber id="500">555.5555</phoneNumber>
</contact>
<contact id="5">
<phoneNumber id="100">111.1111</phoneNumber>
<phoneNumber id="300">333.3333</phoneNumber>
</contact>
</contactInformation>


Im having an issue of getting either repeating <contact> tags or <phoneNumber> of the same value depending on the nesting of my <xsl:for-each-group> tags.

If someone can point me in the right direction, I would appreciate it.

Thanks.
 
Old February 20th, 2009, 06:41 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Im having an issue of getting either repeating <contact> tags or <phoneNumber> of the same value depending on the nesting of my <xsl:for-each-group> tags.

So, your code is wrong. If you show us your code, we can tell you where your mistake is.
__________________
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
Dataset repeated values Narts C# 1 November 23rd, 2007 10:31 AM
matches without repeated items pongup BOOK: Beginning Regular Expressions 0 April 7th, 2007 09:05 PM
Protect cells and allow grouping/un-grouping sfreuden Excel VBA 4 December 14th, 2006 08:01 AM
How can I stop repeated words elfstoneUK BOOK: Beginning Regular Expressions 1 September 8th, 2006 03:04 AM
Excecuting repeated code every one second maxpotters Excel VBA 6 March 6th, 2005 06:34 PM





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