setting default values for empty nodes

Posted by azathoth on Stack Overflow See other posts from Stack Overflow or by azathoth
Published on 2010-05-07T19:48:23Z Indexed on 2010/05/07 20:18 UTC
Read the original article Hit count: 133

Filed under:
|
|
|
|

Hello all

I need to transform a piece of XML, so that the value of every node in a list I specify is set to "0"

for example:

<contract>
 <customerName>foo</customerName>
 <contractID />
 <customerID>912</customerID>
 <countryCode/>
 <cityCode>7823</cityCode>
</contract>

would be transformed into

<contract>
 <customerName>foo</customerName>
 <contractID>0</contractID>
 <customerID>912</customerID>
 <countryCode>0</contractID>
 <cityCode>7823</cityCode>
</contract>

How can this be accomplished using XSLT? I have tried some examples I found but none works as expected

Thank you

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xslt