You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by th...@ascentialsoftware.com on 2003/03/19 16:58:43 UTC

nillable, fixed and default XSD attributes

I recognize that it is more a pure XML question than a Xalan one, but just
in case someone has a good answer for me.

When looking at the XML Schema specification, if you declare an element with
nillable="true", you cannot use the fixed attribute (which, I guess makes
sense).
I did not find anything related to nillable="true" and the usage of a
default value.

By using the Xalan sample programs, here is what I found by experimentation
(more a Xerces test than a Xalan one, I suppose): if I have either a default
or fixed attribute on my element declaration, as well as nillable="true", no
errors are generated at the schema processing time, but when processing an
XML document, if it contains an empty element instance with xsi:nil="true",
then I get an error (Element [element name] with attribute xsi:nil=true must
be empty).

I understand the behavior when I have the fixed attribute (although an error
at schema processing time will be better), but I am not sure I understand
this behavior when I have the default attribute as the XML schema does not
seem to say that it is not allowed.

Any ideas? Did I miss something in the XML schema spec or is there a
potential Xerces bug?

Thomas

Re: nillable, fixed and default XSD attributes

Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.



Hi Thomas,

Your best bet is to create a minimal shema document and instance document
that illustrates your question and post that to the Xerces list.

I agree with you this seems confusing, since Xerces is adding the
default/fixed attribute, then complaining the element must be empty, but
I'm not enough of a schema expert to know the right way to handle this
situation.

Dave



                                                                                                                                 
                      thomas.cherel@ascentials                                                                                   
                      oftware.com                      To:      xalan-c-users@xml.apache.org                                     
                                                       cc:      (bcc: David N Bertoni/Cambridge/IBM)                             
                      03/19/2003 07:58 AM              Subject: nillable, fixed and default XSD attributes                       
                                                                                                                                 



I recognize that it is more a pure XML question than a Xalan one, but just
in case someone has a good answer for me.

When looking at the XML Schema specification, if you declare an element
with
nillable="true", you cannot use the fixed attribute (which, I guess makes
sense).
I did not find anything related to nillable="true" and the usage of a
default value.

By using the Xalan sample programs, here is what I found by experimentation
(more a Xerces test than a Xalan one, I suppose): if I have either a
default
or fixed attribute on my element declaration, as well as nillable="true",
no
errors are generated at the schema processing time, but when processing an
XML document, if it contains an empty element instance with xsi:nil="true",
then I get an error (Element [element name] with attribute xsi:nil=true
must
be empty).

I understand the behavior when I have the fixed attribute (although an
error
at schema processing time will be better), but I am not sure I understand
this behavior when I have the default attribute as the XML schema does not
seem to say that it is not allowed.

Any ideas? Did I miss something in the XML schema spec or is there a
potential Xerces bug?

Thomas