What happens when you use something like xsd:fractionDigits in your 
restriction. It may be easier than using a regex pattern.

http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
Please let us know what happens,
-Jacobd

-----Original Message-----
From: Niklas Koponen [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 25, 2005 6:47 AM
To: [email protected]
Subject: Writing double from java-code to XML

Hi!

I am using xmlbeans-2.0.0.

I have the following problem. I have defined a type in my schema which
restricts that a double should have two decimals.

<xsd:simpleType name="kilometersType">
        <xsd:restriction base="xsd:double">
                <xsd:pattern value="\d{0,4}[\.]\d{2}"/>
        </xsd:restriction>
</xsd:simpleType>

I have generated the java files using scomp.

Now I set the value of the element that is of type workinghoursType in
java code.

expenses.setKilometers(1.20);

When I try to validate the element using validate() the validation
fails. This is because the element that is supposed to contain two
decimals contains only one decimal.

When I write the object to XML (without validating) it writes the data
there as 1.20.

The writing works as expected but the validating fails. This is
problematic because I need to validate before writing to file.

Am I missing something important. I have skimmed through the javadoc and
the mailinglist archive through eyebrowse but haven't found an answer.

Is this a bug in xmlbeans?

-Niklas
-- 
Niklas Koponen, [EMAIL PROTECTED], +358 40 757 1459
Fifth ELement Oy / GISnet Solutions Oy
Tietäjäntie 2, FIN-02130 Espoo


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to