You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Kiran Halwai <kh...@winphoria.com> on 2001/04/19 20:40:53 UTC

Clarification: key/keyref

I want to validate whether a particular element is in given set or not.
This set is defined dynamically.
Please see the following sample.  Parser does complain if an ID does not
appears in the given set but
it does not allow me to define more than one such ID for the element in
key ref. Is this a valid functionality
of key/key ref? If yes, is there any other way to achieve the required
functionality? I am using Oracle parser.
Any help would be greatly appreciated.

Regards,
Kiran

In short: Why can not I define  Value.ID = 1 twice?

-----------------------------------------------------------------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
        targetNamespace="my.trial"
        xmlns:my="my.trial"
        elementFormDefault="qualified">

<xsd:element name="trial">
 <xsd:complexType>
  <xsd:sequence>
    <xsd:element name="ValidSet" type="my:ValidSetType"
maxOccurs="unbounded"/>
    <xsd:element name="Values" type="my:ValuesType"
maxOccurs="unbounded"/>
  </xsd:sequence>
 </xsd:complexType>

  <key name="valid_values">
      <selector xpath="my:ValidSet"/>
      <field xpath="my:ValidID"/>
  </key>

  <keyref name="value" refer="valid_values">
      <selector xpath="my:Values"/>
      <field xpath="my:ID"/>
  </keyref>

</xsd:element>

<xsd:complexType name="ValidSetType">
    <xsd:sequence>
        <xsd:element name="ValidID" type="xsd:positiveInteger"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ValuesType">
    <xsd:sequence>
 <xsd:element name="ID" type="xsd:positiveInteger"/>
   </xsd:sequence>
</xsd:complexType>

</xsd:schema>

--------------------------------------------------------------------
<?xml version="1.0"?>
<trial xmlns = "my.trial"
     xmlns:my="my.trial"
     xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
     xsi:schemaLocation =
  "my.trial
   keykref.xsd">

  <ValidSet>
      <ValidID>1</ValidID>
  </ValidSet>

  <ValidSet>
      <ValidID>2</ValidID>
  </ValidSet>

  <Values>
      <ID>1</ID>
  </Values>

  <Values>
      <ID>1</ID>
  </Values>

</trial>


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


Re: Clarification: key/keyref

Posted by Kiran Halwai <kh...@winphoria.com>.
Well, I started with the 'Xerces Java Parser 1.3.1 Release' but on
http://xml.apache.org/xerces-j/schema.html,
I saw the list of 'Features NOT Supported'.  It does not support some of
the things I need and one of that is constraints.
I confirmed following Bug (1) and stopped using this parser.

Is there any (alpha/final) release around that supports following
unsupported features in 1.3.1?

Features NOT Supported in 1.3.1
                    Constraints in Chapter 5 and elsewhere in the
specifications
                    Nullable
                    Block and final
                    Fixed and default values of elements

Thank you very much.

Regards,
Kiran



Andy Clark wrote:

> Kiran Halwai wrote:
> > functionality? I am using Oracle parser.
>
> Step 1: Uninstall Oracle parser. ;)
> Step 2: Install Xerces-J parser.
> Step 3: Try example again.
>
> > Any help would be greatly appreciated.
>
> Seriously, I ran into several problems using your sample with
> Xerces-J but it's mostly various bugs interacting in Xerces.
> Bug 1) If the Schema uses a named prefix (i.e. xsd:schema
> instead of just schema) then the parser can't properly create
> the identity constraints. Bug 2) Putting schema grammar in
> default namespace solves Bug 1 but introduces another problem.
> The parser will emit errors that it can't find the element
> declarations for "my:ValidSet" and "my:Values". BUT... it
> still creates the identity constrains and validates them in
> the instance document correctly. Strange, indeed.
>
> --
> Andy Clark * IBM, TRL - Japan * andyc@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


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


Re: Clarification: key/keyref

Posted by Andy Clark <an...@apache.org>.
Kiran Halwai wrote:
> functionality? I am using Oracle parser.

Step 1: Uninstall Oracle parser. ;)
Step 2: Install Xerces-J parser.
Step 3: Try example again.

> Any help would be greatly appreciated.

Seriously, I ran into several problems using your sample with
Xerces-J but it's mostly various bugs interacting in Xerces.
Bug 1) If the Schema uses a named prefix (i.e. xsd:schema
instead of just schema) then the parser can't properly create
the identity constraints. Bug 2) Putting schema grammar in
default namespace solves Bug 1 but introduces another problem.
The parser will emit errors that it can't find the element
declarations for "my:ValidSet" and "my:Values". BUT... it
still creates the identity constrains and validates them in
the instance document correctly. Strange, indeed.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

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