XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
andre goldiSubject: Using Generated Java-Code...
Author: andre goldi
Date: 15 Aug 2011 08:46 AM
Originally Posted: 15 Aug 2011 08:42 AM
Having generated Java from XQuery (Scenario) I now have the problem that I receive the EDI-File as a Stream and not as a File. So how can I
change the code using a Stream instead of a File/the URL of the File?

The problem is that the code uses the following:

String inputUrl ="path";
StreamSource source = (StreamSource)resolver.resolve(inputUrl, null);

Of course I could write the Stream somewhere in a File and then read the path but I would like to have another solution.


UnknownUntitled1.java

Postnext
Ivan PedruzziSubject: Using Generated Java-Code...
Author: Ivan Pedruzzi
Date: 15 Aug 2011 12:07 PM

Use the following code to bind an arbitrary EDI input stream. Replace FileInputStream with your own stream object

ConverterFactory factory = new ConverterFactory();
ConvertToXML toXml = factory.newConvertToXML("EDI");
XMLStreamReader source = toXml.getXMLStreamReader(new StreamSource(new FileInputStream("order.edi")));



// Bind source as context item to the XQ Expression
xqExpr.bindDocument(XQConstants.CONTEXT_ITEM, source, null);

Hope this helps
Ivan Pedruzzi

Postnext
andre goldiSubject: Using Generated Java-Code...
Author: andre goldi
Date: 16 Aug 2011 03:44 AM
I will try. But maybe a little more detail to this:
The "inputUrl" contains the incoming EDI-File and the ".sef"-File generated by Stylus Studio so it looks like this:

String inputUrl = "converter:EDI:loopnames=yes:opt=yes:tbl=yes:user=file://c:PRICAT.sef?file:///c:PRICAT.edi";


The second part (after the "?") of this URL is my problem. I do not have this URL because I just get a Stream.

Postnext
Ivan PedruzziSubject: Using Generated Java-Code...
Author: Ivan Pedruzzi
Date: 16 Aug 2011 11:43 AM
The XML Converters API is very flexible, allowing to pass the SEF file as stream as well.

Here is the sample code revisited; again you can replace the FileInputStream with any InputStream implementation, doing so you are not forced to use the file system, for example you may have EDI data coming in as JMS messages and the SEF file stored in database.

Hope this helps
Ivan


ConverterFactory factory = new ConverterFactory();
ConvertToXML toXml = factory.newConvertToXML("converter:EDI:loopnames=yes:opt=yes:tbl=yes");
toXml.getConfiguration().setEDIExtension(new StreamSource(new FileInputStream("c:\\PRICAT.sef")));
XMLStreamReader source = toXml.getXMLStreamReader(new StreamSource(new FileInputStream("order.edi")));


Posttop
andre goldiSubject: Using Generated Java-Code...
Author: andre goldi
Date: 22 Aug 2011 11:12 AM
Many thanks again, this was also very helpful and I got it working.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.