RE: [xsl] XSL Transformation!!

Subject: RE: [xsl] XSL Transformation!!
From: cknell@xxxxxxxxxx
Date: Sun, 26 Dec 2004 18:05:25 -0500
You will want two templates to handle the <Risk> elements, one for those with the "RepeatDet" attribute and one for those without. The template for those without is a null template. It copies nothing.

<xsl:template match="Risk[not(@RepeatDet)]> />

The second will be like this

<xsl:template match="Risk[@RepeatDet]">
  <xsl:apply templates />
</xsl:template>

Outside this you establish templates to match each of the child elements of Risk that you want to put in the output. E.g., 

<xsl:template match="SeqNumber">
  <SeqNumber><xsl:value-of select="." /><SeqNumber>
</xsl:template>

You haven't given enough information for me to go any further. If you need more help, come back with examples of how you want the individual child elements of <Risk> to look.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Kalkunda, Venkat <Kalkunda.Venkat@xxxxxxxxxxxxx>
Sent:     Fri, 24 Dec 2004 12:43:00 -0600
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] XSL Transformation!!

I am working on a J2EE project. that needs some XSL transformation and I am stuck with an issue that how much ever I try am not able to resolve. Anybody with any suggestions or solutions will be greatly appreciated. 

<Risk RepeatDet="SeqNumber='1'">
                 <SeqNumber>1</SeqNumber>
                 <ExistingProductType CtlType="5" QID="1597">Disability Income</ExistingProductType>
                 <ExistingPolNumber CtlType="7" QID="1597">456464765</ExistingPolNumber>                  
                 <ExistingInsuranceAmt CtlType="7" QID="1597">8000</ExistingInsuranceAmt>
                 <ExistingInsuranceName CtlType="7" QID="1597">ING</ExistingInsuranceName>
                 <ExistingInsurancePending CtlType="10" QID="1597">Yes</ExistingInsurancePending>
                 <ExistingInsuranceEP CtlType="5" QID="1597">60 day</ExistingInsuranceEP>
                 <ExistingInsuranceInd CtlType="10" QID="1597">No</ExistingInsuranceInd>
                 <ExistingInsuranceBP CtlType="5" QID="1597">To Age 65</ExistingInsuranceBP>
                 <ReplacementType CtlType="10" QID="1597">Yes</ReplacementType>
               </Risk>
               <Risk RepeatDet="SeqNumber='2'">
                 <SeqNumber>2</SeqNumber>
                 <ExistingInsuranceInd CtlType="10" QID="1597">Yes</ExistingInsuranceInd>
                 <ExistingInsuranceAmt CtlType="7" QID="1597">9000</ExistingInsuranceAmt>
                 <ExistingInsurancePending CtlType="10" QID="1597">No</ExistingInsurancePending>
                 <ExistingInsuranceBP CtlType="5" QID="1597">To Age 67</ExistingInsuranceBP>
                 <ExistingInsuranceEP CtlType="5" QID="1597">90 day</ExistingInsuranceEP>
                 <ExistingPolNumber CtlType="7" QID="1597">48979</ExistingPolNumber>
                 <ExistingProductType CtlType="5" QID="1597">Overhead Expense</ExistingProductType>
                 <ExistingInsurancePaidBy CtlType="1" QID="1597">E</ExistingInsurancePaidBy>
                 <ExistingInsuranceName CtlType="7" QID="1597">Blue Cross Blue Shield</ExistingInsuranceName>
                 <ReplacementType CtlType="10" QID="1597">No</ReplacementType>
               </Risk>
               <Risk RepeatDet="SeqNumber='3'">
                 <SeqNumber>3</SeqNumber>
                 <ExistingInsuranceInd CtlType="10" QID="1597">No</ExistingInsuranceInd>
                 <ExistingInsuranceAmt CtlType="7" QID="1597">54354</ExistingInsuranceAmt>
                 <ExistingInsurancePending CtlType="10" QID="1597">No</ExistingInsurancePending>
                 <ExistingInsuranceBP CtlType="5" QID="1597">To Age 67</ExistingInsuranceBP>
                 <ExistingInsuranceEP CtlType="5" QID="1597">60 day</ExistingInsuranceEP>
                 <ExistingPolNumber CtlType="7" QID="1597">54545</ExistingPolNumber>
                 <ExistingProductType CtlType="5" QID="1597">Overhead Expense</ExistingProductType>
                 <ExistingInsurancePaidBy CtlType="1" QID="1597">E</ExistingInsurancePaidBy>
                 <ExistingInsuranceName CtlType="7" QID="1597">United Health Care</ExistingInsuranceName>
                 <ReplacementType CtlType="10" QID="1597">No</ReplacementType>
               </Risk>

I have a segment of the XML which i need to transform. From each <Risk> that contains the attribute <RepeatDet>
I need to pull out the other elements within the <Risk> node and transform to a format as below

<field name=ExistingInsuranceName1>
	<value>ING</value>
</field>

In this way, I have to transform all the elements within the <Risk> Node, as long as <Risk> nodes with attribute <RepeatDet> is present. There are other <Risk> nodes in the complete XML file but with out the attribute<RepeatDet>. Can somebody please help me, as to how to do this. I have used the <xsl:for-each> but it is creating different elements for all the <Risk> nodes but its putting the same values each time.

Thank You
Kalkunda Venkat
515 362 0241
x-20241




-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect@xxxxxxxxxxxxx and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

Current Thread