Grouping on Multiple Field
Posted
by Nisarg Mehta
on Stack Overflow
See other posts from Stack Overflow
or by Nisarg Mehta
Published on 2010-05-07T12:59:02Z
Indexed on
2010/05/10
5:08 UTC
Read the original article
Hit count: 449
Hi , I am generating XML file from Database as below...
<?xml version = '1.0'?>
<T0019>
<IFTA_ACCOUNT>
<IFTA_CARRIER_ID_NUMBER>705</IFTA_CARRIER_ID_NUMBER>
<IFTA_LICENSE_NUMBER>631227666</IFTA_LICENSE_NUMBER>
<IFTA_BASE_COUNTRY>US</IFTA_BASE_COUNTRY>
<IFTA_BASE_STATE>AL</IFTA_BASE_STATE>
<IFTA_STATUS_CODE>0 </IFTA_STATUS_CODE>
<IFTA_STATUS_DATE>2009-01-01</IFTA_STATUS_DATE>
<IFTA_ISSUE_DATE>2009-01-01</IFTA_ISSUE_DATE>
<IFTA_EXPIRE_DATE>2009-12-01</IFTA_EXPIRE_DATE>
<IFTA_UPDATE_DATE>2008-12-30</IFTA_UPDATE_DATE>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>K D L TRUCKING INC</NAME>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>200 MARTIN LANE</STREET_LINE_1>
<CITY>OHATCHEE</CITY>
<STATE>AL</STATE>
<ZIP_CODE>36271</ZIP_CODE>
<COUNTY>CALHOUN COUNTY</COUNTY>
<COUNTRY>US</COUNTRY>
</IFTA_ACCOUNT>
<IFTA_ACCOUNT>
<IFTA_CARRIER_ID_NUMBER>705</IFTA_CARRIER_ID_NUMBER>
<IFTA_LICENSE_NUMBER>631227666</IFTA_LICENSE_NUMBER>
<IFTA_BASE_COUNTRY>US</IFTA_BASE_COUNTRY>
<IFTA_BASE_STATE>AL</IFTA_BASE_STATE>
<IFTA_STATUS_CODE>0 </IFTA_STATUS_CODE>
<IFTA_STATUS_DATE>2009-01-01</IFTA_STATUS_DATE>
<IFTA_ISSUE_DATE>2009-01-01</IFTA_ISSUE_DATE>
<IFTA_EXPIRE_DATE>2009-12-01</IFTA_EXPIRE_DATE>
<IFTA_UPDATE_DATE>2008-12-30</IFTA_UPDATE_DATE>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>K D L TRUCKING INC</NAME>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>200 MARTIN LANE</STREET_LINE_1>
<CITY>OHATCHEE</CITY>
<STATE>AL</STATE>
<ZIP_CODE>36271</ZIP_CODE>
<COUNTRY>US</COUNTRY>
</IFTA_ACCOUNT>
</T0019>
I have taken first two records from generated XSLT. With the use of XSLT I have tried lot to group record on basis of IFTA_LICENSE_NUMBER,IFTA_BASE_COUNTRY,IFTA_BASE_ST ATE,NAME_TYPE,ADDRESS_TYPE but i failed to generated XML like this..
<?xml version="1.0" encoding="UTF-8" ?>
<T0019>
<IFTA_ACCOUNT>
<IFTA_CARRIER_ID_NUMBER>705</IFTA_CARRIER_ID_NUMBER>
<IFTA_BASE_COUNTRY>US</IFTA_BASE_COUNTRY>
<IFTA_BASE_STATE>AL</IFTA_BASE_STATE>
<IFTA_LICENSE_NUMBER>631227666</IFTA_LICENSE_NUMBER>
<IFTA_STATUS_CODE>0</IFTA_STATUS_CODE>
<IFTA_STATUS_DATE>2009-01-01</IFTA_STATUS_DATE>
<IFTA_ISSUE_DATE>2009-01-01</IFTA_ISSUE_DATE>
<IFTA_EXPIRE_DATE>2009-12-01</IFTA_EXPIRE_DATE>
<IFTA_UPDATE_DATE>2008-12-30</IFTA_UPDATE_DATE>
<IFTA_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>K D L TRUCKING INC</NAME>
<IFTA_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>200 MARTIN LANE</STREET_LINE_1>
<STREET_LINE_2 />
<CITY>OHATCHEE</CITY>
<STATE>AL</STATE>
<ZIP_CODE>36271</ZIP_CODE>
<COUNTY>CALHOUN COUNTY</COUNTY>
<COUNTRY>US</COUNTRY>
</IFTA_ADDRESS>
<IFTA_ADDRESS>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>200 MARTIN LANE</STREET_LINE_1>
<STREET_LINE_2 />
<CITY>OHATCHEE</CITY>
<STATE>AL</STATE>
<ZIP_CODE>36271</ZIP_CODE>
<COUNTY />
<COUNTRY>US</COUNTRY>
</IFTA_ADDRESS>
</IFTA_NAME>
</IFTA_ACCOUNT>
</T0019>
© Stack Overflow or respective owner