Commit ea152c05 authored by William M. Brack's avatar William M. Brack
Browse files

Further enhancement for XPath streaming, consolidated with schemas usage

* pattern.c, xpath.c, include/libxml/pattern.h: Further
  enhancement for XPath streaming, consolidated with
  schemas usage of pattern.c.  Added a new enum
  xmlPatternFlags.
* doc/*, testapi.c, elfgcchack.h: updated to reflect new
  enum.
* test/XPath/tests/mixedpat, test/XPath/docs/mixed,
  result/XPath/mixedpat: added regression test for problems
  reported in bug306348
parent 1c720df4
Wed Jun 9 11:07:42 PDT 2005 William Brack <wbrack@mmm.com.hk>
* pattern.c, xpath.c, include/libxml/pattern.h: Further
enhancement for XPath streaming, consolidated with
schemas usage of pattern.c. Added a new enum
xmlPatternFlags.
* doc/*, testapi.c, elfgcchack.h: updated to reflect new
enum.
* test/XPath/tests/mixedpat, test/XPath/docs/mixed,
result/XPath/mixedpat: added regression test for problems
reported in bug306348
Thu Jun 9 16:51:31 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemastypes.c: Changed non-prefixed QNames to be bound to a
......
......@@ -856,10 +856,15 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-parserInternals.html#xmlSwitchEncoding">xmlSwitchEncoding</a><br />
<a href="html/libxml-parserInternals.html#xmlSwitchInputEncoding">xmlSwitchInputEncoding</a><br />
<a href="html/libxml-parserInternals.html#xmlSwitchToEncoding">xmlSwitchToEncoding</a><br />
</p><h2><a name="pattern" id="pattern">Module pattern</a>:</h2><p><a href="html/libxml-pattern.html#xmlFreePattern">xmlFreePattern</a><br />
</p><h2><a name="pattern" id="pattern">Module pattern</a>:</h2><p><a href="html/libxml-pattern.html#XML_PATTERN_DEFAULT">XML_PATTERN_DEFAULT</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_XPATH">XML_PATTERN_XPATH</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_XSFIELD">XML_PATTERN_XSFIELD</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_XSSEL">XML_PATTERN_XSSEL</a><br />
<a href="html/libxml-pattern.html#xmlFreePattern">xmlFreePattern</a><br />
<a href="html/libxml-pattern.html#xmlFreePatternList">xmlFreePatternList</a><br />
<a href="html/libxml-pattern.html#xmlFreeStreamCtxt">xmlFreeStreamCtxt</a><br />
<a href="html/libxml-pattern.html#xmlPattern">xmlPattern</a><br />
<a href="html/libxml-pattern.html#xmlPatternFlags">xmlPatternFlags</a><br />
<a href="html/libxml-pattern.html#xmlPatternFromRoot">xmlPatternFromRoot</a><br />
<a href="html/libxml-pattern.html#xmlPatternGetStreamCtxt">xmlPatternGetStreamCtxt</a><br />
<a href="html/libxml-pattern.html#xmlPatternMatch">xmlPatternMatch</a><br />
......
......@@ -1705,6 +1705,7 @@ A:link, A:visited, A:active { text-decoration: underline }
</p><h2>Type xmlParserNodeInfoSeqPtr:</h2><p><a href="html/libxml-parser.html#xmlClearNodeInfoSeq">xmlClearNodeInfoSeq</a><br />
<a href="html/libxml-parser.html#xmlInitNodeInfoSeq">xmlInitNodeInfoSeq</a><br />
</p><h2>Type xmlParserSeverities:</h2><p><a href="html/libxml-xmlreader.html#xmlTextReaderErrorFunc">xmlTextReaderErrorFunc</a><br />
</p><h2>Type xmlPatternFlags:</h2><p><a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
</p><h2>Type xmlPatternPtr:</h2><p><a href="html/libxml-pattern.html#xmlFreePattern">xmlFreePattern</a><br />
<a href="html/libxml-pattern.html#xmlFreePatternList">xmlFreePatternList</a><br />
<a href="html/libxml-pattern.html#xmlPatternFromRoot">xmlPatternFromRoot</a><br />
......
......@@ -558,6 +558,10 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-parser.html#XML_PARSE_SAX1">XML_PARSE_SAX1</a><br />
<a href="html/libxml-parser.html#XML_PARSE_UNKNOWN">XML_PARSE_UNKNOWN</a><br />
<a href="html/libxml-parser.html#XML_PARSE_XINCLUDE">XML_PARSE_XINCLUDE</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_DEFAULT">XML_PATTERN_DEFAULT</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_XPATH">XML_PATTERN_XPATH</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_XSFIELD">XML_PATTERN_XSFIELD</a><br />
<a href="html/libxml-pattern.html#XML_PATTERN_XSSEL">XML_PATTERN_XSSEL</a><br />
<a href="html/libxml-tree.html#XML_PI_NODE">XML_PI_NODE</a><br />
<a href="html/libxml-xmlreader.html#XML_READER_TYPE_ATTRIBUTE">XML_READER_TYPE_ATTRIBUTE</a><br />
<a href="html/libxml-xmlreader.html#XML_READER_TYPE_CDATA">XML_READER_TYPE_CDATA</a><br />
......@@ -2336,6 +2340,7 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-globals.html#xmlParserVersion">xmlParserVersion</a><br />
<a href="html/libxml-xmlerror.html#xmlParserWarning">xmlParserWarning</a><br />
<a href="html/libxml-pattern.html#xmlPattern">xmlPattern</a><br />
<a href="html/libxml-pattern.html#xmlPatternFlags">xmlPatternFlags</a><br />
<a href="html/libxml-pattern.html#xmlPatternFromRoot">xmlPatternFromRoot</a><br />
<a href="html/libxml-pattern.html#xmlPatternGetStreamCtxt">xmlPatternGetStreamCtxt</a><br />
<a href="html/libxml-pattern.html#xmlPatternMatch">xmlPatternMatch</a><br />
......
......@@ -12,6 +12,7 @@ A:link, A:visited, A:active { text-decoration: underline }
pre.programlisting {border-style: double;background: #EECFA1}
</style><title>Module pattern from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module pattern from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a style="font-weight:bold" href="../index.html">Main Menu</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../examples/index.html">Code Examples</a></li><li><a style="font-weight:bold" href="index.html">API Menu</a></li><li><a href="libxml-parser.html">Parser API</a></li><li><a href="libxml-tree.html">Tree API</a></li><li><a href="libxml-xmlreader.html">Reader API</a></li><li><a href="../guidelines.html">XML Guidelines</a></li><li><a href="../ChangeLog.html">ChangeLog</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="../APIchunk0.html">Alphabetic</a></li><li><a href="../APIconstructors.html">Constructors</a></li><li><a href="../APIfunctions.html">Functions/Types</a></li><li><a href="../APIfiles.html">Modules</a></li><li><a href="../APIsymbols.html">Symbols</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://www.blastwave.org/packages.php/libxml2">Solaris binaries</a></li><li><a href="http://www.explain.com.au/oss/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://libxmlplusplus.sourceforge.net/">C++ bindings</a></li><li><a href="http://www.zend.com/php5/articles/php5-xmlphp.php#Heading4">PHP bindings</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://rubyforge.org/projects/xml-tools/">Ruby bindings</a></li><li><a href="http://tclxml.sourceforge.net/">Tcl bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-parserInternals.html"><img src="left.png" width="24" height="24" border="0" alt="Prev" /></a></td><th align="left"><a href="libxml-parserInternals.html">parserInternals</a></th><td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up" /></a></td><th align="left"><a href="index.html">API documentation</a></th><td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home" /></a></td><th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th><th align="right"><a href="libxml-relaxng.html">relaxng</a></th><td><a accesskey="n" href="libxml-relaxng.html"><img src="right.png" width="24" height="24" border="0" alt="Next" /></a></td></tr></table><p>allows to compile and test pattern expressions for nodes either in a tree or based on a parser state. </p><h2>Table of Contents</h2><pre class="programlisting">Structure <a href="#xmlPattern">xmlPattern</a><br />struct _xmlPattern
The content of this structure is not made public by the API.
</pre><pre class="programlisting">Enum <a href="#xmlPatternFlags">xmlPatternFlags</a>
</pre><pre class="programlisting">Typedef <a href="libxml-pattern.html#xmlPattern">xmlPattern</a> * <a name="xmlPatternPtr" id="xmlPatternPtr">xmlPatternPtr</a>
</pre><pre class="programlisting">Structure <a href="#xmlStreamCtxt">xmlStreamCtxt</a><br />struct _xmlStreamCtxt
The content of this structure is not made public by the API.
......@@ -24,14 +25,20 @@ The content of this structure is not made public by the API.
<pre class="programlisting">int <a href="#xmlPatternMatch">xmlPatternMatch</a> (<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp, <br /> <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> node)</pre>
<pre class="programlisting">int <a href="#xmlPatternMaxDepth">xmlPatternMaxDepth</a> (<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)</pre>
<pre class="programlisting">int <a href="#xmlPatternStreamable">xmlPatternStreamable</a> (<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)</pre>
<pre class="programlisting"><a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> <a href="#xmlPatterncompile">xmlPatterncompile</a> (const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br /> <a href="libxml-dict.html#xmlDict">xmlDict</a> * dict, <br /> int flags, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)</pre>
<pre class="programlisting"><a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> <a href="#xmlPatterncompile">xmlPatterncompile</a> (const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br /> <a href="libxml-dict.html#xmlDict">xmlDict</a> * dict, <br /> <a href="libxml-pattern.html#xmlPatternFlags">xmlPatternFlags</a> flags, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)</pre>
<pre class="programlisting">int <a href="#xmlStreamPop">xmlStreamPop</a> (<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream)</pre>
<pre class="programlisting">int <a href="#xmlStreamPush">xmlStreamPush</a> (<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * ns)</pre>
<pre class="programlisting">int <a href="#xmlStreamPushAttr">xmlStreamPushAttr</a> (<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * ns)</pre>
<h2>Description</h2>
<h3><a name="xmlPattern" id="xmlPattern">Structure xmlPattern</a></h3><pre class="programlisting">Structure xmlPattern<br />struct _xmlPattern {
The content of this structure is not made public by the API.
}</pre><h3><a name="xmlStreamCtxt" id="xmlStreamCtxt">Structure xmlStreamCtxt</a></h3><pre class="programlisting">Structure xmlStreamCtxt<br />struct _xmlStreamCtxt {
}</pre><h3>Enum <a name="xmlPatternFlags" id="xmlPatternFlags">xmlPatternFlags</a></h3><pre class="programlisting">Enum xmlPatternFlags {
<a name="XML_PATTERN_DEFAULT" id="XML_PATTERN_DEFAULT">XML_PATTERN_DEFAULT</a> = 0 : simple pattern match
<a name="XML_PATTERN_XPATH" id="XML_PATTERN_XPATH">XML_PATTERN_XPATH</a> = 1 : standard XPath pattern
<a name="XML_PATTERN_XSSEL" id="XML_PATTERN_XSSEL">XML_PATTERN_XSSEL</a> = 2 : XPath subset for schema selector
<a name="XML_PATTERN_XSFIELD" id="XML_PATTERN_XSFIELD">XML_PATTERN_XSFIELD</a> = 4 : XPath subset for schema field
}
</pre><h3><a name="xmlStreamCtxt" id="xmlStreamCtxt">Structure xmlStreamCtxt</a></h3><pre class="programlisting">Structure xmlStreamCtxt<br />struct _xmlStreamCtxt {
The content of this structure is not made public by the API.
}</pre><h3><a name="xmlFreePattern" id="xmlFreePattern"></a>Function: xmlFreePattern</h3><pre class="programlisting">void xmlFreePattern (<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)<br />
</pre><p>Free up the memory allocated by @comp</p>
......@@ -49,7 +56,7 @@ The content of this structure is not made public by the API.
</pre><p>Check the maximum depth reachable by a pattern</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>-2 if no limit (using //), otherwise the depth, and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlPatternStreamable" id="xmlPatternStreamable"></a>Function: xmlPatternStreamable</h3><pre class="programlisting">int xmlPatternStreamable (<a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> comp)<br />
</pre><p>Check if the pattern is streamable i.e. xmlPatternGetStreamCtxt() should work.</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if streamable, 0 if not and -1 in case of error.</td></tr></tbody></table></div><h3><a name="xmlPatterncompile" id="xmlPatterncompile"></a>Function: xmlPatterncompile</h3><pre class="programlisting"><a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> xmlPatterncompile (const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br /> <a href="libxml-dict.html#xmlDict">xmlDict</a> * dict, <br /> int flags, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)<br />
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>comp</tt></i>:</span></td><td>the precompiled pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if streamable, 0 if not and -1 in case of error.</td></tr></tbody></table></div><h3><a name="xmlPatterncompile" id="xmlPatterncompile"></a>Function: xmlPatterncompile</h3><pre class="programlisting"><a href="libxml-pattern.html#xmlPatternPtr">xmlPatternPtr</a> xmlPatterncompile (const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * pattern, <br /> <a href="libxml-dict.html#xmlDict">xmlDict</a> * dict, <br /> <a href="libxml-pattern.html#xmlPatternFlags">xmlPatternFlags</a> flags, <br /> const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> ** namespaces)<br />
</pre><p>Compile a pattern.</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>the pattern to compile</td></tr><tr><td><span class="term"><i><tt>dict</tt></i>:</span></td><td>an optional dictionary for interned strings</td></tr><tr><td><span class="term"><i><tt>flags</tt></i>:</span></td><td>compilation flags, undefined yet</td></tr><tr><td><span class="term"><i><tt>namespaces</tt></i>:</span></td><td>the prefix definitions, array of [URI, prefix] or NULL</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the compiled form of the pattern or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlStreamPop" id="xmlStreamPop"></a>Function: xmlStreamPop</h3><pre class="programlisting">int xmlStreamPop (<a href="libxml-pattern.html#xmlStreamCtxtPtr">xmlStreamCtxtPtr</a> stream)<br />
</pre><p>push one level from the stream.</p>
......
......@@ -951,8 +951,13 @@
<summary>pattern expression handling</summary>
<description>allows to compile and test pattern expressions for nodes either in a tree or based on a parser state. </description>
<author>Daniel Veillard </author>
<exports symbol='xmlStreamCtxt' type='typedef'/>
<exports symbol='XML_PATTERN_DEFAULT' type='enum'/>
<exports symbol='XML_PATTERN_XSFIELD' type='enum'/>
<exports symbol='XML_PATTERN_XSSEL' type='enum'/>
<exports symbol='XML_PATTERN_XPATH' type='enum'/>
<exports symbol='xmlStreamCtxtPtr' type='typedef'/>
<exports symbol='xmlPatternFlags' type='typedef'/>
<exports symbol='xmlStreamCtxt' type='typedef'/>
<exports symbol='xmlPattern' type='typedef'/>
<exports symbol='xmlPatternPtr' type='typedef'/>
<exports symbol='xmlPatternGetStreamCtxt' type='function'/>
......@@ -4739,6 +4744,10 @@
<enum name='XML_PARSE_SAX1' file='parser' value='512' type='xmlParserOption' info='use the SAX1 interface internally'/>
<enum name='XML_PARSE_UNKNOWN' file='parser' value='0' type='xmlParserMode'/>
<enum name='XML_PARSE_XINCLUDE' file='parser' value='1024' type='xmlParserOption' info='Implement XInclude substitition'/>
<enum name='XML_PATTERN_DEFAULT' file='pattern' value='0' type='xmlPatternFlags' info='simple pattern match'/>
<enum name='XML_PATTERN_XPATH' file='pattern' value='1' type='xmlPatternFlags' info='standard XPath pattern'/>
<enum name='XML_PATTERN_XSFIELD' file='pattern' value='4' type='xmlPatternFlags' info=' XPath subset for schema field'/>
<enum name='XML_PATTERN_XSSEL' file='pattern' value='2' type='xmlPatternFlags' info='XPath subset for schema selector'/>
<enum name='XML_PI_NODE' file='tree' value='7' type='xmlElementType'/>
<enum name='XML_READER_TYPE_ATTRIBUTE' file='xmlreader' value='2' type='xmlReaderTypes'/>
<enum name='XML_READER_TYPE_CDATA' file='xmlreader' value='4' type='xmlReaderTypes'/>
......@@ -5942,6 +5951,7 @@ actually an xmlCharEncoding'/>
<typedef name='xmlParserProperties' file='xmlreader' type='enum'/>
<typedef name='xmlParserSeverities' file='xmlreader' type='enum'/>
<struct name='xmlPattern' file='pattern' type='struct _xmlPattern'/>
<typedef name='xmlPatternFlags' file='pattern' type='enum'/>
<typedef name='xmlPatternPtr' file='pattern' type='xmlPattern *'/>
<struct name='xmlRMutex' file='threads' type='struct _xmlRMutex'/>
<typedef name='xmlRMutexPtr' file='threads' type='xmlRMutex *'/>
......@@ -11641,7 +11651,7 @@ actually an xmlCharEncoding'/>
<return type='xmlPatternPtr' info='the compiled form of the pattern or NULL in case of error'/>
<arg name='pattern' type='const xmlChar *' info='the pattern to compile'/>
<arg name='dict' type='xmlDict *' info='an optional dictionary for interned strings'/>
<arg name='flags' type='int' info='compilation flags, undefined yet'/>
<arg name='flags' type='xmlPatternFlags' info='compilation flags, undefined yet'/>
<arg name='namespaces' type='const xmlChar **' info='the prefix definitions, array of [URI, prefix] or NULL'/>
</function>
<function name='xmlPedanticParserDefault' file='parser' module='parserInternals'>
......@@ -552,6 +552,10 @@
<reference name='XML_PARSE_SAX1' href='html/libxml-parser.html#XML_PARSE_SAX1'/>
<reference name='XML_PARSE_UNKNOWN' href='html/libxml-parser.html#XML_PARSE_UNKNOWN'/>
<reference name='XML_PARSE_XINCLUDE' href='html/libxml-parser.html#XML_PARSE_XINCLUDE'/>
<reference name='XML_PATTERN_DEFAULT' href='html/libxml-pattern.html#XML_PATTERN_DEFAULT'/>
<reference name='XML_PATTERN_XPATH' href='html/libxml-pattern.html#XML_PATTERN_XPATH'/>
<reference name='XML_PATTERN_XSFIELD' href='html/libxml-pattern.html#XML_PATTERN_XSFIELD'/>
<reference name='XML_PATTERN_XSSEL' href='html/libxml-pattern.html#XML_PATTERN_XSSEL'/>
<reference name='XML_PI_NODE' href='html/libxml-tree.html#XML_PI_NODE'/>
<reference name='XML_READER_TYPE_ATTRIBUTE' href='html/libxml-xmlreader.html#XML_READER_TYPE_ATTRIBUTE'/>
<reference name='XML_READER_TYPE_CDATA' href='html/libxml-xmlreader.html#XML_READER_TYPE_CDATA'/>
......@@ -2330,6 +2334,7 @@
<reference name='xmlParserVersion' href='html/libxml-globals.html#xmlParserVersion'/>
<reference name='xmlParserWarning' href='html/libxml-xmlerror.html#xmlParserWarning'/>
<reference name='xmlPattern' href='html/libxml-pattern.html#xmlPattern'/>
<reference name='xmlPatternFlags' href='html/libxml-pattern.html#xmlPatternFlags'/>
<reference name='xmlPatternFromRoot' href='html/libxml-pattern.html#xmlPatternFromRoot'/>
<reference name='xmlPatternGetStreamCtxt' href='html/libxml-pattern.html#xmlPatternGetStreamCtxt'/>
<reference name='xmlPatternMatch' href='html/libxml-pattern.html#xmlPatternMatch'/>
......@@ -3875,6 +3880,10 @@
<ref name='XML_PARSE_SAX1'/>
<ref name='XML_PARSE_UNKNOWN'/>
<ref name='XML_PARSE_XINCLUDE'/>
<ref name='XML_PATTERN_DEFAULT'/>
<ref name='XML_PATTERN_XPATH'/>
<ref name='XML_PATTERN_XSFIELD'/>
<ref name='XML_PATTERN_XSSEL'/>
<ref name='XML_PI_NODE'/>
<ref name='XML_READER_TYPE_ATTRIBUTE'/>
<ref name='XML_READER_TYPE_CDATA'/>
......@@ -5689,6 +5698,7 @@
<ref name='xmlParserVersion'/>
<ref name='xmlParserWarning'/>
<ref name='xmlPattern'/>
<ref name='xmlPatternFlags'/>
<ref name='xmlPatternFromRoot'/>
<ref name='xmlPatternGetStreamCtxt'/>
<ref name='xmlPatternMatch'/>
......@@ -9345,6 +9355,9 @@
<type name='xmlParserSeverities'>
<ref name='xmlTextReaderErrorFunc'/>
</type>
<type name='xmlPatternFlags'>
<ref name='xmlPatterncompile'/>
</type>
<type name='xmlPatternPtr'>
<ref name='xmlFreePattern'/>
<ref name='xmlFreePatternList'/>
......@@ -10826,10 +10839,15 @@
<ref name='xmlSwitchToEncoding'/>
</file>
<file name='pattern'>
<ref name='XML_PATTERN_DEFAULT'/>
<ref name='XML_PATTERN_XPATH'/>
<ref name='XML_PATTERN_XSFIELD'/>
<ref name='XML_PATTERN_XSSEL'/>
<ref name='xmlFreePattern'/>
<ref name='xmlFreePatternList'/>
<ref name='xmlFreeStreamCtxt'/>
<ref name='xmlPattern'/>
<ref name='xmlPatternFlags'/>
<ref name='xmlPatternFromRoot'/>
<ref name='xmlPatternGetStreamCtxt'/>
<ref name='xmlPatternMatch'/>
......@@ -29,6 +29,20 @@ extern "C" {
typedef struct _xmlPattern xmlPattern;
typedef xmlPattern *xmlPatternPtr;
/**
* xmlPatternFlags:
*
* This is the set of options affecting the behaviour of pattern
* matching with this module
*
*/
typedef enum {
XML_PATTERN_DEFAULT = 0, /* simple pattern match */
XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */
XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */
XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */
} xmlPatternFlags;
XMLPUBFUN void XMLCALL
xmlFreePattern (xmlPatternPtr comp);
......@@ -38,7 +52,7 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN xmlPatternPtr XMLCALL
xmlPatterncompile (const xmlChar *pattern,
xmlDict *dict,
int flags,
xmlPatternFlags flags,
const xmlChar **namespaces);
XMLPUBFUN int XMLCALL
xmlPatternMatch (xmlPatternPtr comp,
......
......@@ -48,7 +48,10 @@
#define XML_STREAM_STEP_ROOT 4
#define XML_STREAM_STEP_ATTR 8
#define XML_PATTERN_NOTPATTERN 1
#define XML_PATTERN_NOTPATTERN (XML_PATTERN_XPATH | \
XML_PATTERN_XSSEL | \
XML_PATTERN_XSFIELD)
#define XML_PATTERN_XSD (XML_PATTERN_XSSEL | XML_PATTERN_XSFIELD)
typedef struct _xmlStreamStep xmlStreamStep;
typedef xmlStreamStep *xmlStreamStepPtr;
......@@ -119,16 +122,15 @@ struct _xmlStepOp {
const xmlChar *value2;
};
#define PAT_FROM_ROOT 1
#define PAT_FROM_CUR 2
#define PAT_FROM_ROOT (1<<8)
#define PAT_FROM_CUR (1<<9)
struct _xmlPattern {
void *data; /* the associated template */
xmlDictPtr dict; /* the optional dictionary */
struct _xmlPattern *next; /* next pattern if | is used */
const xmlChar *pattern; /* the pattern */
int flags; /* flags */
xmlPatternFlags flags; /* flags */
int nbStep;
int maxStep;
xmlStepOpPtr steps; /* ops for computation */
......@@ -692,11 +694,11 @@ rollback:
if (xmlPatternAdd(ctxt, ctxt->comp, (op), (val), (val2))) goto error;
#define XSLT_ERROR(X) \
{ xsltError(ctxt, __FILE__, __LINE__, X); \
{ xsltError(ctxt, __FILE__, __LINE__, X); \
ctxt->error = (X); return; }
#define XSLT_ERROR0(X) \
{ xsltError(ctxt, __FILE__, __LINE__, X); \
{ xsltError(ctxt, __FILE__, __LINE__, X); \
ctxt->error = (X); return(0); }
#if 0
......@@ -1047,8 +1049,8 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
}
if (i >= ctxt->nb_namespaces) {
ERROR5(NULL, NULL, NULL,
"xmlCompileStepPattern : no namespace bound to prefix %s\n",
prefix);
"xmlCompileStepPattern : no namespace bound "
"to prefix %s\n", prefix);
ctxt->error = 1;
goto error;
}
......@@ -1122,9 +1124,10 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) {
SKIP_BLANKS;
if (CUR == '/') {
ctxt->comp->flags |= PAT_FROM_ROOT;
} else if (CUR == '.') {
} else if ((CUR == '.') || (ctxt->comp->flags & XML_PATTERN_NOTPATTERN)) {
ctxt->comp->flags |= PAT_FROM_CUR;
}
if ((CUR == '/') && (NXT(1) == '/')) {
PUSH(XML_OP_ANCESTOR, NULL, NULL);
NEXT;
......@@ -1581,9 +1584,9 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
*/
if (comp->nbStep == 0) {
/*
* For non-pattern like evaluation like XML Schema IDCs,
* this will match if we are at the first level only,
* otherwise on every level.
* For non-pattern like evaluation like XML Schema IDCs
* or traditional XPath expressions, this will match if
* we are at the first level only, otherwise on every level.
*/
if ((nodeType == XML_ELEMENT_NODE) &&
(((stream->flags & XML_PATTERN_NOTPATTERN) == 0) ||
......@@ -1593,18 +1596,20 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
stream->level++;
goto stream_next;
}
tmp = stream->level;
for (i = 0; i < comp->nbStep; i++) {
if (comp->steps[i].flags & XML_STREAM_STEP_DESC) {
tmp = -2;
break;
if ((stream->flags & XML_PATTERN_NOTPATTERN) != 0) {
tmp = stream->level;
for (i = 0; i < comp->nbStep; i++) {
if (comp->steps[i].flags & XML_STREAM_STEP_DESC) {
tmp = -2;
break;
}
}
if (comp->nbStep <= tmp) {
stream->level++;
goto stream_next;
}
}
if (comp->nbStep < tmp) {
stream->level++;
goto stream_next;
}
}
/*
* Check evolution of existing states
*/
......@@ -1685,7 +1690,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
*/
desc = comp->steps[0].flags & XML_STREAM_STEP_DESC;
if ( ((comp->steps[0].flags & XML_STREAM_STEP_ROOT) == 0) &&
( ((stream->flags & XML_PATTERN_NOTPATTERN) == 0) ||
( ((stream->flags & XML_PATTERN_XSD) == 0) ||
( (desc || (stream->level == 1)) )
)
) {
......@@ -1709,48 +1714,26 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
if (!(comp->steps[0].flags & XML_STREAM_STEP_ROOT)) {
#endif
*/
match = 0;
if (comp->dict) {
if (comp->steps[0].name == NULL) {
if (comp->steps[0].ns == NULL)
match = 1;
else
if (comp->steps[0].name == NULL) {
if (comp->steps[0].ns == NULL)
match = 1;
else {
if (comp->dict)
match = (comp->steps[0].ns == ns);
} else {
if (stream->flags & XML_PATTERN_NOTPATTERN) {
/*
* Workaround for missing "self::node() on "foo".
*/
if (!desc) {
xmlStreamCtxtAddState(stream, 0, stream->level);
goto stream_next;
} else {
match = ((comp->steps[0].name == name) &&
(comp->steps[0].ns == ns));
}
} else {
match = ((comp->steps[0].name == name) &&
(comp->steps[0].ns == ns));
}
}
} else {
if (comp->steps[0].name == NULL) {
if (comp->steps[0].ns == NULL)
match = 1;
else
match = xmlStrEqual(comp->steps[0].ns, ns);
}
} else {
if ((stream->flags & XML_PATTERN_XSD) && (!desc)) {
/*
* Workaround for missing "self::node() on "foo".
*/
xmlStreamCtxtAddState(stream, 0, stream->level);
goto stream_next;
} else {
if (stream->flags & XML_PATTERN_NOTPATTERN) {
/*
* Workaround for missing "self::node() on "foo".
*/
if (!desc) {
xmlStreamCtxtAddState(stream, 0, stream->level);
goto stream_next;
} else {
match = ((xmlStrEqual(comp->steps[0].name, name)) &&
(xmlStrEqual(comp->steps[0].ns, ns)));
}
if (comp->dict) {
match = ((comp->steps[0].name == name) &&
(comp->steps[0].ns == ns));
} else {
match = ((xmlStrEqual(comp->steps[0].name, name)) &&
(xmlStrEqual(comp->steps[0].ns, ns)));
......@@ -1873,7 +1856,7 @@ xmlStreamPop(xmlStreamCtxtPtr stream) {
*/
xmlPatternPtr
xmlPatterncompile(const xmlChar *pattern, xmlDict *dict,
int flags ATTRIBUTE_UNUSED,
xmlPatternFlags flags,
const xmlChar **namespaces) {
xmlPatternPtr ret = NULL, cur;
xmlPatParserContextPtr ctxt = NULL;
......@@ -1933,8 +1916,10 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict,
xmlStreamCompile(cur);
if (xmlReversePattern(cur) < 0)
goto error;
if (tmp != NULL)
if (tmp != NULL) {
xmlFree(tmp);
tmp = NULL;
}
start = or;
}
if (streamable == 0) {
......
========================
Expression: s
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
========================
Expression: s|p1/s
Object is a Node Set :
Set contains 2 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
2 ELEMENT s
ATTRIBUTE p
TEXT
content=p1
========================
Expression: s|/root/p1/s
Object is a Node Set :
Set contains 2 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
2 ELEMENT s
ATTRIBUTE p
TEXT
content=p1
========================
Expression: /root/p1/s|s
Object is a Node Set :
Set contains 2 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
2 ELEMENT s
ATTRIBUTE p
TEXT
content=p1
========================
Expression: //s
Object is a Node Set :
Set contains 3 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
2 ELEMENT s
ATTRIBUTE p
TEXT
content=p1
3 ELEMENT s
ATTRIBUTE p
TEXT
content=p2
========================
Expression: //s|p1
Object is a Node Set :
Set contains 4 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
2 ELEMENT p1
3 ELEMENT s
ATTRIBUTE p
TEXT
content=p1
4 ELEMENT s
ATTRIBUTE p
TEXT
content=p2
========================
Expression: p1|//s
Object is a Node Set :
Set contains 4 nodes:
1 ELEMENT s
ATTRIBUTE p
TEXT
content=root
2 ELEMENT p1
3 ELEMENT s
ATTRIBUTE p
TEXT
content=p1
4 ELEMENT s
ATTRIBUTE p
TEXT
content=p2
<?xml version="1.0"?>
<root>
<s p="root"/>
<p1>
<s p="p1"/>
</p1>
<p2>
<s p="p2"/>
</p2>
</root>
s
s|p1/s
s|/root/p1/s
/root/p1/s|s
//s
//s|p1
p1|//s
......@@ -1053,6 +1053,21 @@ static void des_xmlElementTypeVal(int no ATTRIBUTE_UNUSED, xmlElementTypeVal val
static void desret_xmlParserErrors(xmlParserErrors val ATTRIBUTE_UNUSED) {
}
#ifdef LIBXML_PATTERN_ENABLED
#define gen_nb_xmlPatternFlags 4
static xmlPatternFlags gen_xmlPatternFlags(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 1) return(XML_PATTERN_DEFAULT);
if (no == 2) return(XML_PATTERN_XPATH);
if (no == 3) return(XML_PATTERN_XSFIELD);
if (no == 4) return(XML_PATTERN_XSSEL);
return(0);
}
static void des_xmlPatternFlags(int no ATTRIBUTE_UNUSED, xmlPatternFlags val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
#endif
#ifdef LIBXML_SCHEMAS_ENABLED
#define gen_nb_xmlSchemaValType 4
static xmlSchemaValType gen_xmlSchemaValType(int no, int nr ATTRIBUTE_UNUSED) {
......@@ -11322,7 +11322,8 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
}
}
stream = xmlPatterncompile(str, dict, 0, &namespaces[0]);
stream = xmlPatterncompile(str, dict, XML_PATTERN_XPATH,
&namespaces[0]);
if ((stream != NULL) && (xmlPatternStreamable(stream) == 1)) {
comp = xmlXPathNewCompExpr();
if (comp == NULL) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment