Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0
This is the forum to discuss the Wrox book XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay; ISBN: 9780470192740
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 25th, 2013, 12:36 PM
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
Default Pass generate multiple XML documents to Java Method/Web Service

Hi, I have a requirement where the application receives updates in the form of XML from upstream and before sending it to the down stream client the XML needs to be validated and if there are any data issues, I need to generate two XML documents, one error XML to the upstream client and a second XML notification to the down stream client. I am keen on using result-document element but I cannot really create files. Is there way to pass the generated XML's to a Java method by using extensions or calling local jersey web service to post the XML from result-document.

I am trying to figure out if its a possibility or not.
Reply With Quote
  #2 (permalink)  
Old February 25th, 2013, 05:59 PM
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
Default

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

Code:
		<!--====To generate a separate xml, create variable containing XML== -->
		<xsl:variable name="noticeXML">
			<xsl:element name="Order">
                                <!-- Create the required attributes and elements -->
			</xsl:element>
		</xsl:variable>
                <!--========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.  
	}
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading and processing multiple xml documents mrfletch XSLT 0 March 11th, 2011 11:08 AM
About method of class in Web Service hueduongit .NET Web Services 5 December 11th, 2003 08:09 PM
Execute method of web service, about database? hueduongit .NET Web Services 3 December 3rd, 2003 02:18 AM
Object as parameter in a web service method evandro.paula .NET Web Services 3 October 14th, 2003 02:20 PM
Referencing multiple XML documents... qornboy XML 3 October 9th, 2003 09:40 AM



All times are GMT -4. The time now is 08:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.