Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What XSD format is this

Posted on 2015-01-15
2
Medium Priority
?
106 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Michael Fowler earned 1000 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 1000 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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

704 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