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 Sandy Gao <sa...@ca.ibm.com> on 2003/07/01 00:00:25 UTC

Re: Attribute must appear/not allowed ?????

In your schema, you specified attributeFormDefault="qualified", which means
that local attribute declarations belong to the target namespace of the
schema. Specifically, attribute "date" has target namespace
"http://www.example.com/2002/Declaration".

But in your instance, the "date" attribute doesn't have a prefix, so it
doesn't have a namespace, hence doesn't match the required "date"
attribute. (Note that default namespace declaration doesn't apply to
attributes.)

HTH,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
sandygao@ca.ibm.com



                                                                                                                                
                      "Luís Pereira"                                                                                            
                      <luis.pereira@ope        To:       <xe...@xml.apache.org>                                         
                      nsoft.pt>                cc:                                                                              
                                               Subject:  Attribute must appear/not allowed ?????                                
                      06/30/2003 05:57                                                                                          
                      PM                                                                                                        
                      Please respond to                                                                                         
                      xerces-j-user                                                                                             
                                                                                                                                
                                                                                                                                




Hello,

I've tried to submit the following bug but the forms are just too complex
and I couldn't understand (everyone has it's limitations) how to send an
attachment example, so I'm sending it here.

It consists of the following:

1. I've Defined a Schema called Declaration.xsd that you can find in
examples.jar, where I've put a simple type (ValueType, a decimal with 13
of max size and 2 of precision)

<xs:simpleType name="ValueType">
      <xs:restriction base="xs:decimal">
            <xs:minExclusive value="0.00"/>
            <xs:totalDigits value="13"/>
            <xs:fractionDigits value="2"/>
      </xs:restriction>
</xs:simpleType>

2. Then wdefined an Element of that type (Amount), whith a restriction to
have an attribute date that is required and...

<xs:element name="Amount" maxOccurs="unbounded">
      <xs:complexType>
            <xs:simpleContent>
                  <xs:extension base="ValueType">
                        <xs:attribute name="date" use="required">
                              <xs:simpleType>
                                    <xs:restriction base="xs:date"/>
                              </xs:simpleType>
                        </xs:attribute>
                  </xs:extension>
            </xs:simpleContent>
      </xs:complexType>
</xs:element>

Guess what happens... (you wont, you can run this example using the
following cmd):

  java -cp example.jar;xercesImpl.jar;xmlParserApi.jar Validator

And amazingly for a simple xml file (that you can find inside the jar),
the output will be:

[Error] :4:28: cvc-complex-type.3.2.2: Attribute 'date' is not allowed to
appear in element 'Amount'.
[Error] :4:28: cvc-complex-type.4: Attribute 'date' must appear on element
'Amount'.
[Error] :5:28: cvc-complex-type.3.2.2: Attribute 'date' is not allowed to
appear in element 'Amount'.
[Error] :5:28: cvc-complex-type.4: Attribute 'date' must appear on element
'Amount'.

Can anyone tell me why is this happening ????

Best Regards,

Luís Pereira


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

#### example.jar has been removed from this note on June 30 2003 by Sandy
Gao



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


RE: Attribute must appear/not allowed ?????

Posted by Luis Pereira <lu...@opensoft.pt>.
Thank you Sandy. When I've changed the attributeFormDefault to
unqualified it worked just fine.

Luis

> -----Original Message-----
> From: Sandy Gao [mailto:sandygao@ca.ibm.com] 
> Sent: segunda-feira, 30 de Junho de 2003 23:00
> To: xerces-j-user@xml.apache.org
> Subject: Re: Attribute must appear/not allowed ????? 
> 
> 
> In your schema, you specified 
> attributeFormDefault="qualified", which means that local 
> attribute declarations belong to the target namespace of the 
> schema. Specifically, attribute "date" has target namespace 
> "http://www.example.com/2002/Declaration".
> 
> But in your instance, the "date" attribute doesn't have a 
> prefix, so it doesn't have a namespace, hence doesn't match 
> the required "date" attribute. (Note that default namespace 
> declaration doesn't apply to
> attributes.)
> 
> HTH,
> Sandy Gao
> Software Developer, IBM Canada
> (1-905) 413-3255
> sandygao@ca.ibm.com
> 
> 
> 
>                                                               
>                                                                   
>                       "Luís Pereira"                          
>                                                                   
>                       <luis.pereira@ope        To:       
> <xe...@xml.apache.org>                                
>          
>                       nsoft.pt>                cc:            
>                                                                   
>                                                Subject:  
> Attribute must appear/not allowed ?????                       
>          
>                       06/30/2003 05:57                        
>                                                                   
>                       PM                                      
>                                                                   
>                       Please respond to                       
>                                                                   
>                       xerces-j-user                           
>                                                                   
>                                                               
>                                                                   
>                                                               
>                                                                   
> 
> 
> 
> 
> Hello,
> 
> I've tried to submit the following bug but the forms are just 
> too complex and I couldn't understand (everyone has it's 
> limitations) how to send an attachment example, so I'm 
> sending it here.
> 
> It consists of the following:
> 
> 1. I've Defined a Schema called Declaration.xsd that you can 
> find in examples.jar, where I've put a simple type 
> (ValueType, a decimal with 13 of max size and 2 of precision)
> 
> <xs:simpleType name="ValueType">
>       <xs:restriction base="xs:decimal">
>             <xs:minExclusive value="0.00"/>
>             <xs:totalDigits value="13"/>
>             <xs:fractionDigits value="2"/>
>       </xs:restriction>
> </xs:simpleType>
> 
> 2. Then wdefined an Element of that type (Amount), whith a 
> restriction to have an attribute date that is required and...
> 
> <xs:element name="Amount" maxOccurs="unbounded">
>       <xs:complexType>
>             <xs:simpleContent>
>                   <xs:extension base="ValueType">
>                         <xs:attribute name="date" use="required">
>                               <xs:simpleType>
>                                     <xs:restriction base="xs:date"/>
>                               </xs:simpleType>
>                         </xs:attribute>
>                   </xs:extension>
>             </xs:simpleContent>
>       </xs:complexType>
> </xs:element>
> 
> Guess what happens... (you wont, you can run this example 
> using the following cmd):
> 
>   java -cp example.jar;xercesImpl.jar;xmlParserApi.jar Validator
> 
> And amazingly for a simple xml file (that you can find inside 
> the jar), the output will be:
> 
> [Error] :4:28: cvc-complex-type.3.2.2: Attribute 'date' is 
> not allowed to appear in element 'Amount'. [Error] :4:28: 
> cvc-complex-type.4: Attribute 'date' must appear on element 
> 'Amount'. [Error] :5:28: cvc-complex-type.3.2.2: Attribute 
> 'date' is not allowed to appear in element 'Amount'. [Error] 
> :5:28: cvc-complex-type.4: Attribute 'date' must appear on 
> element 'Amount'.
> 
> Can anyone tell me why is this happening ????
> 
> Best Regards,
> 
> Luís Pereira
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 
> #### example.jar has been removed from this note on June 30 
> 2003 by Sandy Gao
> 
> 
> 
> ---------------------------------------------------------------------
> 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