Hi Mukul,

Thanks for your continued effort on the assertions implementation and
welcome to the community Ken. :-)

I've had a few thoughts about the DOM construction for the XPath processor
which I'd like to share:

>From a performance perspective I think it would be good if the DOM being
built could be shared with assertions which start within the scope of the
outermost assertion which triggered the DOM construction. Then you're only
ever building one DOM tree at a time. These details could be hidden beneath
the interface which the schema validator talks to so that it is possible to
plug in other XPath 2.0 engines which may not necessarily take DOM as an
input.

We could be clever about how much of the DOM we build by analyzing the
XPath expressions, for example a/b/c isn't going to need to look deeper
than 3 elements so could avoid constructing many subtrees if we recognize
that they won't be traversed. Might also be interesting to have a smarter
path when the input to the validator is DOM where we could just use the
application's DOM instead of building a new one.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [email protected]
E-mail: [email protected]

Mukul Gandhi <[email protected]> wrote on 04/10/2009 12:46:16 AM:

> Hi all,
>    Some of you might be remembering, that I started to implement XML
> Schema 1.1 assertions into Xerces. Since last few days, I have started
> to put an effort again to complete the Xerces assertions support.
>
> I am happy to share that, Ken Cai is working with me on assertions
> implementation.
>
> We are sending this mail to the xerces-j-dev community, to share the
> "assertions design" thoughts so far. It would be great, if any one
> would like to suggest any improvements, or has any thoughts about
> assertions implementation.
>
> The assertions traversal code is written into Xerces and available at
> the online SVN repository. The development of XPath 2.0 integration
> code is underway. After the XPath 2.0 integration code is complete, a
> complete assertions support in Xerces would be ready for use.
>
> Ken has shared with me in a personal mail, a generic assertions
> interface to the XPath 2.0 engine. This interface looks like
> following:
>
> public interface XMLAssert {
>    public void initXPathProcessor(Document xdmRoot) throws Exception;
>    public void initXPathProcessor(InputStream is) throws Exception,
> IOException;
>    public void setNamespace(String prefix, String uri);
>    public void setSchema(XSModel schema);
>    public void setValidating(boolean validate);
>    public boolean evaluateXpathExpression(String xpathExpression)
> throws Exception;
> }
>
> For each specific XPath 2.0 engine, this interface needs to be
> implemented. Ken has also written and shared with me, an
> implementation of this interface, for the Psychopath XPath 2.0 engine.
>
> I would be working to integrate Ken's code with the XPath 2.0
> assertions code I am writing. We'll post all the newly written and
> modified assertions code with a JIRA issue after some time (may be few
> days later) (after ensuring good quality).
>
> Currently, I am trying to modify the Xerces class,
> "XMLSchemaValidator" to support assertions. The basic framework would
> like following:
>
> public class XMLSchemaValidator .. { ...
>
>  // some stuff here
>
>  public void startElement(QName element, XMLAttributes attributes,
>           Augmentations augs) throws XNIException {
>
>     // some stuff here
>
>     XSTypeDefinition typeDef = fCurrentPSVI.getTypeDefinition();
>
>    if (typeDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
>       XSComplexTypeDefinition complexTypeDef =
> (XSComplexTypeDefinition) typeDef;
>       XSObjectList assertions = complexTypeDef.getAssertions();
>       if (assertions.getLength() > 0) {
>          // do something here
>       }
>    }
>    else if (typeDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
>       XSSimpleTypeDefinition simpleTypeDef = (XSSimpleTypeDefinition)
typeDef;
>       XSObjectList facets = simpleTypeDef.getMultiValueFacets();
>       for (int i = 0; i < facets.getLength(); i++) {
>          XSMultiValueFacet facet = (XSMultiValueFacet) facets.item(i);
>          if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT)
{
>            // do something here
>          }
>        }
>     }
>
>    // if assertions are present, start building an XML tree with
> this element as
>    // a root of the tree.
>
>    // some stuff here
>
>  }
>
>
>  public void endElement(QName element, Augmentations augs)
>    throws XNIException {
>
>    // some stuff here
>
>    // end tree construction
>
>    // evaluate assertions on this tree. throw error if assertion
> evaluation is false.
>
>    // some stuff here
>
>  }
>
>
>  public void characters(org.apache.xerces.xni.XMLString text,
> org.apache.xerces.xni.Augmentations augs) .. {
>
>    // some stuff here
>
>    // write code here to add text nodes to the assertions XML tree.
>
>    // some stuff here
>
>  }
>
>
> This is just a very high level design. The actual details in the final
> code may take a different shape.
>
> I'm hoping to have an initial complete assertions implementation quite
> soon. Please watch this space :)
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]

Reply via email to