Grouping problem...
Posted: Sat Jan 14, 2006 7:19 pm
The data I'm working with is coming from an unstructured table source - there is nothing to indicate that a row has ended, other than the sequence of elements.
When the <Price> element is followed by any other element other than itself, (like SKU in this example) I'd like to make thta my indicator of the end of a group.
The input XML is similar to this:
---------------------------------
<onepage>
<prodgroup>
<SKU>No. 447139K5</SKU>
<Price>Price 15.99</Price>
</prodgroup>
<prodgroup>
<SKU>456291K5</SKU>
<SKU>456225K5</SKU>
<SKU>456209K5</SKU>
<Price>159.99</Price>
<Price>169.99</Price>
<SKU>484697K5</SKU>
<SKU>456299K5</SKU>
<SKU>574599K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<SKU>484557K5</SKU>
<SKU>484545K5</SKU>
<SKU>484527K5</SKU>
<Price>169.99</Price>
<Price>289.99</Price>
</prodgroup>
<prodgroup>
<SKU>456237K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>189.99</Price>
<SKU>484552K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>309.99</Price>
</prodgroup>
</onepage>
---------------------------------
The ideal result of XML would be:
---------------------------------
<onepage>
<table>
<row>
<SKU>447139K5</SKU>
<Price>15.99</Price>
</row>
</table>
<table>
<row>
<SKU>456291K5</SKU>
<SKU>456225K5</SKU>
<SKU>456209K5</SKU>
<Price>159.99</Price>
<Price>169.99</Price>
</row>
<row>
<SKU>484697K5</SKU>
<SKU>456299K5</SKU>
<SKU>574599K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
</row>
<row>
<SKU>484557K5</SKU>
<SKU>484545K5</SKU>
<SKU>484527K5</SKU>
<Price>169.99</Price>
<Price>289.99</Price>
</row>
</table>
<table>
<row>
<SKU>456237K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>189.99</Price>
</row>
<row>
<SKU>484552K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>309.99</Price>
</row>
</table>
</onepage>
---------------------------------
The XSLT that I've currently written doesn't work properly because I'm using group-ending-with="Price".
Since the Price element can sometimes follow itself,
this creates an unwanted break in my result XML.
Any help would be GREATLY appreciated!
Thanks in advance!
-lmm
When the <Price> element is followed by any other element other than itself, (like SKU in this example) I'd like to make thta my indicator of the end of a group.
The input XML is similar to this:
---------------------------------
<onepage>
<prodgroup>
<SKU>No. 447139K5</SKU>
<Price>Price 15.99</Price>
</prodgroup>
<prodgroup>
<SKU>456291K5</SKU>
<SKU>456225K5</SKU>
<SKU>456209K5</SKU>
<Price>159.99</Price>
<Price>169.99</Price>
<SKU>484697K5</SKU>
<SKU>456299K5</SKU>
<SKU>574599K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<SKU>484557K5</SKU>
<SKU>484545K5</SKU>
<SKU>484527K5</SKU>
<Price>169.99</Price>
<Price>289.99</Price>
</prodgroup>
<prodgroup>
<SKU>456237K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>189.99</Price>
<SKU>484552K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>309.99</Price>
</prodgroup>
</onepage>
---------------------------------
The ideal result of XML would be:
---------------------------------
<onepage>
<table>
<row>
<SKU>447139K5</SKU>
<Price>15.99</Price>
</row>
</table>
<table>
<row>
<SKU>456291K5</SKU>
<SKU>456225K5</SKU>
<SKU>456209K5</SKU>
<Price>159.99</Price>
<Price>169.99</Price>
</row>
<row>
<SKU>484697K5</SKU>
<SKU>456299K5</SKU>
<SKU>574599K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
</row>
<row>
<SKU>484557K5</SKU>
<SKU>484545K5</SKU>
<SKU>484527K5</SKU>
<Price>169.99</Price>
<Price>289.99</Price>
</row>
</table>
<table>
<row>
<SKU>456237K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>189.99</Price>
</row>
<row>
<SKU>484552K5</SKU>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>169.99</Price>
<Price>309.99</Price>
</row>
</table>
</onepage>
---------------------------------
The XSLT that I've currently written doesn't work properly because I'm using group-ending-with="Price".
Since the Price element can sometimes follow itself,
this creates an unwanted break in my result XML.
Any help would be GREATLY appreciated!
Thanks in advance!
-lmm