C# - Get part of XML to be validated by XSD using attribute value -


i need validate column values before inserting them in table. have written common xsd tables , xml looks this.

<root>   <table name="user">     <column>userid</column>     <column>name</column>     <column>roleid</column>   </table>   <table name="role">     <column>roleid</column>     <column>rolename</column>   </table> </root> 

and xsd this:

<xs:schema attributeformdefault="unqualified" elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema">   <xs:element name="root">     <xs:complextype>       <xs:sequence>         <xs:element name="table" maxoccurs="unbounded" minoccurs="1">           <xs:complextype>             <xs:sequence>               <xs:element type="xs:string" name="column" maxoccurs="unbounded" minoccurs="1"/>             </xs:sequence>             <xs:attribute type="xs:string" name="name" use="required"/>           </xs:complextype>         </xs:element>       </xs:sequence>     </xs:complextype>   </xs:element> </xs:schema> 

but condition @ 1 time insert in either 'user' or 'role' table. need validate part of xml. possible access part in c# using attribute value table name?

the xsd should in below format;

<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified" attributeformdefault="unqualified">   <xs:element name="message"> <xs:annotation>   <xs:documentation> </xs:documentation> </xs:annotation> <xs:complextype>   <xs:choice> <xs:element name="root">     <xs:complextype>       <xs:sequence>         <xs:element name="table" maxoccurs="unbounded" minoccurs="1">           <xs:complextype>             <xs:sequence>               <xs:element type="xs:string" name="column" maxoccurs="unbounded" minoccurs="1"/>             </xs:sequence>             <xs:attribute type="xs:string" name="name" use="required"/>           </xs:complextype>         </xs:element>       </xs:sequence>     </xs:complextype>   </xs:element>      </xs:choice>` </xs:complextype>   </xs:element> </xs:schema> 

under choice tag can add individual elements, if have more 1 elements.

`


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -