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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary Key Issue

Status
Not open for further replies.

khush79

Technical User
Nov 1, 2004
1
US
Hi. I would really appreciate it if someone can tell me why the SSN sub-element in the xml schema, which has been declared as a primary key still allows duplicates when I display it using the main xml file. I still see two SSNs with the same value of 123

XML Schema
==========

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xs = " <xs:element name = "Banking" msdata:IsDataSet="true">
<xs:complexType>

<xs:element name = "Customer">
<xs:complexType>
<xs:sequence>
<xs:element = "SSN" type = "xs:integer" minOccurs = "1"
maxOccurs = "1" />
<xs:element = "FirstName" type = "xs:string" minOccurs = "1"
maxOccurs = "1" />
<xs:element = "LastName" type = "xs:integer" minOccurs = "1"
maxOccurs = "1"/>
<xs:element = "CreditReport" type = "xs:string" minOccurs = "0"
maxOccurs = "1"/>
<xs:element = "Zip" type = "xs:integer" minOccurs = "1"
maxOccurs = "1"/>
<xs:element = "AptSuite" type = "xs:string" minOccurs = "0"
maxOccurs = "1" />
<xs:element = "Street" type = "xs:string" minOccurs = "1"
maxOccurs = "1" />
<xs:element = "City" type = "xs:string" minOccurs = "1"
maxOccurs = "1" />
<xs:element = "State" type = "xs:string" minOccurs = "1"
maxOccurs = "1"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:complexType>
<xs:key name="CustomerKey1" msdata:primaryKey="true">
<xs:selector xpath=".//Customer"/>
<xs:field xpath="SSN"/>
</xs:key>

</xs:element>
</schema>

XML File
=========

?xml version = "1.0" ?>
<?xml-stylesheet type="text/xsl" href="template.xsl"?>
<Banking
xsi:noNamespaceSchemaLocation = "C:\Documents and Settings\Burly Ogre\My Documents\USC\585\Mcleod\xml\schema.xsd"
xmlns:xsi = " <Customer>
<SSN>123</SSN>
<FirstName>firstnm</FirstName>
<LastName>lastnm</LastName>
<CreditReport>creditclear</CreditReport>
<Zip>90001</Zip>
<AptSuite>1</AptSuite>
<Street>Street 1</Street>
<City>City 1</City>
<State>State 1</State>

</Customer>

<Customer>
<SSN>123</SSN>
<FirstName>secondnm</FirstName>
<LastName>lastnm</LastName>
<CreditReport>creditclear</CreditReport>
<Zip>90001</Zip>
<AptSuite>1</AptSuite>
<Street>Street 1</Street>
<City>City 1</City>
<State>State 1</State>

</Customer>
</Banking>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top