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 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion
Author: Bruno F
Date: 20 Oct 2005 06:00 AM
Dear all,

I'm currently using the wizard to convert XML schemata to XML instances.

Is there any way to avoid having whitespaces in number data types with explicit format (e.g. long, decimal)?

The whitespaces appear when the actual number is not using up the "totaldigits" slots.
Imho these whitespaces should not exist or be optional.


Example:
XSD:
<xs:element name="Numberfield">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
<xs:totalDigits value="11"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

XML-Output:<br>
<Numberfield>__blank_1.23</Numberfield>

I added the "__blank_" cause excess blanks seem to be filtered by this forum :)

Expected Output:<br>
<Numberfield>1.23</Numberfield>



Thank you for any help,
best regards,
Bruno

Postnext
(Deleted User) Subject: Unwanted blanks in XML schema / XSD to XML conversion
Author: (Deleted User)
Date: 20 Oct 2005 10:10 AM
We don't have an option to turn off number padding.
Can I ask you why you think this is a problem?
I was under impression that this will give user
an idea how many digits he/she can use when replacing
sample number with some actual value in generated XML.
I can of cause change it to fill unused slots with "0" or "1"
instead of spaces...

Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion
Author: Bruno F
Date: 20 Oct 2005 11:50 AM
Its a formal requirement on how we test our software product.
For the test we need synthetic data that looks like real data - which won't feature padding.

An option would be really nice...

Cheers,
Bruno

Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion
Author: Bruno F
Date: 09 Jan 2006 10:57 AM
Dear Yuriy,

I see that in StylusStudio 6 you introduced the padding with zeroes :)

One case might be an issue - some validation engines dont accept what StylusStudio generates:

Example XSD:

<xs:schema xmlns="Schemas/Art100/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="Schemas/Art100/1.0" elementFormDefault="qualified">
<xs:element name="Art">
<xs:complexType>
<xs:sequence>
<xs:element name="Top" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Sub" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:long">
<xs:totalDigits value="12"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Generated XML:
<p1:Top>
<p1:Sub>0000727379969</p1:Sub>
</p1:Top>

The proble is that the resulting number has 13 digits, whereas the restriction was set to 12 digits.
Some engines ignore the leading zeros, some don't and report an error.

Anyway, I think that padding should not put too much zeros or is there a reason that this is desired functionality?

It would be really nice to have an "Option"-Switch for padding anyways.

Thx for an answer & kind regards,
Bruno

Postnext
Tony LavinioSubject: Unwanted blanks in XML schema / XSD to XML conversion
Author: Tony Lavinio
Date: 09 Jan 2006 12:02 PM
We'll look into it, however, our behavior is completely conformant,
so it is doubtful our behaviour will change.

http://www.w3.org/TR/xmlschema-2/#dt-totalDigits says (especially the
last sentence)

"The term totalDigits is chosen to reflect the fact that it restricts
the ·value space· to those values that can be represented lexically
using at most totalDigits digits. Note that it does not restrict the
·lexical space· directly; a lexical representation that adds additional
leading zero digits or trailing fractional zero digits is still
permitted."

Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion
Author: Bruno F
Date: 09 Jan 2006 01:30 PM
Thanks for the quick reply, Tony.

I agree there might be more critical issues to look into :) ... I just wanted to remark that the number padding in this case fails to deliver the proposed functionality. According to Yuriy, the padding was introduced to allow users to quickly edit the XML instance without looking into the XSD.

Cheers,
Bruno

Postnext
Tony LavinioSubject: Unwanted blanks in XML schema / XSD to XML conversion
Author: Tony Lavinio
Date: 09 Jan 2006 01:58 PM
I'll make a note in the issues database, and we'll just remove
some of those extra zeros from Yuriy's paycheck also :).

Seriously, this has been noted in our database as a potential
to-do item.

Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion (padding)
Author: Bruno F
Date: 10 Jan 2006 05:19 AM
*rofl*

sounds good... especially because I just came across a couple of issues on which I would greatly appreciate your opinion.

