Joseph Kesselman wrote:
> 3) The main thing that makes DOM revalidation different from other
> uses of a validation pipeline seems to be that it has a specialized
> builder which writes back to the same place that the validation is
> reading from -- that is, it attempts to annotate existing nodes as
> much as possible rather than discarding and rebuilding the entire
> tree.
> I honestly don't yet understand how Elena's code is doing that.
During revalidation the only new nodes which are added to the tree are
the nodes that represent default contents:
attributes or element default content (in XML Schemas). The rest of the
nodes are unchanged during re-validation process.
To add default attributes I've introduces AttributeProxy that implements
XMLAttributes. The attributeProxy holds reference to NodeNamedMap, and
when the XMLSchemaValidator calls attributes.addAttribute(), I add an
attribute to the NodeNamedMap.
Adding default element content is not implemented yet, but the idea is
that DOMNormalizer passes an augmentations object to the
RevalidationHandler. The handler adds elementPSVI information which
includes defaultElement content (if any).
In the DOMNormaliser the code will look as follows:
revalidationHandler.startElement(elementName, attributes, augmentations)
..
// process children if any
..
revalidationHandler.endElement(elementName, augmenations);
ElementPSVI psvi =
(ElementPSVImpl)augmentations.getItem(Constants.ELEMENT_PSVI);
String default = psvi.getSchemaDefault();
if (default!=null){
currentNode.appendChild (document.createTextNode(default));
}
The other modifications to the tree include:
a) update text value of element/ attribute nodes with the
schemaNormalizeValue (available in the psvi): the text node for that
data is already in the tree -- we will only replace a value of this text
node/or maybe remove the node completely..
b) augment tree with PSVI information -- update PSVIObject available on
the tree, or fields (depends on our implementation of PSVI).
> (Xalan doesn't have the same need -- we can and should generate a new
> tree to represent the new PSVI.)
In this case you need to register on the RevalidationHandler a
documentHandler. This can be done by calling
revalidationHandler.setDocumentHandler (since revalidation handler also
implements the XMLDocumentSource). I suspect you have code in place for
the document handler that allows to build a tree from the XNI events...
Thx,
--
Elena Litani / IBM Toronto
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]