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

April 29th, 2009, 08:17 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Sorry - this is just to big for me to debug in the time available. I can't help unless you can cut it down to something simple.
Telling us it's urgent doesn't help. You need to understand that people like me are always reluctant to help with an enquiry if it's urgent - it makes it far less likely that the questioner will take the time needed to phrase their questions carefully and study the responses.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

April 29th, 2009, 08:40 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Let's try to work from what you have posted.
You posted an XML input document in http://p2p.wrox.com/240346-post21.html. It is a well-formed sample, that, when indenting it with the help of an XML editor, looks as follows:
Code:
<OTA_HotelAvailRS xmlns="http://www.opentravel.org/OTA/2003/05">
<RoomStays>
<RoomStay SupplierSystem="XHOTEL">
<ns1:RoomRates xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="CP" ArtificialAllocation="0" MealPlanCode="6" RoomTypeCode="DLX">
</RoomRate>
</ns1:RoomRates>
</RoomStay>
<RoomStay SupplierSystem="XHOTEL">
<ns1:RoomRates xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="SUT">
</RoomRate>
<RoomRate NumberOfUnits="4" NumberOfGuests="6" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="SDLX">
</RoomRate>
</ns1:RoomRates>
</RoomStay>
<RoomStay SupplierSystem="XHOTEL">
<ns1:RoomRates xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="RFS">
</RoomRate>
</ns1:RoomRates>
</RoomStay>
</RoomStays>
</OTA_HotelAvailRS>
Then in the post http://p2p.wrox.com/240347-post22.html you describe what you want as the output. Unfortunately that sample is not even well-formed, it has a RoomRate element that is not closed. When I correct that and indent to make it more readable then I get:
Code:
<OTA_HotelAvailRS xmlns="http://www.opentravel.org/OTA/2003/05">
<RoomStays>
<RoomStay SupplierSystem="XHOTEL">
<ns1:RoomRates xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="CP" ArtificialAllocation="0" MealPlanCode="6" RoomTypeCode="DLX">
</RoomRate>
</ns1:RoomRates>
</RoomStay>
<RoomStay SupplierSystem="XHOTEL">
<ns1:RoomRates xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="SUT">
</RoomRate>
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="SDLX">
</RoomRate>
</ns1:RoomRates>
</RoomStay>
<RoomStay SupplierSystem="XHOTEL">
<ns1:RoomRates xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="RFS"/>
<RoomRate NumberOfUnits="2" NumberOfGuests="3" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="SDLX">
</RoomRate>
</ns1:RoomRates>
</RoomStay>
</RoomStays>
</OTA_HotelAvailRS>
I have looked at those two samples for some time but I fail to see the relationship between the two so I am not sure what kind of transformation you want to apply.
You have a OTA_HotelAvailRS root element with a RoomStays child element that has three RoomStay child elements, each having a RoomRates child element.
That part seems to remain unchanged.
Can you explain the relationship between the RoomRates/RoomRate elements in the input and output?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|
|

April 29th, 2009, 08:46 AM
|
 |
Wrox Staff
Points: 18,059, Level: 58 |
|
|
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
|
|
As the response message you got and pasted here states, posting the same moderated message over aand over (more than 30 times actually) doesn't help you, it slows down the moderation process, not speeds it up. And it makes it hard for us to tell if there was more than 1 unique message in there or the same thing in 30 variations.
I recognize it's frustrating to wait but if this happens again, we'll get it it in a few hours.
Quote:
Originally Posted by maryj
i have tried many a times but it doesn't allow me to submit. Always redirects to a page that says " Thanks for posting. Moderators need to approve"
"
Thank you for posting! Your post will not be visible until a moderator has approved it for posting. You will now be taken back to the forum. If you opted to post a poll, you will now be allowed to do so.
Please DO NOT repost the same message! If you message is not spam, it will be approved soon.
Click here if your browser does not automatically redirect you.
"
Please guide how can I submit the xslt code. I have tried at least 10 times
|
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click  on their post!
|
|

April 29th, 2009, 10:27 AM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 25
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Thanks for giving so much time Martin.
Basic structure remains same. RoomStays , then RoomStay, then RoomRates , then RoomRate.
What I want is, to calculate and aggregate results in RoomRates (for which you have already given the code) for each RoomStay separately.
Let me describe it.
There is root node <OTA_HotelAvailRS>. Inside this there is <RoomStays> which is also single. That has multiple <RoomStay> nodes. In 1 <RoomStay>, there is single <RoomRates> which again has multiple <RoomRate> nodes.
Now what I previously had (the code that you provided me), that code creates a key on RoomRates and works for-each RoomRate.
It doesn't takes into account RoomStay.
Hence, if you see those samples, @RoomTypeCode="SDLX" from 1 RoomStay node gets mixed up with @RoomTypeCode from another RoomStay.
<RoomRate NumberOfUnits="4" NumberOfGuests="6" RoomRPH="1" OnRequest="false" RatePlanCode="EP" ArtificialAllocation="1" MealPlanCode="14" RoomTypeCode="SDLX">
</RoomRate>
This RoomRate node is a result of aggregated result from 2 RoomStay nodes.
What I want is, the code should consider "for-each RoomRate" , which it is already doing. But before that, it should also take into account "for-each RoomStay"
The code should not work on multiple RoomStay nodes together.
I hope you understand :)
Thanks,
Mary
Last edited by maryj; April 29th, 2009 at 10:31 AM..
|
|

April 29th, 2009, 11:05 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
So for each RoomStay element you want to group and aggregrate the RoomRate elements, is that right?
Then you need to change the key to
Code:
<xsl:key name="k1" match="ota:RoomRates/ota:RoomRate[not(@RatePlanCode = 'RACK')]" use="concat(generate-id(parent::ota:RoomRates/parent::ota:RoomStay), '|', @RatePlanCode, '|', @RoomTypeCode)"/>
That way, as the key includes the id of the ancestor RoomStay element, you should be able to group and aggregrate the RoomRate elements for each RoomStay. You only need to make sure you use the expression
Code:
concat(generate-id(parent::ota:RoomRates/parent::ota:RoomStay), '|', @RatePlanCode, '|', @RoomTypeCode)
where you before had
Code:
concat(@RatePlanCode, '|', @RoomTypeCode)
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|
|

April 29th, 2009, 11:46 AM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 25
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Don't know how to thank you enough but thanks a ton.
I will try this code and get back to you in case of any problem :)
Mary
************************************************** ********
I am trying to thank Martin from morning but moderators are not approving that for posting :)
But this time, I have tried only 2 times Jim :)
Thank u so much Martin . Code is working superbly.
Tonnes of thanks for your patience :)
Best Regards,
Mary
Last edited by maryj; April 30th, 2009 at 07:18 AM..
|
|

April 30th, 2009, 01:01 AM
|
|
Authorized User
|
|
Join Date: Apr 2009
Posts: 25
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Martin,
Thanks a lot. Actually tonnes of thanks.
Its working
Best Regards,
Mary
|
|
 |