Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML pattern and C# dataset

Status
Not open for further replies.

majkinetor

Programmer
Feb 21, 2006
88
RS
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:pattern 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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top