You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Joachim Achtzehnter <jo...@netacquire.com> on 2002/01/03 22:56:19 UTC

Schema support in 1.6.0 (unique/key)

Dec 6, I wrote:
>
> Hi Khaled,
>
> You wrote:
> >
> > The fix is in CVS. I have attached the diff for your reference.
>
> Thanks a bundle. This appears to work now. Will these two bug fixes make
> it into the final 1.6.0 release?

Let me take this back. :-)

Union support in schema "unique" or "key" selectors now works as long as
there are at most two choices. It still doesn't work for the general case,
for example something like this:

   <xs:selector xpath="one|two|three|four" />

In this case everything except "one" and "two" are being ignored.

Below is an example that should fail the unique constraint because of the
duplicated "bar1" value, but Xerces 1.6.0 doesn't detect this violation.

Joachim

-- 
work:     joachima@netacquire.com   (http://www.netacquire.com)
private:  joachim@kraut.ca          (http://www.kraut.ca)

-- union.xml ------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	  xsi:noNamespaceSchemaLocation="union.xsd">

<table1 key="foo1"/>
<table1 key="bar1"/>

<table2 key="foo2"/>
<table2 key="bar2"/>

<table3 key="foo3"/>
<table3 key="bar1"/>  <!-- violates unique constraint -->

</database>
-------------------------------------------------------------------------

-- union.xsd ------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

 <xs:element name="database">
  <xs:complexType>
   <xs:sequence>

     <xs:element name="table1" minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
       <xs:attribute name="key"/>
      </xs:complexType>
     </xs:element>

     <xs:element name="table2" minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
       <xs:attribute name="key"/>
      </xs:complexType>
     </xs:element>

     <xs:element name="table3" minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
       <xs:attribute name="key"/>
      </xs:complexType>
     </xs:element>

   </xs:sequence>
  </xs:complexType>

  <xs:unique name="common_key">
   <xs:selector xpath="table1|table2|table"/>
   <xs:field xpath="@key"/>
  </xs:unique>

 </xs:element>
</xs:schema>
-------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Schema support in 1.6.0 (unique/key)

Posted by Joachim Achtzehnter <jo...@netacquire.com>.
Hi Khaled,

You wrote:
>
> Here is the fix:

Thanks again! It now works (famous last words...).

Joachim

-- 
work:     joachima@netacquire.com   (http://www.netacquire.com)
private:  joachim@kraut.ca          (http://www.kraut.ca)


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Schema support in 1.6.0 (unique/key)

Posted by Khaled Noaman <kn...@ca.ibm.com>.
:-(

Here is the fix:

Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.73
diff -r1.73 TraverseSchema.cpp
3936c3936
<         fBuffer.append(xpathExpr + startIndex, chOffset + 1);
---
>         fBuffer.append(xpathExpr + startIndex, chOffset + 1 - startIndex);

Regards,
Khaled


joachima@van4.netacquire.com wrote:

> Dec 6, I wrote:
> >
> > Hi Khaled,
> >
> > You wrote:
> > >
> > > The fix is in CVS. I have attached the diff for your reference.
> >
> > Thanks a bundle. This appears to work now. Will these two bug fixes make
> > it into the final 1.6.0 release?
>
> Let me take this back. :-)
>
> Union support in schema "unique" or "key" selectors now works as long as
> there are at most two choices. It still doesn't work for the general case,
> for example something like this:
>
>    <xs:selector xpath="one|two|three|four" />
>
> In this case everything except "one" and "two" are being ignored.
>
> Below is an example that should fail the unique constraint because of the
> duplicated "bar1" value, but Xerces 1.6.0 doesn't detect this violation.
>
> Joachim
>
> --
> work:     joachima@netacquire.com   (http://www.netacquire.com)
> private:  joachim@kraut.ca          (http://www.kraut.ca)
>
> -- union.xml ------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>           xsi:noNamespaceSchemaLocation="union.xsd">
>
> <table1 key="foo1"/>
> <table1 key="bar1"/>
>
> <table2 key="foo2"/>
> <table2 key="bar2"/>
>
> <table3 key="foo3"/>
> <table3 key="bar1"/>  <!-- violates unique constraint -->
>
> </database>
> -------------------------------------------------------------------------
>
> -- union.xsd ------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>  <xs:element name="database">
>   <xs:complexType>
>    <xs:sequence>
>
>      <xs:element name="table1" minOccurs="0" maxOccurs="unbounded">
>       <xs:complexType>
>        <xs:attribute name="key"/>
>       </xs:complexType>
>      </xs:element>
>
>      <xs:element name="table2" minOccurs="0" maxOccurs="unbounded">
>       <xs:complexType>
>        <xs:attribute name="key"/>
>       </xs:complexType>
>      </xs:element>
>
>      <xs:element name="table3" minOccurs="0" maxOccurs="unbounded">
>       <xs:complexType>
>        <xs:attribute name="key"/>
>       </xs:complexType>
>      </xs:element>
>
>    </xs:sequence>
>   </xs:complexType>
>
>   <xs:unique name="common_key">
>    <xs:selector xpath="table1|table2|table"/>
>    <xs:field xpath="@key"/>
>   </xs:unique>
>
>  </xs:element>
> </xs:schema>
> -------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Schema support in 1.6.0 (unique/key)

Posted by Joachim Achtzehnter <jo...@netacquire.com>.
Just a quick followup:

I wrote:
>
> Below is an example that should fail the unique constraint because of the
> duplicated "bar1" value, but Xerces 1.6.0 doesn't detect this violation.

The schema I provided included a small typo. Replace

   <xs:selector xpath="table1|table2|table"/>

by the intended:

   <xs:selector xpath="table1|table2|table3"/>

Note, the 3 was missing. Xerces 1.6.0 still doesn't detect the uniqueness
violation...

Joachim

-- 
work:     joachima@netacquire.com (http://www.netacquire.com)
private:  joachim@kraut.ca (http://www.kraut.ca)



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org