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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> - Stylus Studio - Registrar en o... (1)
-> + Stylus Studio - Registrar en o... (2)
-> + Can a pipeline send a file by ... (2)
-> + After Updateing WIN10 to WIN11... (12)
-> + Where do I add the custom java... (3)
-> + Where is the Diagram tab? (5)
-> + Applying XSLT to Word DOCX/XML (2)
-> - CSV conversion via ConvertToXM... (1)
-> + Text symbols in SS not same as... (4)
-> + Exposing xquery as webservice ... (6)
-> + Syntax Identifier (2)
-> + Saving a Converted XML as an X... (5)
-> + Output document cannot be pars... (4)
-> - Archiving output from conversi... (1)
-> + EDIFACT guideline from Stylus ... (3)
-> + CSV file putting all the data ... (5)
-> + Can't install Home version 64b... (5)
-> + presale - Can I covers this sc... (5)
-> + Problem with UNB (5)
-> + Splitting EDIFACT files pipeli... (4)
-- [1-20] [21-40] [41-60] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Alex SmirnovSubject: Java XMLPipeline result to string
Author: Alex Smirnov
Date: 09 Aug 2011 10:28 AM
Hello!

I generate java code from XMLPipeline, and I get something like that

public boolean init() throws Exception {

// Create all the objects required for the pipeline
convertToXML = new ConvertToXML("Convert to XML", getEnvironment());
convertToXML.setAdapter("edi:decode=no:field=no:tbl=no:typ=no:chr=UNOE");
XSLTOperator = new XSLTOperation("XSLT operator", ContentType.UNKNOWN, getEnvironment());

edge_2 = new EdgeImpl("edge_2", getEnvironment(), DataType.NODE, DataType.DOCUMENT);

// Connect all the operation objects with edge objects.
convertToXML.setInputUrl("edi__1", DataType.NONE);
convertToXML.addOutputEdge(edge_2);
XSLTOperator.setScriptUrl("ORDERS.xsl");
XSLTOperator.addInputEdge(edge_2);
XSLTOperator.setOutputUrl("result.xml", DataType.ANY);


return true;
}

I this case, I can set only path to input and output file.

But I need set java String with input file content and get result to string.

String In = "UNB+UNOE:3+....UNZ+1+1'";
String Out = null;
and for example:
convertToXML.setInputUrl(In, DataType.NONE);
XSLTOperator.setOutputUrl(Out, DataType.ANY);

Please help me with this

Postnext
Ivan PedruzziSubject: Java XMLPipeline result to string
Author: Ivan Pedruzzi
Date: 09 Aug 2011 07:33 PM
Hi Alex,

Which Stylus Studio version are you running?

Thanks
Ivan

Postnext
Alex SmirnovSubject: Java XMLPipeline result to string
Author: Alex Smirnov
Date: 10 Aug 2011 12:16 AM
Originally Posted: 10 Aug 2011 12:11 AM
Stylus Studio Build 1540
XMLConverters 5.0.0.1540

Postnext
Alex SmirnovSubject: Java XMLPipeline result to string
Author: Alex Smirnov
Date: 11 Aug 2011 04:56 AM
Ivan, can you help me?

Postnext
Ivan PedruzziSubject: Java XMLPipeline result to string
Author: Ivan Pedruzzi
Date: 11 Aug 2011 01:11 PM
Sorry if it took too long.

You can use the following to bind a string as input

convertToXML.setInputUrl(In, DataType.NONE);

Binding the output requires more digging using the XML runtime API.

If you check "Generate inline code" in the java code generation dialog, then you can use the full XML Convert API that is well documented.

Hope this helps
Ivan

Posttop
Alex SmirnovSubject: Java XMLPipeline result to string
Author: Alex Smirnov
Date: 13 Aug 2011 04:55 AM
Ivan thanks! Its help!

I use it with Redis to get body and write result.

My code:
public void run() throws Exception {

ConverterFactory CFactory = new ConverterFactory();
ConverterResolver Resolver = CFactory.newResolver();
TransformerFactory TFactory = TransformerFactory.newInstance();
TFactory.setURIResolver(Resolver);

String ConverterOpt = "edi:decode=no:field=no:tbl=no:typ=no:chr=UNOE";

TransformerHandler XSLTOperator = ((SAXTransformerFactory)TFactory).newTransformerHandler(new StreamSource("ORDERS.xsl"));

String InputDocBody = redis.lpop("tests");
StreamSource StSource = new StreamSource();
StSource.setInputStream(new ByteArrayInputStream(InputDocBody.getBytes()));

ByteArrayOutputStream BAOS = new ByteArrayOutputStream();
StreamResult StResult = new StreamResult(BAOS);
XSLTOperator.setResult(StResult);

CFactory.newConvertToXML(ConverterOpt).convert(StSource, new SAXResult(XSLTOperator));

String OutputDocBody = new String(BAOS.toByteArray(), "UTF-8");
redis.lpush("parser", OutputDocBody);
}

   
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.