Need help for xml schema

  • Thread starter Thread starter 955
  • Start date Start date
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?
 
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
 
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
 
Back
Top