[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to do this unique grouping on XML using XSLT 1.0

Subject: How to do this unique grouping on XML using XSLT 1.0
From: Amit Agarwal <aagarwal123@xxxxxxxxx>
Date: Tue, 19 Jun 2012 18:42:13 +0530
 How to do this unique grouping on XML using XSLT 1.0
My input xml looks like:


 Root>
  <ReportDrugSafetyReport>
   <DrugSafetyReportPatient>
    <DrugSafetyReportDrug>
     <MedicinalProductName>BPM Infra</MedicinalProductName>
     <ObtainedCountryCode>US</ObtainedCountryCode>
    </DrugSafetyReportDrug>

    <DrugSafetyReportDrug>
     <MedicinalProductName>Multistandard VCR</MedicinalProductName>
     <ObtainedCountryCode>UK</ObtainedCountryCode>
    </DrugSafetyReportDrug>

    <DrugSafetyReportDrug>
     <MedicinalProductName>Pharmaceuticals</MedicinalProductName>
     <ObtainedCountryCode>IN</ObtainedCountryCode>
    </DrugSafetyReportDrug>

   </DrugSafetyReportPatient>

   <DrugSafetyReportMedicalDevice>
    <MedicalDeviceName>BPM Infra</MedicalDeviceName>
    <DeviceProductCode>1234</DeviceProductCode>
   </DrugSafetyReportMedicalDevice>

   <DrugSafetyReportMedicalDevice>
    <MedicalDeviceName>Different Product name</MedicalDeviceName>
    <DeviceProductCode>456</DeviceProductCode>
   </DrugSafetyReportMedicalDevice>
  </ReportDrugSafetyReport>
 </Root>

 And My target xml is:

 <Root>
  <Drug>
   <medicinalproduct>BPM Infra</medicinalproduct>
   <ObtainedCountryCode>US</ObtainedCountryCode>
   <DeviceProductCode>1234</DeviceProductCode>
  </Drug>
  <Drug>
   <medicinalproduct>Multistandard VCR</medicinalproduct>
   <ObtainedCountryCode>UK</ObtainedCountryCode>
  </Drug>
  <Drug>
   <medicinalproduct>Pharmaceuticals</medicinalproduct>
   <ObtainedCountryCode>IN</ObtainedCountryCode>
  </Drug>
  <Drug>
   <medicinalproduct>Different Product name</medicinalproduct>
   <DeviceProductCode>456</DeviceProductCode>
  </Drug>
 </Root>

  Input xml contains two unbounded elements DrugSafetyReportDrug and
DrugSafetyReportMedicalDevice. Both of these elements belongs to
different parent elements, e.g.
 <root>ReportDrugSafetyReport/
DrugSafetyReportPatient/DrugSafetyReportDrug and
<root>/ReportDrugSafetyReport/DrugSafetyReportMedicalDevice

 Each of these elements has a set of child elements. Out of which,
MedicinalProductName is child element of  DrugSafetyReportDrug
(DrugSafetyReportDrug/MedicinalProductName)  and MedicalDeviceName is
child element of DrugSafetyReportMedicalDevice
(DrugSafetyReportMedicalDevice/MedicalDeviceName).

 Target xml has an unbounded element: drug.

If MedicinalProductName = MedicalDeviceName then DrugSafetyReportDrug
and DrugSafetyReportMedicalDevice should be grouped to a single drug
element (in the target xml). Otherwise, there would be a separate drug
element for each DrugSafetyReportDrug and
DrugSafetyReportMedicalDevice.

Thanks for your help!.

Thanks,
Amit

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.