on 10-08-2009 6:42 AM
Hi,
I want to replace the value of an attribute for a specific node. Can you please tell me how this can be achieved using XSLT coding?
The input file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
<EnvelopeVersion>2.0</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>IR-PAYE-MOV</Class>
<Qualifier>request</Qualifier>
<Function>submit</Function>
<CorrelationID/>
<Transformation>XML</Transformation>
<GatewayTimestamp/>
</MessageDetails>
<SenderDetails>
<IDAuthentication>
<SenderID>isv142</SenderID>
<Authentication>
<Method>MD5</Method>
<Value>1L2xFE8WqHHI5iVMGhixAg==</Value>
</Authentication>
</IDAuthentication>
</SenderDetails>
</Header>
<GovTalkDetails>
<Keys>
<Key Type="TaxOfficeNumber">123</Key>
<Key Type="TaxOfficeReference">MD345</Key>
</Keys>
<ChannelRouting>
<Channel>
<URI>0142</URI>
</Channel>
</ChannelRouting>
</GovTalkDetails>
<Body>
<IRenvelope xmlns="http://www.govtalk.gov.uk/taxation/PAYE/MOV/09-10/1">
<IRheader>
<Keys>
<Key Type="TaxOfficeNumber">123</Key>
<Key Type="TaxOfficeReference">MD345</Key>
</Keys>
<PeriodEnd>2009-09-29</PeriodEnd>
<DefaultCurrency>GBP</DefaultCurrency>
<IRmark Type="generic">03Bfkipk6UDWSXLj77ObBVoK894=</IRmark>
<Sender>Company</Sender>
</IRheader>
<InYearMovements>
<EmployerName>form p60</EmployerName>
<P46 Statement="A">
<Name>
<Fore>Smith</Fore>
<Sur>John</Sur>
</Name>
<Address>
<Line>Sterling Residency</Line>
<Line>Gehde</Line>
<Line>Hedge End</Line>
<Line>Southampton</Line>
<PostCode>12345678</PostCode>
</Address>
<WorksNumber>20090030</WorksNumber>
<NINO>NP258719D</NINO>
<BirthDate>1985-07-11</BirthDate>
<Gender>male</Gender>
<StartDate>2009-04-20</StartDate>
<TaxCodeInUse>647L</TaxCodeInUse>
</P46>
</InYearMovements>
</IRenvelope>
</Body>
</GovTalkMessage>
I want to replace the value 'http://www.govtalk.gov.uk/taxation/PAYE/MOV/09-10/1' of attribute xmlns belonging to the node 'IRenvelope' with the value 'http://www.govtalk.gov.uk/taxation/PAYE/MOV/10-11/1'
So the output of the mapping should be:
<?xml version="1.0" encoding="UTF-8"?>
<GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
<EnvelopeVersion>2.0</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>IR-PAYE-MOV</Class>
<Qualifier>request</Qualifier>
<Function>submit</Function>
<CorrelationID/>
<Transformation>XML</Transformation>
<GatewayTimestamp/>
</MessageDetails>
<SenderDetails>
<IDAuthentication>
<SenderID>isv142</SenderID>
<Authentication>
<Method>MD5</Method>
<Value>1L2xFE8WqHHI5iVMGhixAg==</Value>
</Authentication>
</IDAuthentication>
</SenderDetails>
</Header>
<GovTalkDetails>
<Keys>
<Key Type="TaxOfficeNumber">123</Key>
<Key Type="TaxOfficeReference">MD345</Key>
</Keys>
<ChannelRouting>
<Channel>
<URI>0142</URI>
</Channel>
</ChannelRouting>
</GovTalkDetails>
<Body>
<IRenvelope xmlns="http://www.govtalk.gov.uk/taxation/PAYE/MOV/10-11/1">
<IRheader>
<Keys>
<Key Type="TaxOfficeNumber">123</Key>
<Key Type="TaxOfficeReference">MD345</Key>
</Keys>
<PeriodEnd>2009-09-29</PeriodEnd>
<DefaultCurrency>GBP</DefaultCurrency>
<IRmark Type="generic">03Bfkipk6UDWSXLj77ObBVoK894=</IRmark>
<Sender>Company</Sender>
</IRheader>
<InYearMovements>
<EmployerName>form p60</EmployerName>
<P46 Statement="A">
<Name>
<Fore>Smith</Fore>
<Sur>John</Sur>
</Name>
<Address>
<Line>Sterling Residency</Line>
<Line>Gehde</Line>
<Line>Hedge End</Line>
<Line>Southampton</Line>
<PostCode>12345678</PostCode>
</Address>
<WorksNumber>20090030</WorksNumber>
<NINO>NP258719D</NINO>
<BirthDate>1985-07-11</BirthDate>
<Gender>male</Gender>
<StartDate>2009-04-20</StartDate>
<TaxCodeInUse>647L</TaxCodeInUse>
</P46>
</InYearMovements>
</IRenvelope>
</Body>
</GovTalkMessage>
Thanks & Regards,
Aditi Naik
Hi,
You get name of an attribute by this code
<xsl:for-each select="@*">
<xsl:text>Value of </xsl:text>
<xsl:value-of select="name(.)"/>
<xsl:text> is </xsl:text><xsl:value-of select="."/>
</xsl:for-each>
Change value by providing new value in <xsl:value-of select="."/>
Regards
suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.