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
Roel van der HoevenSubject: Another EDI problem
Author: Roel van der Hoeven
Date: 27 May 2009 09:20 AM
I got most my issues addressed now, but I got one left that keeps bugging me. IMO there has to be an easy solution for this one:

I have a segment which exists out of some elements:

<NAD>
<NAD01-3035ElementType>AG</NAD01-3035ElementType>
<NAD02-C082-ACompositeType>
<NAD0201-3039ElementType>
{
$input/xlGscarg/xlCustomsEoriNumberTerminal/text()
}
</NAD0201-3039ElementType>
</NAD02-C082-ACompositeType>
</NAD>

As you can see the top element contains the value AG. I have my output converter set to:
converter:EDI:val=yes:typ=yes:clean=both:rtrim=yes:auto=yes:user=file://path/to/dictionary.sef?file:///path/to/output.edi

In the SEF file the NAD@3035 is mandatory.

The XML output (before going to EDI) reads:

<NAD>
<NAD01-3035ElementType/>
<NAD02-C082-ACompositeType>
<NAD0201-3039ElementType>39000</NAD0201-3039ElementType>
</NAD02-C082-ACompositeType>
</NAD>

As you can see, the 3035 element has no value. However the output EDI reads:
NAD+ +39000'

If I remove the 3035 I get an error that a mandatory element is missing (as I would expect), but with the empty sequence it feeds a whitespace, which ommits the error from being thrown.

Any thoughts on this?

Postnext
(Deleted User) Subject: Another EDI problem
Author: (Deleted User)
Date: 27 May 2009 12:37 PM
Roel,

Our defined behavior is that elements like <NAD01-3035ElementType/> will generate a data value. If you want no value, you need to completely eliminate the element.

You could do that with an xquery or xslt.

Clyde

Postnext
Roel van der HoevenSubject: Another EDI problem
Author: Roel van der Hoeven
Date: 28 May 2009 01:48 AM
Is there no way to strip empty tags from the output? I would expect something like the converter setting clean (or something simular).

Postnext
Roel van der HoevenSubject: Another EDI problem
Author: Roel van der Hoeven
Date: 29 May 2009 02:43 AM
This will generate a lot of work for me, if I have to check for these things EVERY (composite)element. Also this has to have an effect on performance since there will be tons of checking in the entire code.

Postnext
Tony LavinioSubject: Another EDI problem
Author: Tony Lavinio
Date: 10 Aug 2009 03:32 PM
Well, we did some research on this, and here is the definitive answer.

If the EDI element is marked as mandatory and there is an XML element
with empty content, in order to keep from causing an error, we will
pad the element with a single space.

In this case, if the NAD01 element were changed to "optional," as is
appropriate since "" is now a valid value, then the EDI serializer
will write out

<NAD>
<NAD01/>
<NAD02>
<NAD0201><!--3039: Party identifier-->39000</NAD0201>
</NAD02>
</NAD>

as

NAD++39000'

But exactly the same XML will, if NAD01 is mandatory, generate this:

NAD+ +39000'

so that the EDI is valid.

So you do have control, based on the settings in the SEF file.

Postnext
Roel van der HoevenSubject: Another EDI problem
Author: Roel van der Hoeven
Date: 11 Aug 2009 01:36 AM
To be honest, the whole idea of mandatory fields getting a whitespace to ommit errors does not feel like correct behaviour. If this is the case; why have mandatory elements?

Posttop
Tony LavinioSubject: Another EDI problem
Author: Tony Lavinio
Date: 11 Aug 2009 10:11 AM
If there is an element present in the XML input AND the field is
mandatory, then there is an element forced into the output.

if there is no element present in the XML input OR the field is
optional and empty, then nothing is forced to the output.

This gives the writer of the XML the most control over the generated
EDI.

The alternative would be to throw an error on empty XML elements
writing to mandatory fields, but based on experience with users,
we settled on the current behavior.

 
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.