View Single Post
  #2 (permalink)  
Old February 25th, 2013, 06:59 PM
Sandeep_Kumar Sandeep_Kumar is offline
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Was able to figure out alternate solution using XSLT 1.0. But still looking for any better solutions.

		<!--====To generate a separate xml, create variable containing XML== -->
		<xsl:variable name="noticeXML">
			<xsl:element name="Order">
                                <!-- Create the required attributes and elements -->
                <!--========Pass the variable to Java method===-->
		<xsl:value-of select="util:toXML($noticeXML)"/>

  	//Java method to convert received 'Node' to stand alone XML and send to Client 
	public static synchronized void toXML(Node xml) throws TransformerException
		StringWriter writer = new StringWriter();
	    Transformer transformer = TransformerFactory.newInstance().newTransformer();
	    //Do not set declaration as its indicating the XML is not stand alone
	    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
	    transformer.transform(new DOMSource(xml), new StreamResult(writer));
	    String receivedxml = writer.toString();
	    //Send the message to the required client.