GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes [XSL] add attribute into existing XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "[XSL] add attribute into existing XML" Watch "[XSL] add attribute into existing XML" New topic
Author

[XSL] add attribute into existing XML

Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
I need to add the attribute "version" in the wap-provisioningdoc node. How can I do this using the following XSL? This XSL gets rid of the node characteristic of type SETTINGSET.

current XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[not(@type='SETTINGSET')]"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>



Input XML
<wap-provisioningdoc>
<characteristic type="SETTINGSET">
<parm name="NAME" value="NOKIA-6170"/>
<parm name="STATE" value="2"/>
<parm name="SERVICE" value="WAPGPRS"/>
</characteristic>
<characteristic type="PXLOGICAL">
<parm name="TRUST"/>
<parm name="MASTER"/>
<parm name="STARTPAGE" value="http://www.bank.com/startpage.wml"/>
</characteristic>
<characteristic type="NAPDEF1">
<parm name="INTERNET"/>
</characteristic>
<characteristic type="APPLICATION">
<characteristic type="RESOURCE">
<parm name="STARTPAGE"/>
</characteristic>
</characteristic>
<characteristic type="ACCESS">
<parm name="RULE"/>
</characteristic>
</wap-provisioningdoc>


Result expected:
<wap-provisioningdoc version="1.0">
<characteristic type="PXLOGICAL">
<parm name="TRUST"/>
<parm name="MASTER"/>
<parm name="STARTPAGE" value="http://www.bank.com/startpage.wml"/>
</characteristic>
<characteristic type="NAPDEF1">
<parm name="INTERNET"/>
</characteristic>
<characteristic type="APPLICATION">
<characteristic type="RESOURCE">
<parm name="STARTPAGE"/>
</characteristic>
</characteristic>
<characteristic type="ACCESS">
<parm name="RULE"/>
</characteristic>
</wap-provisioningdoc>


Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [XSL] add attribute into existing XML