Re: [xml] Initial identity-constraint implementation for XML Schemata



Hi,

Daniel Veillard wrote:
On Thu, Jan 27, 2005 at 04:28:09PM +0100, Kasimier Buchcik wrote:

Preparatory work for (2):
 - A streamable XPath engine would be perfect for IDCs, but since there
   is none yet available the XPath module is used to compile the IDC
   XPath expressions.


  Bzzz, checkout CVS :-)

You have 4 new APIs in pattern.h:

XMLPUBFUN xmlStreamCtxtPtr XMLCALL
                        xmlPatternGetStreamCtxt (xmlPatternPtr comp);
XMLPUBFUN void XMLCALL
                        xmlFreeStreamCtxt       (xmlStreamCtxtPtr stream);
XMLPUBFUN int XMLCALL
                        xmlStreamPush           (xmlStreamCtxtPtr stream,
                                                 const xmlChar *name,
                                                 const xmlChar *ns);
XMLPUBFUN int XMLCALL
                        xmlStreamPop            (xmlStreamCtxtPtr stream);

 Basically the operation is that you call
    push(name, ns) on all element start
    pop() on all element end
and push() returns 1 if the element matches the pattern.

 I't not yet fully completed, but works for simple cases, I added code
to test it in xmllint --stream --pattern .
 Things needing work:
   - compilation flags to check for specific syntaxes
using flags of xmlPatterncompile() - making clear how pattern starting with / or . need to be handled,
     currently push(NULL, NULL) means a reset of the streaming context
and indicating we are on / (the document node), probably need something similar for .
   - xmlPatterncompile support of namespaces arguments, I'm not sure
     it's implemented and definitely not tested
   - handling of disjunction "pattern1 | pattern2" mean needed to build
     and check a list internally
   - better testing, I'm pretty sure there is some bugs left in the
     engine :-)

So there is still a bit of work needed :-), APIs should be okay though.
For the last node() or attribute @foo needed specifically for schemas
patterns I suggest to handle them on top of the engine, I'm not sure
we want to add attributes to xmlStreamPush() for example.

The good part is that the XPath subset is so restricted that if can be done
in a very lightweight way, and I hope to be able to reuse that to speed
up significantly XPath implementaton for that subset by reusing it.

So quite a bit of work, but a lot of fun ahead,

Daniel

Coool!
I integrated it into the schema module. Works nice for the test schema
I'm using, didn't test special cases yet. Fixed some bugs in the IDC
code. I'll try to commit soon.

Thanks & regards,

Kasimier





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]