Thanks Alberto, Validation is going perfect now :-)

-----Original Message-----
From: Alberto Massari [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 08, 2008 6:56 PM
To: [email protected]
Subject: Re: Will Sax support xsd:unique?

[EMAIL PROTECTED] wrote:
>
> Thanks Alberto. However, When I am trying to enforce unique constraint

> on single attribute for multiple instances,I am still facing
> difficulty.Here is my sample XML
>
>                         <CLM:ClientTable>
>                                 <CLM:ClientEntry ClientId="1">
>
> <CLM:ClientProcessId>*12*</CLM:ClientProcessId>
>                                 </CLM:ClientEntry>
>                                 <CLM:ClientEntry ClientId="2">
>
> <CLM:ClientProcessId>*12*</CLM:ClientProcessId>
>                                 </CLM:ClientEntry>
>                                 <CLM:ClientEntry ClientId="3">
>
> <CLM:ClientProcessId>*12*</CLM:ClientProcessId>
>                                 </CLM:ClientEntry>
>                         </CLM:ClientTable>
>
> I am trying to make *ClientProcessId* Unique across different
> "*ClientEntry*" and attached schema fails to do so. Any pointers would

> be of great help!
>

The elements are in a namespace, so you should write

            <xsd:selector xpath="c:ClientTable/c:ClientEntry"/>
            <xsd:field xpath="c:ClientProcessId"/>

and add a xmlns:c="CLM" to the root element XPath expressions ignore the
default namespace, in order to be able to always reference the empty
namespace (http://www.w3.org/TR/xpath#node-tests)

Alberto

> Thanks,
> Karuna
>
> -----Original Message-----
> From: Alberto Massari [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 04, 2008 7:56 PM
> To: [email protected]
> Subject: Re: Will Sax support xsd:unique?
>
> Your schema is wrong; you are defining the unique constraint inside
> the <number> element, but you need to place it in the <root> element.
> Also, if you want to detect duplicates between <number> and <digit>,
> you need to add both to your xs:unique
>
> <?xml version="1.0" encoding="UTF-8"?> <xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified">
>     <xs:element name="root">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element ref="number"/>
>                 <xs:element ref="digit"/>
>             </xs:sequence>
>         </xs:complexType>
>         <xs:unique name="numberUnique">
>             <xs:selector xpath="number | digit"></xs:selector>
>             <xs:field xpath="."></xs:field>
>         </xs:unique>
>     </xs:element>
>     <xs:element name="number" type="xs:integer"/>
>     <xs:element name="digit" type="xs:integer"/> </xs:schema>
>
> Alberto
>
> [EMAIL PROTECTED] wrote:
> > Hi All,
> >
> > I have the following XSD where my "number" is having unique
> > constarint
> >
> > <?xml version="1.0" encoding="UTF-8"?> <xs:schema
> > xmlns:xs="http://www.w3.org/2001/XMLSchema";
> > elementFormDefault="qualified">
> > <xs:element name="root">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element ref="number"/>
> > <xs:element ref="digit"/>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> > <xs:element name="number" type="xs:integer"> <xs:unique
> > name="numberUnique"> <xs:selector xpath="number"></xs:selector>
> > <xs:field xpath="."></xs:field> </xs:unique> </xs:element>
> > <xs:element name="digit" type="xs:integer"/> </xs:schema>
> >
> > My corresponding XML is like below
> >
> > <?xml version="1.0" encoding="UTF-8"?> <root
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > xsi:noNamespaceSchemaLocation="Unique.xsd">
> > <number> 2</number>
> > <digit>2</digit>
> > </root>
> >
> > As i understand, since number has xsd:unique constraint, the value
> > should be unique in its parent scope.
> > But in my above XML, the values for "number" and "digit" are same,
> > which is 2. When i validate the XML using SAX, i am not seeing any
> error.
> >
> > Can SAX support xsd:unique constraint? if yes, why the error was not

> > reported for above case
> >
> > Thanks a lot,
> > Karuna
> >
> >
> > The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> addressee(s) and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately and destroy all copies of this message and any
attachments.
> >
> > WARNING: Computer viruses can be transmitted via email. The
> recipient should check this email and any attachments for the presence

> of viruses. The company accepts no liability for any damage caused by
> any virus transmitted by this email.
> >
> > www.wipro.com
> >
> >
> >
>
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> addressee(s) and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately and destroy all copies of this message and any
attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of
> viruses. The company accepts no liability for any damage caused by any

> virus transmitted by this email.
>
> www.wipro.com
>



The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

Reply via email to