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

XS:UNIQUE Question

Status
Not open for further replies.

dave1112

Programmer
Jan 5, 2012
1
0
0
US
I have an XML file that I would like to enforce uniqueness on a field. I know I can use XS:UNIQUE to do this on fields within a type. However, I want to do this on fields within a hierarchy. So in the example XML, I want the tax rate field to be unique for a given customer, but each customer can have the same tax rate. In the sample XML below, Customer # 123 and # 456 can both have a "1.2" tax rate, but customer # 456 cannot have two instances of the "1.2" tax rate. If I try to put a uniqueness constraint on the tax rate, it applies it to the whole file, not just to one customer in the file. I can't change the file format. I'm just looking for a way to enforce uniqueness with an XSD given this format. Thanks in advance for any help!
------------
<?xml version="1.0" encoding="UTF-8" ?>
<TAXES>
<CUSTOMERS>
<CUST_NO>123</CUST_NO>
<DETAILS>
<TAX_RATE>1.2</TAX_RATE>
<TAX_REVENUE>3000.00</TAX_REVENUE>
</DETAILS>
<DETAILS>
<TAX_RATE>7.5</TAX_RATE>
<TAX_REVENUE>5000.00</TAX_REVENUE>
</DETAILS>
</CUSTOMERS>
<CUSTOMERS>
<CUST_NO>456</CUST_NO>
<DETAILS>
<TAX_RATE>1.2</TAX_RATE>
<TAX_REVENUE>2000.00</TAX_REVENUE>
</DETAILS>
<DETAILS>
<TAX_RATE>1.2></TAX_RATE>
<TAX_REVENUE>7000.00</TAX_REVENUE>
</DETAILS>
</CUSTOMERS>
</TAXES>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top