mike.mclennan 29 Light Poster

I have created a new XML file and schema that is used to run sql scripts but I am having a problem doing a few things. below is an example of what I am hoping to create.

XML file.


    <name> Script for Upgrading </name>
    <file> C:\Files\Scripts\Upgrade.sql </file>
    <SCHEMA> Schema Owner </SCHEMA>
    <name> Script for Removing Geometeries </name>
    <file> C:\Files\Scripts\replaceGeoms.sql </file>
    <SCHEMA> Schema Owner </SCHEMA>
     <USERNAME> Username </USERNAME>
     <PASSWORD> Password </PASSWORD>



XML schema

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="sqlscripts"
            xmlns="sqlscripts" elementFormDefault="qualified">

    <xsd:element name="root">
          <xsd:element name="script" type="script_type" maxOccurs="unbounded" />
          <xsd:element name="parameter_type" type="xsd:string" 
                                                                                maxOccurs="unbounded" />    

    <xsd:complexType name="script_type">
            <xsd:element name="name" type="xsd:string" />
            <xsd:element name="file" type="xsd:string" />                    
            [B]<xsd:element type="parameter_type" maxOccurs="unbounded" />[/B]


The main problem I am having is I want the element that surrounds the parameter to
be parameter type name. So if the element is USERNAME and the value is pparker then I know that ppparker is a username and not a PAssword or string or whatever. But I have not been able to find how to do this with the xml schema.

I also would like to create the name field as a key or a unique, I have found a few examples of that but nothing that has worked for me. (I am validating the XML with C# validationReader)

Any help would be greatly appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.