You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by Aaron Dalton <aa...@daltons.ca> on 2009/11/28 18:52:08 UTC

Unique, key, and keyref

I have a schema (http://abstractgamers.org/xml/iago-report.xsd) that
imposes a couple of unique and key/keyref constraints.  I'm using
XML::Xerces (obviously) and have tried using both validator.pl and
validator-dom.pl included in the distribution (using --full_schema).  I
am attempting to validate an instance document
(http://abstractgamers.org/xml/iago-report-test.xml) but it refuses to
flag the duplicate "iagoid" attribute in the <player> elements.  The
Xerces documentation suggests that these constraints are supported, but
I just don't know what else to try to make that happen.  I would greatly
appreciate any help you could offer.

Many thanks,
Aaron

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


Re: [Fwd: Re: Well-formed v. invalid errors] Unique, key, and keyref

Posted by GlenFlint <Gl...@ngc.com>.
Hi Aaron,
I'm having a very similar problem with key/keyref constraints.  I'm running
the free xml editor that
comes with Eclipse 3.5 no problems are being detected.  Did you ever find
out what was going on?

Here's my test xsd and xml.
*************     test.xsd       ******************
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	targetNamespace="http://www.example.org/test" 
	xmlns:tns="http://www.example.org/test"
	elementFormDefault="qualified">
	
  <xsd:complexType name="myAAA">
    <xsd:sequence minOccurs="1">
      <xsd:element name="a" minOccurs="1" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:attribute name="id" type="xsd:NCName" use="required"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="myBBB">
    <xsd:sequence minOccurs="1">
      <xsd:element name="b" minOccurs="1" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:attribute name="idref" type="xsd:NCName" use="required"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="root">
    <xsd:complexType>
      <xsd:sequence minOccurs="1" maxOccurs="1">
        <xsd:element name="AAA" type="tns:myAAA"/>
        <xsd:element name="BBB" type="tns:myBBB"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:key name="myId">
      <xsd:selector xpath="a"/>
      <xsd:field xpath="@id"/>
    </xsd:key>
    <xsd:keyref name="myIdref" refer="tns:myId">
      <xsd:selector xpath="b"/>
      <xsd:field xpath="@idref"/>
    </xsd:keyref>
  </xsd:element>


</xsd:schema> 
**************  test.xml   ********************
<?xml version="1.0" encoding="UTF-8"?>
<tns:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://www.example.org/test"
	xmlns:tns="http://www.example.org/test"
	xsi:schemaLocation="http://www.example.org/test test.xsd"
	>
  <tns:AAA>
    <tns:a id="x"/>
    <tns:a id="y"/>
  </tns:AAA>
  <tns:BBB>
    <tns:b idref="x"/>
    <tns:b idref="y"/>
    <tns:b idref="z"/>
  </tns:BBB>
</tns:root> 
************************************************

Aaron Dalton wrote:
> 
> I have a schema (http://abstractgamers.org/xml/iago-report.xsd) that
> imposes a couple of unique and key/keyref constraints.  I'm using
> XML::Xerces (obviously) and have tried using both validator.pl and
> validator-dom.pl included in the distribution (using --full_schema).  I
> am attempting to validate an instance document
> (http://abstractgamers.org/xml/iago-report-test.xml) but it refuses to
> flag the duplicate "iagoid" attribute in the <player> elements.  The
> Xerces documentation suggests that these constraints are supported, but
> I just don't know what else to try to make that happen.  I would greatly
> appreciate any help you could offer.
> 
> Many thanks,
> Aaron
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: p-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: p-dev-help@xerces.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Unique%2C-key%2C-and-keyref-tp26555363p27601009.html
Sent from the Xerces - P - Dev mailing list archive at Nabble.com.


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