INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

XS:UNIQUE Question

XS:UNIQUE Question

(OP)
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>
    
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close