Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

How to adding and removing a key in xsd schema

$
0
0

How to add a key  and removing a key in XSD using c#   

                //XmlSchemaKey element_key = new XmlSchemaKey();  // added dynamically in save button .
                //element_key.Name = Schema_Name;
                //element_key.Selector = new XmlSchemaXPath();
                //element_key.Selector.XPath = ".";
                //XmlSchemaXPath field = new XmlSchemaXPath();
                //field.XPath = Schema_Name;
                //element_key.Fields.Add(field);
                //element.Constraints.Add(element_key);
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="AD">  <xsd:element name="AD"><xsd:complexType><xsd:sequence><xsd:element minOccurs="0" maxOccurs="1" name="MobileName"><xsd:complexType><xsd:sequence><xsd:element name="quantity" type="xsd:int" /><xsd:element name="account_no" type="xsd:int" /><xsd:element minOccurs="1" maxOccurs="1" name="provision_status" type="xsd:string" /><xsd:element minOccurs="0" maxOccurs="unbounded" name="User"><xsd:complexType><xsd:sequence><xsd:element minOccurs="1" maxOccurs="1" name="FirstName" type="xsd:string" /><xsd:element minOccurs="1" maxOccurs="1" name="LastName" type="xsd:string" /><xsd:element minOccurs="1" maxOccurs="1" name="UserLogOnName" type="xsd:string" /><xsd:element minOccurs="1" maxOccurs="1" name="UserPassword" type="xsd:string" /><xsd:element minOccurs="1" maxOccurs="1" name="DomainName" type="xsd:string" /></xsd:sequence><xsd:attribute default="false" name="Suspended" type="xsd:boolean" /><xsd:attribute name="ID" type="xsd:int" use="optional" /><xsd:attribute name="Platform_Id" type="xsd:int" /><xsd:attribute name="Product_Id" type="xsd:int" /></xsd:complexType><xsd:key name="MobileName"><xsd:selector xpath=".//User" /><xsd:field xpath="FirstName" /><xsd:field xpath="LastName" /></xsd:key></xsd:element></xsd:sequence><xsd:attribute default="false" name="Suspended" type="xsd:boolean" /><xsd:attribute name="ID" type="xsd:int" use="optional" /><xsd:attribute name="Platform_Id" type="xsd:int" /><xsd:attribute name="Product_Id" type="xsd:int" /></xsd:complexType></xsd:element></xsd:sequence></xsd:complexType></xsd:element></xsd:schema>

I added a key using the code . but not able to remove the key .

Is there any other way to remove the key from the xsd

 <xsd:key name="MobileName">
                  <xsd:selector xpath=".//User" />
                  <xsd:field xpath="FirstName" />
                  <xsd:field xpath="LastName" />
                </xsd:key>

                //XmlSchemaKey element_key = new XmlSchemaKey();  // added dynamically in save button .
                //element_key.Name = Schema_Name;
                //element_key.Selector = new XmlSchemaXPath();
                //element_key.Selector.XPath = ".";
                //XmlSchemaXPath field = new XmlSchemaXPath();
                //field.XPath = Schema_Name;
                //element_key.Fields.Add(field);
                //element.Constraints.Add(element_key);

                //XmlSchemaKey element_key = new XmlSchemaKey();  // added dynamically in save button .
                //element_key.Name = Schema_Name;
                //element_key.Selector = new XmlSchemaXPath();
                //element_key.Selector.XPath = ".";
                //XmlSchemaXPath field = new XmlSchemaXPath();
                //field.XPath = Schema_Name;
                //element_key.Fields.Add(field);
                //element.Constraints.Add(element_key);

                //XmlSchemaKey element_key = new XmlSchemaKey();  // added dynamically in save button .
                //element_key.Name = Schema_Name;
                //element_key.Selector = new XmlSchemaXPath();
                //element_key.Selector.XPath = ".";
                //XmlSchemaXPath field = new XmlSchemaXPath();
                //field.XPath = Schema_Name;
                //element_key.Fields.Add(field);
                //element.Constraints.Add(element_key);


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>