I need help in XSL transformation ,following is my input structure :
I want to create following structure out of it :
I am not sure how to match Pset of T_num with corrosponding T_status ( there order should match , first Pset of T_num should match with first Pset of T_status)
Also this is single snippet example , there are multiple snippets similar like this so when we we select node we have to select all the T_num and T_status after X_number and before another X_number node.
returns a list of Pset elements which have "T_num" as their "name" attribute. You can make a similar list for "T_status". Those lists should have the same length? Anyway you can then use <xsl:for-each> to process the first list and inside that loop, get the corresponding element from the second list using the position() function.
Joined: May 03, 2011
Thanks for reply , It will certainly help to resolve this issue , however at the same time as I mentioned in my mail there can be multiple similar snippets like this so want to select T_Num and T_status between
<Pset name="X_number"> and before start of another <Pset name="X_number"> only or in a similar fashion
How I can achieve this ? Any pointer in this direction .
Another ugly problem. The people who designed this XML format should be repeatedly hit on the head with rotting fish carcasses.
You might do something with the previous-sibling axis to find the previous <Pset name="X_number"> for one of your Pset elements. But really the format should be redesigned so that if there's a natural group of Pset elements, they should be enclosed as children of a higher-level element.
Joined: May 03, 2011
I understand this format is pretty bad but it is given by third party on which we have dependency and they have used extensively in their code so redesign will not be possible because that will need massive change in their code.
Do you think using axis previous-sibling I can solve this issue , If I use that will it be possible to capture all xml nodes between these two using xpath which you suggested in your reply.
I thought of using xsl:key but that also does not fit in my criteria to choose nodes between X_number and before start of another X_number .
Kindly suggest and give me some more assistance.
This is not as easy in implementing an xsl template as one would think mainly because people may feel frozen up when actually need to write a working prototype template, before refining, to deal with this generically fairly complicated situation. This is how and you can see how things work out in this prototype implementation.
Suppose the block of of all those tags (Pset) is contained in the container tag, say named "container". The template shown here will match that and do all the work.
This prototype will be "T_num" centric in the sense that every Pset with attribute named "T_num" will be outputted. If the number of Pset with name attribute "T_status" is less than that with name attribute of T_num, those Tstatus will be empty. If the number of Pset with name attribute "T_status" is more than that with name attribute of T_num, those Pset will not be outputted and be ignored. And the whole output will also be wrapped in a tag named "container" again (change it to reflex your need).