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 Christian Will <ch...@gmail.com> on 2005/09/05 18:19:42 UTC

Validating ID/IDREF/IDRES with a default value...

Hi,

I have a question...

I created an element declaration with an attribute of type IDREF and a
default value. The xml processor creates automaticaly the attribute
with the default value, if it is absent in the instance document.

So I expected that the validator also checks ID/IDREF dependency for
default attributes.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:element name="ROOT">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="ELEMENT" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="idref" type="xs:IDREF" default="ID001"/>
            <xs:attribute name="id" type="xs:ID"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="schema.xsd">
<ELEMENT id="ID002"></ELEMENT>
</ROOT>

For example for this instance document I expected the error
"cvc-id.1: There is no ID/IDREF binding for IDREF 'ID001'",
but xerces reports no error.

So maybe I'm wrong or this is a bug? Where can I find the rule for
this case in the schema recommendation?

Cheers,
Christian

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


Re: Validating ID/IDREF/IDRES with a default value...

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Christian,

Christian Will <ch...@gmail.com> wrote on 09/05/2005 12:19:42 PM:

> Hi,
> 
> I have a question...
> 
> I created an element declaration with an attribute of type IDREF and a
> default value. The xml processor creates automaticaly the attribute
> with the default value, if it is absent in the instance document.
> 
> So I expected that the validator also checks ID/IDREF dependency for
> default attributes.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
>   <xs:element name="ROOT">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="ELEMENT" minOccurs="0" maxOccurs="unbounded">
>           <xs:complexType>
>             <xs:attribute name="idref" type="xs:IDREF" default="ID001"/>
>             <xs:attribute name="id" type="xs:ID"/>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="schema.xsd">
> <ELEMENT id="ID002"></ELEMENT>
> </ROOT>
> 
> For example for this instance document I expected the error
> "cvc-id.1: There is no ID/IDREF binding for IDREF 'ID001'",
> but xerces reports no error.
> 
> So maybe I'm wrong or this is a bug? Where can I find the rule for
> this case in the schema recommendation?

It's a grey area of the spec. It isn't clear whether IDREF is enforced for 
defaulted attributes. Members of the schema WG are aware of this issue and 
have opened a bug report against the spec in Bugzilla [1]. I think this is 
probably a bug, but will wait for a response from them before making any 
changes to the code.

> Cheers,
> Christian
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
> 

Thanks.

[1] http://www.w3.org/Bugs/Public/show_bug.cgi?id=2041

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


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