i want to transform this xml to another xml using xslt. i have use this code for transformation.
result = new XSLTProcessor(); result.importStylesheet(xsl); result = result.transformToDocument(xml);
this code working fine. but resultant xml doesn't contain <?xml version="1.0" encoding="UTF-8"?>
i intentionally removed <?xml version="1.0" encoding="UTF-8"?>
from input xml. xml:-
<rentalProperties> <property contact="1"> <type>House </type> <price>420</price> <address> <streetNo>1</streetNo> <street>Wavell Street</street> <suburb>Box Hill</suburb> <state>VIC</state> <zipcode>3128</zipcode> </address> <numberOfBedrooms>3</numberOfBedrooms> <numberOfBathrooms>1</numberOfBathrooms> <garage>1</garage> </property> </rentalProperties>
xsl:-
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="no" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="address"> <xsl:copy> <xsl:value-of select= "concat(streetNo, ' ', street, ',', suburb,',', state,', Australia') "/> </xsl:copy> </xsl:template> <xsl:template match="address/node()"/> </xsl:stylesheet>
i want to add <?xml version="1.0" encoding="UTF-8"?>
to transformed xml. is there any way to add using xslt or copy this tag to output xml.
please give any suggestion .
No comments:
Post a Comment