Solved

What XSD format is this

Posted on 2015-01-15
2
103 Views
Last Modified: 2015-01-16
I have the following type

  <xs:simpleType name="MoneyType">

    <xs:restriction base="xs:string">

      <xs:pattern value="\p{Nd}+(\.\p{Nd}\p{Nd})" />

    </xs:restriction>

  </xs:simpleType>

Open in new window


I use this for numeric fields

When I try to aggregate a large number of fields into a field with this structure, ti fails

Is there a better specification?

Thanks
0
Comment
Question by:Anthony Lucia
2 Comments
 
LVL 23

Accepted Solution

by:
Michael74 earned 250 total points
ID: 40552267
Try this for currency

<xsd:simpleType name="money">
      <xsd:restriction base="xsd:decimal">
         <xsd:fractionDigits value="2"/>
      </xsd:restriction>
</xsd:simpleType>

Open in new window

http://www.java2s.com/Code/XML/XML-Schema/fractionDigitsformoneytype.htm
0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 250 total points
ID: 40552303
The issue you might be having with the type you are using is the base type
<xs:restriction base="xs:string">
you should not use strings if your aim is to do calculations, use decimal instead.
Note that I posted a similar reply in an earlier question of yours
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_28596088.html#a40547843
<xs:pattern value="\p{Nd}+(\.\p{Nd}\p{Nd})" />
is very similar to what I posted there
"\p{Nd}" is a regular expression indication for a decimal number... as is "\d",
consider the two equivalent, other than the base type
As I said in that other question, you would use the patern facet (one way to restrict the base type) if you need exactly 2 decimals as the fractional part

You are posting a number of questions, sometimes it is better to ask some extra information in an existing question, rather than starting yet another question that is hardly any different. We do give feedback even after you closed a question.
Try to really understand what we post before jumping to the next question... this forum will serve you as a better learning aid that way

Michael74's suggestion is not different from what I gave you in that other question
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_28596088.html#a40547824
fractionDigits serves as a limitation, not as an exact number
so
99.99 is OK
99.9 is OK too
99.999 is not OK
If that is sufficient restriction for your purposes, I recommend that way
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java syntax, or is it Selenium 6 39
Cisco ASA: Java web start no go, asdm launcher no go 3 57
Java Eclipse Loop 3 31
learn programming 8 68
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question