I'm still concerned with the "XML Schema to XML"-Functionality.

Issues:
- Generated XML is not valid when mutliple facets apply (esp. a regular expression pattern and minInclusive/maxInclusive)
- Generated XML depends on the order of restriction facets (below cases put the pattern first and last, respectively)
- Number padding is not working for these cases (minor issue).

I am currently working on a project where we have to deal with a large amount of complex schemata featuring stuff like you see below. I need to regularly create XML instances...

Here are XSD Samples and XML generated by StylusStudio. Both are reported invalid by StylusStudio.

Sample XSD 1:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="Schemas/Typ9002/1.0" elementFormDefault="qualified" targetNamespace="Schemas/Typ9002/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Type">
<xs:complexType>
<xs:sequence>
<xs:element name="StandardData">
<xs:complexType>
<xs:sequence>
<xs:element name="A">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="(-)?\d{1,16}\.\d{2}" />
<xs:fractionDigits value="2" />
<xs:totalDigits value="18" />
<xs:maxInclusive value="1000000000000000" />
<xs:minInclusive value="-1000000000000000" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="B">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="(-)?\d{1,16}\.\d{2}" />
<xs:fractionDigits value="2" />
<xs:totalDigits value="18" />
<xs:maxInclusive value="10000000000000000" />
<xs:minInclusive value="-10000000000000000" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="C">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="(-)?\d{1,9}\.\d{2}" />
<xs:fractionDigits value="2" />
<xs:totalDigits value="11" />
<xs:maxInclusive value="999999.99" />
<xs:minInclusive value="0.01" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="D">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="(-)?\d{1,9}\.\d{2}" />
<xs:fractionDigits value="2" />
<xs:totalDigits value="11" />
<xs:maxInclusive value="9999.99" />
<xs:minInclusive value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="E">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="(-)?\d{1,9}\.\d{2}" />
<xs:fractionDigits value="2" />
<xs:totalDigits value="11" />
<xs:maxInclusive value="999999999.99" />
<xs:minInclusive value="-999999999.99" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="F">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="36" />
<xs:maxLength value="36" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="G">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="978" />
<xs:enumeration value="000" />
<xs:enumeration value="978" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Generated XML 1:
<?xml version="1.0"?>
<p1:Type xmlns:p1="Schemas/Typ9002/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Schemas/Typ9002/1.0 file:///c:/AUTOMATION/VerarbeitungsSet/_issues/Issues.xsd">
<p1:StandardData>
<p1:A>-1000000000000000</p1:A>
<p1:B>-10000000000000000</p1:B>
<p1:C>0.01</p1:C>
<p1:D>0</p1:D>
<p1:E>-999999999.99</p1:E>
<p1:F>stringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p1:F>
<p1:G>978</p1:G>
</p1:StandardData>
</p1:Type>



Sample XSD 2:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="Schemas/Typ9002/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="Schemas/Typ9002/1.0" elementFormDefault="qualified">
<xs:element name="Type">
<xs:complexType>
<xs:sequence>
<xs:element name="StandardData">
<xs:complexType>
<xs:sequence>
<xs:element name="A">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
<xs:totalDigits value="18"/>
<xs:maxInclusive value="1000000000000000"/>
<xs:minInclusive value="-1000000000000000"/>
<xs:pattern value="(-)?\d{1,16}\.\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="B">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
<xs:totalDigits value="18"/>
<xs:maxInclusive value="10000000000000000"/>
<xs:minInclusive value="-10000000000000000"/>
<xs:pattern value="(-)?\d{1,16}\.\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="C">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
<xs:totalDigits value="11"/>
<xs:maxInclusive value="999999.99"/>
<xs:minInclusive value="0.01"/>
<xs:pattern value="(-)?\d{1,9}\.\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="D">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
<xs:totalDigits value="11"/>
<xs:maxInclusive value="9999.99"/>
<xs:minInclusive value="0"/>
<xs:pattern value="(-)?\d{1,9}\.\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="E">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2"/>
<xs:totalDigits value="11"/>
<xs:maxInclusive value="999999999.99"/>
<xs:minInclusive value="-999999999.99"/>
<xs:pattern value="(-)?\d{1,9}\.\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="F">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="36"/>
<xs:maxLength value="36"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="G" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="978"/>
<xs:enumeration value="000"/>
<xs:enumeration value="978"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Generated XML 2:
<?xml version="1.0"?>
<p1:Type xmlns:p1="Schemas/Typ9002/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Schemas/Typ9002/1.0 file:///c:/AUTOMATION/VerarbeitungsSet/_issues/Issues_2.xsd">
<p1:StandardData>
<p1:A>-1.23</p1:A>
<p1:B>-1.23</p1:B>
<p1:C>-1.23</p1:C>
<p1:D>-1.23</p1:D>
<p1:E>-1.23</p1:E>
<p1:F>stringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p1:F>
<p1:G>978</p1:G>
</p1:StandardData>
</p1:Type>

