Subject:datadirect coverter result differs from Stylus Studio Author:Jon Roberts Date:01 Aug 2008 07:18 AM
I have been using Stylus Studio to convert EDIFACT messages into XML. I open the file using the converter (converter:EDI:chr=REPLACE:invalid=TAB) and then apply an XSL transform to give me a resulting XML file I can import into my database.
All has been working well, but now I have just bought the DataDirect XML converters for dot.net to automate the process.
If I take the same EDIFACT EDI file that works in Stylus Studio and apply the following code:
factory = New ConverterFactory()
toXml = factory.CreateConvertToXml("converter:EDI:chr=REPLACE:invalid=TAB")
toXml.Convert(New UriSource(FileName), New UriResult(XMLFileName))
When I then try to use the resulting XML file as the source from my XSL in Stylus Studio, I get the following message:
Error Reported by XML Parser: Document Root Element is Missing
When I jump to location, it is the first line of the file, which is:
<?xml version="1.0" encoding="utf-8"?>
<EDIFACT>
I believe there is a rogue character at the end of the first line because if I delete this whitespace in stylus studio & recreate it (new line) then save and re-apply the XSL, then all works OK.
Subject:datadirect coverter result differs from Stylus Studio Author:Jon Roberts Date:02 Aug 2008 05:27 AM
Hi Ivan,
Since posting this message, I have been able to raise a support query with DataDirect. I am happy to send you full details of the error too, if you'd like to see it - otherwise I'll post back as & when I get an answer from them.
Subject:datadirect coverter result differs from Stylus Studio Author:Jon Roberts Date:06 Aug 2008 04:29 AM
Problem solved. Here's advice from DataDirect Support:
///
What's probably happening is that the extra white space that the .Net serializer is emitting is getting included in the value of the elements.
There are two solutions:
1. [Harder] Change all of the [x = 'y'] predicates to be something like [normalize-space(x) = 'y'].
2. [Easier] Add decode=no and field=no to the EDI URI specification.
These will turn off the addition of comments in the EDI, and as a side-effect will suppress indentation. This will make the EDI smaller also and will speed up the transform.
///
I solved problem by changeing coverter to:
“EDI:chr=REPLACE:invalid=TAB:decode=no:field=no”