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 Joseph Kesselman <ke...@us.ibm.com> on 2002/08/06 19:18:49 UTC

Re: help with default= processing

This would be a DOM question more than a parser question, since you're 
asking about behavior of the model after the parser's done constructing 
it.

The current DOM spec is not schema-aware, so it wouldn't fill in the 
defaults automagically -- and adding that behavior would break 
compatability with DOM Level 2.

There was a proposal to add that capability in DOM Level 3, but I believe 
it was shot down in favor of a decision that users be told to explicitly 
revalidate the subtree if/when they wanted the defaults filled in.   I 
know there's been discussion of how to perform a revalidation in Xerces 
but I've lost track of whether there's a prototype you could call.

______________________________________
Joe Kesselman  / IBM Research

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


Re: help with default= processing

Posted by Roy Y Katz <ro...@fanniemae.com>.
Hello again,

I'm curious as to why a facility for a Schema defaults mechanism has been
defined without specifying how to access it (either from DOM, or from a
parser, for example).  Of what use then, is the Schema definition's default=
statement?
In any case,   You mentioned that a discussion of defaults processing
("revalidation"?) came up before, so I will search the mailing list for this
term.

Thanks,
Roey Katz

[disclaimer: the opinions expressed above are entirely my own and not of my
employer]


You wrote:

[snip]

> There was a proposal to add that capability in DOM Level 3, but I believe
> it was shot down in favor of a decision that users be told to explicitly
> revalidate the subtree if/when they wanted the defaults filled in.   I
> know there's been discussion of how to perform a revalidation in Xerces
> but I've lost track of whether there's a prototype you could call.



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


default= validation

Posted by Roy Y Katz <ro...@fanniemae.com>.
Hello,

I have written before regarding XML revalidation; my question now is
whether Xerces can supply default attributes.  I ran across this
paragraph in the Schema definition (http://www.w3.org/TR/xmlschema-1/)

  {value constraint} establishes a default or fixed value for an
element. If default is specified, and if the element
  being ·validated· is empty, then the canonical form of the supplied
constraint value becomes the [schema
  normalized value] of the ·validated· element in the
post-schema-validation infoset. If fixed is specified, then
  the element's content must either be empty, in which case fixed
behaves as default, or its value must match the
  supplied constraint value.

    NOTE: The provision of defaults for elements goes beyond what is
possible in XML 1.0 DTDs,
    and does not exactly correspond to defaults for attributes. In
particular, an element with a
    non-empty {value constraint} whose simple type definition includes
the empty string in its lexical
    space will nonetheless never receive that value, because the {value
constraint} will override it. 

Supposing I had Xerces' validation turned on and loaded a DOM. 
Does this imply that Xerces should fill in the empty elements with their
defaults from the Schema?
If I have:

--- Schema ---

<?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="test" default="DEFAULT"/>
        </xs:sequence>
     </xs:complexType>
  </xs:element>
</xs:schema>

--- XML input ---

<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
xsi:noNameSpaceSchemaLocation="/home/test/example-schema.xsd">
   <test/>
</ROOT>

----

Then I expect that loading the above XML file would be the same as
loading

  .
  .
  .
  <test>DEFAULT</test>
  .
  .
  .

and that calling <test>.getNodeValue() would return "DEFAULT".
Are my assumptions correct?


Thanks!
Roey Katz


[disclaimer:  the opinions expressed above are my own and not of my
employer]


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