Postnext
Tony LavinioSubject: Unwanted blanks in XML schema / XSD to XML conversion (padding)
Author: Tony Lavinio
Date: 10 Jan 2006 08:53 AM
Thank you for the testcases. We'll take a look right away.

Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion (padding)
Author: Bruno F
Date: 17 Jan 2006 10:07 AM
Hi Tony,

hopefully you found the input helpful.
will there be an update to the XML instance generation?
That functionality was the main reason we bought StylusStudio... on my recommendation, since its already doing better on regular expressions than *thenamethatmaynotbespoken* :)

Kind regards,
Bruno

Postnext
Tony LavinioSubject: Unwanted blanks in XML schema / XSD to XML conversion (padding)
Author: Tony Lavinio
Date: 17 Jan 2006 11:28 AM
First, the spec says we can add as many zeros as we want.
But we want to be nice and play well with others, to we
try to generate the same number as the totalDigits=.

In your case, there was a very interesting interaction going
on. When we generated the sample number, you asked for 13
digits. The datatype was integer, and the largest positive
value that an integer can hold is 12 digits. If you go bigger,
you wrap (due to twos-complements math) to negatives. And
that's what happened. The internal function saw that the output
was 13 characters (12 digits plus the '-') and formatted the
output field to 13 spaces.

The good news is that this will be changed in the next release.
The bad news is that since we are well within the explicit text
of the specification, this will not be backported into a patch
for the current release.

Does this help at all?

Postnext
Bruno FSubject: Unwanted blanks in XML schema / XSD to XML conversion (padding)
Author: Bruno F
Date: 17 Jan 2006 11:42 AM
So you're saying no patch to StylusStudio Professional 2006 considering the "too much zeroes" issues. This one is minor...I can live with it :)

But what about the two sample XSDs and the related issues? StylusStudio isnt producing valid XML for these... this might be a more serious gap in functionality (not to say a bug). I'd call it the "multiple restriction facets" issue.
Or am I off-topic here and we should move the discussion somewhere else *g*.

Regards,
Bruno

Posttop
Tony LavinioSubject: Unwanted blanks in XML schema / XSD to XML conversion (padding)
Author: Tony Lavinio
Date: 17 Jan 2006 02:42 PM
It turns out that there is no algorithm that will guarantee that the
generated XML will match the schema that will run in predictable time.

Our algorithm is highly tuned, but unless we start writing all sorts
of special-case code for specific situations, it's unlikely that it
will improve to the point where we can guarantee that for any valid
XSD we will generate a perfectly valid XML file. We're also pretty
sure that no one else can guarantee it in all cases.

We are proud of the generator we have; we feel it's about as good as
we or anyone else is likely to make in general (there may be specific
cases where another works better).

Just as a simple example, it doesn't take too much effort to build a
regular expression pattern facet that will take hours of iteration to
build a string that will pass.

There comes a point where nothing beats a sample of real data, and you
are probably right at that point.

Sorry we couldn't do more; at least the padding issue will be solved
in the next release (although I still do not admit guilt there ;) ).

 
Topic Page 1 2 3 4 5 6 7 8 9 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.