Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xslt group by elements and "sub"-elements...

Status
Not open for further replies.

jenlion

IS-IT--Management
Nov 13, 2001
215
I have an xml file that I am converting to a new xml file. Currently I'm creating an xslt file with MapForce to do this.

My issue is that my source file contains data at low-levels of the file, and my destination needs that data grouped at high-level:

Source
Code:
<Receipt>
  <Receipt Header>
    <Warehouse/>
    <Receipt Lines>
       <Company/>
    </Receipt Lines>
  </Receipt Header>
</Receipt>

Destination
Code:
<Receipt Batch>
  <Company/>
  <Warehouse/>
  <Receipt Header>
    <Receipt Lines>
    </Receipt Lines>
  </Receipt Header>
</Receipt Batch>
I've simplified it to only show the relevant elements; obviously there's a lot more in the source file's header and line records. But the weird thing is that the source file's header may have lines for multiple warehouses. And there's nothing like a "batch" in the source file.

What I need to do is pull all of the source PO Headers out by company and put them in one batch with all of their lines by warehouse. Basically, Company1 and WarehouseA are one batch; Company1 and WarehouseB are one batch; Company2 and WarehouseA are one batch; Company2 and WarehouseB are another batch.

Since we're calling the xslt programmatically (via saxon), I'm hoping that there's some grouping functionality to call on here? Currently using MapForce but still pretty new to it; hoping to keep all this within mapforce but the concept is more important than the editor.
 
For xslt 1.0, search google on xsl:key element (search this forum and a k5tm's faq). For xslt 2.0, search group-by attribute of xsl:for-each-group element.
ps: tag names with empty space separator are not well-formed even as a demo of concept.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top