Link to home
Start Free TrialLog in
Avatar of sri1209
sri1209

asked on

need to modify the xml through xslt

Hi ,

I have the below xml, i need to change the name of the attribute through xslt, any suggestions on how to implement this. Thank you in advance.

current xml:

<Cor>
<Ics>
                                    <Captions>
                                                <Caption id="A">Your total reported Income</Caption>
                                                <Caption type="OrdinaryDeduction">
                                                            <Text>-Deductions</Text>
                                                            <Item id="D10">Personal Needs Allowance </Item>
                                                </Caption>
                                                <Caption id="C">=Payment Towards Your Cost of Care.</Caption>
                                                <Caption type="MedicalDeduction">
                                                            <Text>Medical Expense Deductions:</Text>
                                                            <Item id="M1">Medicare Premium</Item>
                                                            <Item id="M2">Other Insurance Premium</Item>
                                                </Caption>
                                    </Captions>
 
</Ics>
</cor>


i need to modify as below:



<Cor>
<Ics>
                                    <Captions>
                                                <Caption id="A">Your total reported Income</Caption>
                                                <Caption id="OrdinaryDeduction">
                                                            <Text>-Deductions</Text>
                                                            <Item id="D10">Personal Needs Allowance </Item>
                                                </Caption>
                                                <Caption id="C">=Payment Towards Your Cost of Care.</Caption>
                                                <Caption id="MedicalDeduction">
                                                            <Text>Medical Expense Deductions:</Text>
                                                            <Item id="M1">Medicare Premium</Item>
                                                            <Item id="M2">Other Insurance Premium</Item>
                                                </Caption>
                                    </Captions>
 
</Ics>
</cor>
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sri1209
sri1209

ASKER

Hi mccarl,

Thank you very much  it worked .. can you please let me know the purpose of "."  in

<xsl:value-of select="." />
The "." simply refers to the current node that is being processed. In this case the template has matched a "type" attribute on a "Caption" element (and we haven't done any other processing that changes what node is the current node) so the current node in this context is the "type" attribute. So the xsl:value-of returns the value of the current node which is the value of the type attribute. And due to the <xsl:attribute> element that is around it, that means we are creating an "id" attribute that contains the value-of the "type" attribute.

Hope that helps, and I'm glad that it is working for you!