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 Steven Ihde <si...@cs.stanford.edu> on 2004/09/09 02:22:33 UTC

boolean "1" normalized to "true" breaks pattern facet validation


I was trying to declare an element with a mandatory
soap:mustUnderstand="1" attribute, like so:

<attribute ref="soap:mustUnderstand" use="required" fixed="1"/>

I get the following error when parsing the schema from Xerces 2.6.2:

  Value 'true' is not facet-valid with respect to pattern '0|1'

But my .xsd doesn't say "true" anywhere -- it says "1".

This was in the context of a schema that referenced SOAP, but I boiled
it down to the following trivial example:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://example.com"
        targetNamespace="http://example.com">

  <attribute name="mustUnderstand" >    
    <simpleType>
      <restriction base='boolean'>
        <pattern value='0|1' />
      </restriction>
    </simpleType>
  </attribute>
  
  <element name="Test">
    <complexType>
      <attribute ref="tns:mustUnderstand" use="required" fixed="1"/>
    </complexType>
  </element>

</schema>

Then we get the following error from the XMLGrammarBuilder sample:

$ java xni.XMLGrammarBuilder -f -a test-default.xsd
[Error] test-default.xsd:16:69: cvc-pattern-valid: Value 'true' is not
 facet-valid with respect to pattern '0|1' for type 'null'.
[Error] test-default.xsd:16:69: a-props-correct.2: Invalid value
 constraint value '1' in attribute 'mustUnderstand'.


If I change each "1" to "true", and each "0" to "false", this works
fine and has the desired effect.

This seems to be a bug in Xerces.  I didn't see anything like it in
Jira.  Has anyone run into this before?

Thanks,

Steve



-- 
Steven C. Ihde <si...@cs.stanford.edu>
PGP Key ID: 0x7793756D
PGP Fingerprint:  DC 55 8B CA 50 8B DD 75  67 45 96 4D FF 42 8A 6C

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


Re: boolean "1" normalized to "true" breaks pattern facet validation

Posted by Steven Ihde <si...@cs.stanford.edu>.
Thanks for taking the time to explain.

So if I accept the constraint on mustUnderstand as a given, then there
is no way to do what I want to do, correct?  Namely, to supply any
fixed or default value for this attribute?  

In the general case, this would seem to be a downside of excluding the
canonical representation through the use of a pattern facet.

-Steve


On Wed, Sep 08, 2004 at 10:40:04PM -0400, Michael Glavassevich wrote:
> Hello Steve,
> 
> Your schema appears to be invalid. The canonical lexical representation 
> [1] of the value of a value constraint (default of fixed) must be valid 
> with respect to the type definition for the attribute (in this case 
> 'mustUnderstand') [2]. The literal '1' maps to true in boolean's value 
> space. The literal 'true' is the canonical lexical representation for the 
> value true [3] but the pattern facet in the type definition excludes 
> 'true' from the lexical space.
> 
> I hope that makes some sense.
> 
> [1] 
> http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes#dt-canonical-representation
> [2] http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#a-props-correct
> [3] 
> http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#boolean
> 
> Steven Ihde <si...@cs.stanford.edu> wrote on 09/08/2004 08:22:33 PM:
> 
> > 
> > 
> > I was trying to declare an element with a mandatory
> > soap:mustUnderstand="1" attribute, like so:
> > 
> > <attribute ref="soap:mustUnderstand" use="required" fixed="1"/>
> > 
> > I get the following error when parsing the schema from Xerces 2.6.2:
> > 
> >   Value 'true' is not facet-valid with respect to pattern '0|1'
> > 
> > But my .xsd doesn't say "true" anywhere -- it says "1".
> > 
> > This was in the context of a schema that referenced SOAP, but I boiled
> > it down to the following trivial example:
> > 
> > <schema xmlns="http://www.w3.org/2001/XMLSchema"
> >         xmlns:tns="http://example.com"
> >         targetNamespace="http://example.com">
> > 
> >   <attribute name="mustUnderstand" > 
> >     <simpleType>
> >       <restriction base='boolean'>
> >         <pattern value='0|1' />
> >       </restriction>
> >     </simpleType>
> >   </attribute>
> > 
> >   <element name="Test">
> >     <complexType>
> >       <attribute ref="tns:mustUnderstand" use="required" fixed="1"/>
> >     </complexType>
> >   </element>
> > 
> > </schema>
> > 
> > Then we get the following error from the XMLGrammarBuilder sample:
> > 
> > $ java xni.XMLGrammarBuilder -f -a test-default.xsd
> > [Error] test-default.xsd:16:69: cvc-pattern-valid: Value 'true' is not
> >  facet-valid with respect to pattern '0|1' for type 'null'.
> > [Error] test-default.xsd:16:69: a-props-correct.2: Invalid value
> >  constraint value '1' in attribute 'mustUnderstand'.
> > 
> > 
> > If I change each "1" to "true", and each "0" to "false", this works
> > fine and has the desired effect.
> > 
> > This seems to be a bug in Xerces.  I didn't see anything like it in
> > Jira.  Has anyone run into this before?
> > 
> > Thanks,
> > 
> > Steve
> > 

-- 
Steven C. Ihde <si...@cs.stanford.edu>
PGP Key ID: 0x7793756D
PGP Fingerprint:  DC 55 8B CA 50 8B DD 75  67 45 96 4D FF 42 8A 6C

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