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
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext 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);
}

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.