> -----Original Message-----
> From: Mike Skells [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 20, 2005 2:34 AM
> To: [email protected]
> Subject: schema validation and default attributes
>
> When using the schema validation feature
> http://apache.org/xml/features/validation/schema then I have
> attributes set with the default values. Is this the expected
> behavior or a bug.
I'm a little unclear exactly what you are asking. When you turn schema validation on, xerces does what the schema spec tells it to do...which is to add default/fixed values to attributes (among other things) in the PSVI. What else should the xerces documentation say on this issue?
If you do a "simple" serialization of the PSVI, yes, those defaulted/fixed values will appear in the serialization. To serialize without the defaulted/fixed values, you'll have to write your own code that looks at org.apache.xerces.xs.ItemPSVI.getIsSchemaSpecified() [1].
As Joe has pointed this is no different from a DTD defaulting/fixing attribute values (expect that in schema it might also happen to element content as well as attribute values) and the need to examine org.w3c.dom.Attr.getSpecified() [2].
pvb
[1] http://xml.apache.org/xerces2-j/javadocs/xs/org/apache/xerces/xs/ItemPSVI.html#getIsSchemaSpecified()
[2] http://xml.apache.org/xerces2-j/javadocs/api/org/w3c/dom/Attr.html#getSpecified()
