Solved

Changes in XML Schema

Posted on 2006-11-01
5
227 Views
Last Modified: 2013-11-19
Hi, for the application, we have a field for bank account number, in which we would apply new validation e.g. modulus 11 to check if it's valid. Does anyone know if such validation can be applied to .XSD file? If so, can I add those codes for working out the validation like those in XSLT?

Here below is part of the schema. The current max length is set as 13.

<xsd:element name="bankNumber" minOccurs="0">
      <xsd:simpleType>
            <xsd:restriction base="xsd:string">
                  <xsd:pattern value="(\d{0,13})"/>
            </xsd:restriction>
      </xsd:simpleType>
</xsd:element>
0
Comment
Question by:manfredino
5 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 63 total points
Comment Utility
Hi manfredino,

There are just a limited number of facets that are applicable to simpleTypes in XSD
You have the pattern facet restricting the string type
That is about the most complex you can go
Typical facets are number of digits, maximum value, enumerations,...

If you can limit the set of allowed values eg 1, 12, 23, 34 etc. you can use enumeration

If you are more thinking of using XPath expressions such as "(substring-before(., '-') + substring-after(., '-')) mod 11 = 1"
for validating the checksum of your bank number
you have two options

- use XSLT for reporting wrong numbers
- use assertions in Schematron... that is a constraints schema language for XML, that can be used in combination with XSD
read about it here http://www.schematron.com/
and check if that is applicable in your situation

Cheers!

Geert
0
 

Author Comment

by:manfredino
Comment Utility
Hi Geert,

Thanks for your help. I ll take a look of schematron and see if we can apply on our schema.

Cheers,
Manfred
0
 
LVL 8

Assisted Solution

by:redpipe
redpipe earned 62 total points
Comment Utility
I am not a schematron specialist, but in spite of its vast possibilities I believe it is impossible (or at least not practical) to use xml-schema-validation for modulus 11. This is a process of calculating the weights of received numbers and adding a check digit. I would urge you to continue with your current format, and validate received messages against this schema first and proceed with checking the modulus 11 validation of the accountnumber (method in a class).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now