Need help for xml schema

9

955

I had develop an xml schema for checking type of data
as
<xs:simpleType name="O_FMExchangeRate" xmlns:xs="http://
www.w3.org/2001/XMLSchema">
<xs:restriction base="xs:float">
<xs:minExclusive value="0.0000001"/>
<xs:pattern value="d(0)|\d{1,5}|\d{1,5}\.\d{1,7}|\.\d{1,7}|
\d{1,5}\.|\+\d{1,5}|\+\d{1,5}\.\d{1,7}|\+\.\d{1,7}|\+\d{1,5}\."/>
</xs:restriction>
</xs:simpleType>

a problem is that I would like to have this field as an optional
field
but Tag pattern ... d(0)|\ (as above) didn't help me on that.
do you have any suggestion?
 
M

Marc Gravell

did you mean \d{0} instead of d(0) [a literal]?
you might also be able to just use nothing - IIRC, the xsd pattern
essentially becomes "^(pattern)$" in a regex, so comparing in C#, both
the following seem to work OK:
@"^(\d{0}|(\d{2}))$"
@"^(|(\d{2}))$"

Marc
 
M

Marc Gravell

Note I was deliberately using a simpler pattern for testing!

And for the pedants, yes, d(0) is the literal d0 with a capture group,
not the literal d(0) as my other post might have suggested.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top