majkinetor
Programmer
Hi there
I am trying to restrict some string via pattern, but for some reason it doesn't validate.
This is the code I tried:
<xs:simpleType name="tTenDigits" > <xs:restriction base="xs:string">
<xs
attern value="[0-9]{10}"/>
</xs:restriction> </xs:simpleType>
<xs:element name="root"><xs:complexType><xs:sequence>
<xs:element name="Number" type="tTenDigits" minOccurs="1" maxOccurs="1"/>
</xs:sequence></xs:complexType></xs:element>
I load this code in c# via:
try
{
ds.ReadXmlSchema(schema);
ds.ReadXml(fileName);
}
this is my XML
<root>
<Number>bla bla </Number>
</root>
No exception is thrown. Does anybody know why ? When I use standard XML data types validation is working but
not with regular expression. Is anybody aware of some isue between xml <pattern> and c# datasets ?
Also, is there anyway to replace sentence minOccurs="1" maxOccurs="1" with something shorter.
I need this sentence for every other element so can I put only those two keywords in some kind of reference
TIA.
I am trying to restrict some string via pattern, but for some reason it doesn't validate.
This is the code I tried:
<xs:simpleType name="tTenDigits" > <xs:restriction base="xs:string">
<xs
</xs:restriction> </xs:simpleType>
<xs:element name="root"><xs:complexType><xs:sequence>
<xs:element name="Number" type="tTenDigits" minOccurs="1" maxOccurs="1"/>
</xs:sequence></xs:complexType></xs:element>
I load this code in c# via:
try
{
ds.ReadXmlSchema(schema);
ds.ReadXml(fileName);
}
this is my XML
<root>
<Number>bla bla </Number>
</root>
No exception is thrown. Does anybody know why ? When I use standard XML data types validation is working but
not with regular expression. Is anybody aware of some isue between xml <pattern> and c# datasets ?
Also, is there anyway to replace sentence minOccurs="1" maxOccurs="1" with something shorter.
I need this sentence for every other element so can I put only those two keywords in some kind of reference
TIA.