Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

How can I add an attribute to a sequence element in an XSD document?

I currently have an XSD document that gives me the following except for the password attribute Type="PasswordDigest".  Can someone tell me how to add this with my existing xsd?

<?xml version="1.0" encoding="utf-8"?>
<Message xmlns="http://www.surescripts.com/messaging">
            <Header>
                        <To>testsite</To>
                        <From>testsite</From>
                        <MessageID>4654664</MessageID>
                        <SentTime>2008-10-09T19:03:37.9Z</SentTime>
                        <Security>
                                    <UsernameToken>
                                                <Username>testname</Username>
                                                <Password Type="PasswordDigest">testpassword</Password>
                                                <Nonce>2254</Nonce>
                                                <Created>2008-10-09T19:03:37.9Z</Created>
                                    </UsernameToken>
                        </Security>
            </Header>
            <Body>
                        <DirectoryDownload>
                                    <AccountID>444</AccountID>
                                    <VersionID>4</VersionID>
                                    <Taxonomy>
                                                <TaxonomyCode>183500000X</TaxonomyCode>
                                    </Taxonomy>
                        </DirectoryDownload>
            </Body>
</Message>



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="Message">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="Header" minOccurs="0"/>
				<xs:element ref="Body" minOccurs="0"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="Header">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="To" minOccurs="0" />
				<xs:element ref="From" minOccurs="0"/>
				<xs:element ref="MessageID" minOccurs="0"/>
				<xs:element ref="SentTime" minOccurs="0"/>
				<xs:element ref="Security" minOccurs="0"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="Body">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="DirectoryDownload" minOccurs="0"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="Security">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="UsernameToken" minOccurs="0" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>	
	<xs:element name="UsernameToken">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="Username" minOccurs="0" />
				<xs:element ref="Password" minOccurs="0" />   
				<xs:element ref="Nonce" minOccurs="0" />
				<xs:element ref="Created" minOccurs="0" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>	
	<xs:element name="DirectoryDownload">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="AccountID" minOccurs="0" />
				<xs:element ref="VersionID" minOccurs="0" />
				<xs:element ref="Taxonomy" minOccurs="0" />
				<xs:element ref="DirectoryDate" minOccurs="0" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>	
	<xs:element name="Taxonomy">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="TaxonomyCode" minOccurs="0" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>		
	<xs:element name="To" type="xs:string"/>
	<xs:element name="From" type="xs:string"/>
	<xs:element name="MessageID" type="xs:string"/>
	<xs:element name="SentTime" type="xs:string"/>
	<xs:element name="Username" type="xs:string"/>
	<xs:element name="Password" type="xs:string"/>
	<xs:element name="Nonce" type="xs:string"/>
	<xs:element name="Created" type="xs:string"/>
	<xs:element name="AccountID" type="xs:string"/>
	<xs:element name="VersionID" type="xs:string"/>
	<xs:element name="TaxonomyCode" type="xs:string"/>
	<xs:element name="DirectoryDate" type="xs:string"/>
</xs:schema>

Open in new window

0
cindymccartney
Asked:
cindymccartney
  • 2
1 Solution
 
Geert BormansCommented:
you will need a complexType/simpleContent in your definition for password

    <xs:element name="Password">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attribute name="Type"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

instead of

      <xs:element name="Password" type="xs:string"/>
0
 
cindymccartneyAuthor Commented:
Thanks!
0
 
Geert BormansCommented:
welcome
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now