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
Matt DawsonSubject: Adapter issues - Failng to Convert From XML to a fixed length text format
Author: Matt Dawson
Date: 29 Jun 2006 10:23 AM
Hi,

I've used the New\Convert to XML menu item to create INF10OTIS.conv (attached), which converts a fixed length field document to XML (sample in INF10OTIS-OTISTest.txt). This works fine, and I've been using the WYSIWYG XSLT editor to manipulate that without any issues.

My problem is when I want to 'round trip' data back to the fixed length format. According to the video tutorial/doco round tripping is possible, but when I try I get an error (03 Error.jpg) implying I can only convert to XML, not from. Other adapters such as CSV will allow Convert from XML, but not my fixed length field adapter.

I've even tried hacking demo.java in case it was an issue with the GUI only. I tried adjusting the 'two' section to reference my adapter instead of the CSV one - i.e.
...
input = (StreamSource) sff.resolve("x.xml", uriBase);
if (input==null)
throw new IOException("Unable to find 'x.xml' in " + uriBase);
output = (StreamResult) sff.outputStreamResolver("x.txt", uriBase);
if (output==null)
throw new IOException("Unable to create 'x.txt' in " + uriBase);
Converter fromXML = factory.newConvertFromXML("adapter:INF10OTIS.conv");
fromXML.convert(input, output);
input.getInputStream().close();
output.getOutputStream().close();
System.out.println("test 2 finished: x.xml -> x.txt");
...
Unfortunately I ended up with a similar error to that seen in the GUI:
...
test 1 finished: one.csv -> one.xml
Exception in thread "main" com.stylusstudio.converter.ConverterException: The adapter "Convert to XML" cannot convert from XML, it can only convert to XML.
at com.stylusstudio.converter.ConverterImpl.validateDirection(ConverterImpl.java:260)
...

Can anyone shed any light on how I can get this to work? I'm trying to hit a deadline less than 24 hours away and this is the last major roadblock to making it.

Thanks,
Matt

PS What I see in Enterprise 2006 r3 does look slightly different from the video describing EDI round tripping (see 01 Doco.jpg and 02 Actual.jpg), but I'm guessing that is just a minor difference due to the release.

Error message
ApplicationINF10OTIS.conv
Fixed length field adapter

Image01Doco.jpg
Documentation Adapter Dialog

Image02Actual.jpg
Actual Adapter Dialog

DocumentINF10OTIS-OTISTest.txt
Sample data

Postnext
Tony LavinioSubject: Adapter issues - Failng to Convert From XML to a fixed length text format
Author: Tony Lavinio
Date: 29 Jun 2006 11:35 AM
Convert-to-XML is named that because it only goes in one direction.
The reason, not that it helps you much, is that it is much easier to
convert from various formats to a standardized one than it is to specify
all of the details of the various target formats (e.g. leading spaces or
not, leading zeros or not, sign on left or right, use + or nothing for
positive,...).

You can use XSLT to write fixed-width data.
Use the substring function, and add spaces.
For example:
<xsl:value-of select="substring(concat($value, ' '), 1, 10)"/>

It might even be easier to define a variable called $space that contains
the most number of spaces you'll need.

I hope this helps.

Postnext
Matt DawsonSubject: Adapter issues - Failing to Convert From XML to a fixed length text format
Author: Matt Dawson
Date: 29 Jun 2006 05:29 PM
Originally Posted: 29 Jun 2006 05:26 PM
Hi Tony,

The outputting fixed length data solution will probably work, but I would have expected there to be something more automatic. All of the data lengths etc are already in the conv file - all that needs to happen is for them to be used. Now it sounds like I need to laboriously re-create all of that information I've already entered into your tool.

Another thing I noticed here is that the Convert XML ( http://www.stylusstudio.com/docs/v62/d_flatfileconversion10.html ) page shows that my .conv files should be directly accessible using this dialog. I have found no way to be able to achieve this, other than manually typing the adapter URL into the "Convert to XML" property. My adapter is part of my project, and also in the Stylus Studio Adapter directory so I've done everything I can think of to make this work. I included some screen shots demonstrating this in the original post.

While you made the flippant comment above about Convert-to-XML above, the products features, documentation and web site content imply this can be done:
- The deployment adapter FAQ ( http://www.stylusstudio.com/deployment/faq.html ) basically says it can be done. It classifies EDI and flat file adapters in exactly the same way, then separately states that the deployment adapters are bidirectional.
- Coverage of EDI round tripping shows "Convert to XML definitions" in the "Convert from XML" dialog, implying these can be used here.
- Both the built-in adapters and the "Convert to XML" wizard's resultant conv files are invoked using adapter URLs.
- I can select a conv file as my target document in the XSLT Mapper.
- Doco and web site content are rather sparse on topic of adapters and converting from XML, and also imply "convert to" adapters can be used in the "convert from" section.
So while you know what the product is capable of, those buying the product or trying to work out how to use it have to find out the hard way.

This is all rather disappointing, especially as this feature is one of the main reasons I chose Enterprise over Professional. Sounds now like that was money wasted.

Thanks,
Matt

Postnext
Matt DawsonSubject: Adapter issues - Failng to Convert From XML to a fixed length text format
Author: Matt Dawson
Date: 29 Jun 2006 05:44 PM
>The reason, not that it helps you much, is that it is much
>easier to convert from various formats
>to a standardized one than it is to specify
>all of the details of the various target formats (e.g.
>leading spaces or not, leading zeros or not,
>sign on left or right, use + or nothing for
>positive,...).

About this specific comment - I suggest a COBOL Copybook bi-directional adapter be added to the Enterprise product. The way COBOL operates combined with the copybook definition includes all of the necessary information for above, a huge number of mainframe apps use this format, and if you had one of these then I wouldn't have needed to post here!

Thanks,
Matt

Postnext
Tony LavinioSubject: Adapter issues - Failng to Convert From XML to a fixed length text format
Author: Tony Lavinio
Date: 30 Jun 2006 09:38 AM
We appreciate your comments; nothing was said to be 'flippant' but
straight-forward. We will review the documents in question because
there should be a distinction between the one-way and two-way adapters.
Also, which version are you running? The /v62/ documentation has been
superceded by documentation for the current version, which is more
complete.

We would very much like to make Convert-to-XML into Convert-to/from-XML.
The challenges are considerable, especially when it comes to thing like
recreating dates and certain other formats. But it is on our list of
things we'd like to seen done also.

Posttop
Matt DawsonSubject: Adapter issues - Failng to Convert From XML to a fixed length text format
Author: Matt Dawson
Date: 30 Jun 2006 09:58 AM
Hi Tony,

>We will review the documents in question because
>there should be a distinction between the one-way and
>two-way adapters. Also, which version are you
>running?

I'm using Enterprise 2006 r3, and have reviewed both the online and locally installed documentation.

>We would very much like to make Convert-to-XML into
>Convert-to/from-XML. The challenges are
>considerable, especially when it comes to thing like
>recreating dates and certain other formats. But it is on
>our list of things we'd like to seen done also.

Thanks for the update. I'd recommend trying to create a to/from COBOL copybook adapter first, as its a more achievable proposition and should have a fairly large target market.

I eventually 'bit the bullet' and wrote a stylesheet (attached) to convert your convert-to-XML .conv file format into a stylesheet that would output fixed format data. It obviously won't cater for every one of the situations you mentioned above, but it catered for my immediate needs and removed most of the drudge work.

Thanks,
Matt


Applicationconv-to-xslt.xsl
Conv to XSLT - stylesheet generator

 
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.