Commit ffa7b7e2 authored by Daniel Veillard's avatar Daniel Veillard

fixed the pattern interfaces but not yet the parser to handle the

* pattern.c xmlreader.c xmllint.c include/libxml/pattern.h
  include/libxml/xmlreader.h: fixed the pattern interfaces
  but not yet the parser to handle the namespaces.
* doc/examples/reader3.c doc/*: fixed the example, rebuilt the docs.
Daniel
parent 1e90661b
Fri Dec 5 17:07:29 CET 2003 Daniel Veillard <daniel@veillard.com>
* pattern.c xmlreader.c xmllint.c include/libxml/pattern.h
include/libxml/xmlreader.h: fixed the pattern interfaces
but not yet the parser to handle the namespaces.
* doc/examples/reader3.c doc/*: fixed the example, rebuilt the docs.
Fri Dec 5 15:49:44 CET 2003 Daniel Veillard <daniel@veillard.com>
* globals.c xmlwriter.c doc/apibuild.py include/libxml/globals.h
......
......@@ -184,7 +184,9 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-parser.html#startElementNsSAX2Func">startElementNsSAX2Func</a><br />
<a href="html/libxml-catalog.html#xmlLoadCatalog">xmlLoadCatalog</a><br />
<a href="html/libxml-catalog.html#xmlLoadCatalogs">xmlLoadCatalogs</a><br />
<a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
<a href="html/libxml-SAX2.html#xmlSAX2StartElementNs">xmlSAX2StartElementNs</a><br />
<a href="html/libxml-xmlreader.html#xmlTextReaderPreservePattern">xmlTextReaderPreservePattern</a><br />
<a href="html/libxml-valid.html#xmlValidateDtd">xmlValidateDtd</a><br />
</dd><dt>delayed</dt><dd><a href="html/libxml-xmlIO.html#xmlOutputBufferWrite">xmlOutputBufferWrite</a><br />
<a href="html/libxml-xmlIO.html#xmlOutputBufferWriteString">xmlOutputBufferWriteString</a><br />
......
......@@ -682,9 +682,11 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-parser.html#startElementSAXFunc">startElementSAXFunc</a><br />
<a href="html/libxml-xlink.html#xlinkExtendedLinkFunk">xlinkExtendedLinkFunk</a><br />
<a href="html/libxml-xlink.html#xlinkExtendedLinkSetFunk">xlinkExtendedLinkSetFunk</a><br />
<a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
<a href="html/libxml-SAX2.html#xmlSAX2StartElement">xmlSAX2StartElement</a><br />
<a href="html/libxml-SAX2.html#xmlSAX2StartElementNs">xmlSAX2StartElementNs</a><br />
<a href="html/libxml-SAX2.html#xmlSAX2StartElementNs">xmlSAX2StartElementNs</a><br />
<a href="html/libxml-xmlreader.html#xmlTextReaderPreservePattern">xmlTextReaderPreservePattern</a><br />
<a href="html/libxml-valid.html#xmlValidGetPotentialChildren">xmlValidGetPotentialChildren</a><br />
<a href="html/libxml-valid.html#xmlValidGetValidElements">xmlValidGetValidElements</a><br />
</p><h2>Type const xmlListPtr:</h2><p><a href="html/libxml-list.html#xmlListCopy">xmlListCopy</a><br />
......
......@@ -35,7 +35,7 @@ extractFile(const char *filename, const xmlChar *pattern) {
/*
* add the pattern to preserve
*/
if (xmlTextReaderPreservePattern(reader, pattern) < 0) {
if (xmlTextReaderPreservePattern(reader, pattern, NULL) < 0) {
fprintf(stderr, "%s : failed add preserve pattern %s\n",
filename, (const char *) pattern);
}
......
......@@ -79,7 +79,7 @@ void <a href="#xmlTextReaderErrorFunc">xmlTextReaderErrorFunc</a> (void * arg,
<pre class="programlisting">int <a href="#xmlTextReaderNormalization">xmlTextReaderNormalization</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)</pre>
<pre class="programlisting"><a href="libxml-tree.html#xmlChar">xmlChar</a> * <a href="#xmlTextReaderPrefix">xmlTextReaderPrefix</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)</pre>
<pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> <a href="#xmlTextReaderPreserve">xmlTextReaderPreserve</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)</pre>
<pre class="programlisting">int <a href="#xmlTextReaderPreservePattern">xmlTextReaderPreservePattern</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br /> const <a href="libxml-tree.html#xmlChar">xmlChar</a> * pattern)</pre>
<pre class="programlisting">int <a href="#xmlTextReaderPreservePattern">xmlTextReaderPreservePattern</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br /> const <a href="libxml-tree.html#xmlChar">xmlChar</a> * pattern, <br /> const <a href="libxml-tree.html#xmlChar">xmlChar</a> ** namespaces)</pre>
<pre class="programlisting">int <a href="#xmlTextReaderQuoteChar">xmlTextReaderQuoteChar</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)</pre>
<pre class="programlisting">int <a href="#xmlTextReaderRead">xmlTextReaderRead</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)</pre>
<pre class="programlisting">int <a href="#xmlTextReaderReadAttributeValue">xmlTextReaderReadAttributeValue</a> (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)</pre>
......@@ -249,9 +249,9 @@ void xmlTextReaderErrorFunc (void * arg, <br /> const char * msg, <br />
</pre><p>A shorthand <a href="libxml-SAX.html#reference">reference</a> to the namespace associated with the node.</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the prefix or NULL if not available</td></tr></tbody></table></div><h3><a name="xmlTextReaderPreserve" id="xmlTextReaderPreserve"></a>Function: xmlTextReaderPreserve</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> xmlTextReaderPreserve (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
</pre><p>current node being accessed by the xmlTextReader. This is dangerous because the underlying node may be destroyed on the next Reads.</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> or NULL in case of error.</td></tr></tbody></table></div><h3><a name="xmlTextReaderPreservePattern" id="xmlTextReaderPreservePattern"></a>Function: xmlTextReaderPreservePattern</h3><pre class="programlisting">int xmlTextReaderPreservePattern (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br /> const <a href="libxml-tree.html#xmlChar">xmlChar</a> * pattern)<br />
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> or NULL in case of error.</td></tr></tbody></table></div><h3><a name="xmlTextReaderPreservePattern" id="xmlTextReaderPreservePattern"></a>Function: xmlTextReaderPreservePattern</h3><pre class="programlisting">int xmlTextReaderPreservePattern (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader, <br /> const <a href="libxml-tree.html#xmlChar">xmlChar</a> * pattern, <br /> const <a href="libxml-tree.html#xmlChar">xmlChar</a> ** namespaces)<br />
</pre><p>This tells the XML Reader to preserve all nodes matched by the pattern. The caller must also use xmlTextReaderCurrentDoc() to keep an handle on the resulting document once parsing has finished</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>an XPath subset pattern</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a positive number in case of success and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderQuoteChar" id="xmlTextReaderQuoteChar"></a>Function: xmlTextReaderQuoteChar</h3><pre class="programlisting">int xmlTextReaderQuoteChar (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>pattern</tt></i>:</span></td><td>an XPath subset pattern</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>a positive number in case of success and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderQuoteChar" id="xmlTextReaderQuoteChar"></a>Function: xmlTextReaderQuoteChar</h3><pre class="programlisting">int xmlTextReaderQuoteChar (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
</pre><p>The quotation mark character used to enclose the value of an attribute.</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>reader</tt></i>:</span></td><td>the <a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> used</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>&quot; or ' and -1 in case of error</td></tr></tbody></table></div><h3><a name="xmlTextReaderRead" id="xmlTextReaderRead"></a>Function: xmlTextReaderRead</h3><pre class="programlisting">int xmlTextReaderRead (<a href="libxml-xmlreader.html#xmlTextReaderPtr">xmlTextReaderPtr</a> reader)<br />
</pre><p>Moves the position of the current instance to the next node in the stream, exposing its properties.</p>
......
......@@ -10024,11 +10024,12 @@ actually an xmlCharEncoding'/>
<arg name='node' type='xmlNodePtr' info='a node'/>
</function>
<function name='xmlPatterncompile' file='pattern'>
<info>Compile a pattern</info>
<info>Compile a pattern.</info>
<return type='xmlPatternPtr' info='the compiled for 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 dictionnary for interned strings'/>
<arg name='flags' type='int' 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'>
<info>Set and return the previous value for enabling pedantic warnings.</info>
......@@ -11764,6 +11765,7 @@ actually an xmlCharEncoding'/>
<return type='int' info='a positive number in case of success and -1 in case of error'/>
<arg name='reader' type='xmlTextReaderPtr' info='the xmlTextReaderPtr used'/>
<arg name='pattern' type='const xmlChar *' info='an XPath subset pattern'/>
<arg name='namespaces' type='const xmlChar **' info='the prefix definitions, array of [URI, prefix] or NULL'/>
</function>
<function name='xmlTextReaderQuoteChar' file='xmlreader'>
<info>The quotation mark character used to enclose the value of an attribute.</info>
......
......@@ -7085,9 +7085,11 @@
<ref name='startElementSAXFunc'/>
<ref name='xlinkExtendedLinkFunk'/>
<ref name='xlinkExtendedLinkSetFunk'/>
<ref name='xmlPatterncompile'/>
<ref name='xmlSAX2StartElement'/>
<ref name='xmlSAX2StartElementNs'/>
<ref name='xmlSAX2StartElementNs'/>
<ref name='xmlTextReaderPreservePattern'/>
<ref name='xmlValidGetPotentialChildren'/>
<ref name='xmlValidGetValidElements'/>
</type>
......@@ -18242,7 +18244,9 @@
<ref name='startElementNsSAX2Func'/>
<ref name='xmlLoadCatalog'/>
<ref name='xmlLoadCatalogs'/>
<ref name='xmlPatterncompile'/>
<ref name='xmlSAX2StartElementNs'/>
<ref name='xmlTextReaderPreservePattern'/>
<ref name='xmlValidateDtd'/>
</word>
<word name='delayed'>
......@@ -36,7 +36,8 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN xmlPatternPtr XMLCALL
xmlPatterncompile (const xmlChar *pattern,
xmlDict *dict,
int flags);
int flags,
const xmlChar **namespaces);
XMLPUBFUN int XMLCALL
xmlPatternMatch (xmlPatternPtr comp,
xmlNodePtr node);
......
......@@ -198,7 +198,8 @@ XMLPUBFUN xmlNodePtr XMLCALL
xmlTextReaderPreserve (xmlTextReaderPtr reader);
XMLPUBFUN int XMLCALL
xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
const xmlChar *pattern);
const xmlChar *pattern,
const xmlChar **namespaces);
XMLPUBFUN xmlDocPtr XMLCALL
xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
XMLPUBFUN xmlNodePtr XMLCALL
......
......@@ -73,6 +73,8 @@ struct _xmlPatParserContext {
xmlDictPtr dict; /* the dictionnary if any */
xmlPatternPtr comp; /* the result */
xmlNodePtr elem; /* the current node if any */
const xmlChar **namespaces; /* the namespaces definitions */
int nb_namespaces; /* the number of namespaces */
};
/************************************************************************
......@@ -149,14 +151,16 @@ xmlFreePatternList(xmlPatternPtr comp) {
/**
* xmlNewPatParserContext:
* @pattern: the pattern context
* @ctxt: the transformation context, if done at run-time
* @dict: the inherited dictionnary or NULL
* @namespaces: the prefix definitions, array of [URI, prefix] or NULL
*
* Create a new XML pattern parser context
*
* Returns the newly allocated xmlPatParserContextPtr or NULL in case of error
*/
static xmlPatParserContextPtr
xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict) {
xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict,
const xmlChar **namespaces) {
xmlPatParserContextPtr cur;
if (pattern == NULL)
......@@ -172,6 +176,14 @@ xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict) {
cur->dict = dict;
cur->cur = pattern;
cur->base = pattern;
if (namespaces != NULL) {
int i;
for (i = 0;namespaces[2 * i] != NULL;i++);
cur->nb_namespaces = i;
} else {
cur->nb_namespaces = 0;
}
cur->namespaces = namespaces;
return(cur);
}
......@@ -871,17 +883,19 @@ error:
* @pattern: the pattern to compile
* @dict: an optional dictionnary for interned strings
* @flags: compilation flags, undefined yet
* @namespaces: the prefix definitions, array of [URI, prefix] or NULL
*
* Compile a pattern
* Compile a pattern.
*
* Returns the compiled for of the pattern or NULL in case of error
*/
xmlPatternPtr
xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags) {
xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
const xmlChar **namespaces) {
xmlPatternPtr ret = NULL;
xmlPatParserContextPtr ctxt = NULL;
ctxt = xmlNewPatParserContext(pattern, dict);
ctxt = xmlNewPatParserContext(pattern, dict, namespaces);
if (ctxt == NULL) goto error;
ret = xmlNewPattern();
if (ret == NULL) goto error;
......
......@@ -739,7 +739,6 @@ Class xmlTextReader(xmlTextReaderCore)
Normalization()
Prefix()
Preserve()
PreservePattern()
QuoteChar()
Read()
ReadAttributeValue()
......
......@@ -1881,7 +1881,7 @@ main(int argc, char **argv) {
#endif /* LIBXML_SCHEMAS_ENABLED */
#ifdef LIBXML_PATTERN_ENABLED
if (pattern != NULL) {
patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0);
patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
if (patternc == NULL) {
xmlGenericError(xmlGenericErrorContext,
"Pattern %s failed to compile\n", pattern);
......
......@@ -3554,6 +3554,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
* xmlTextReaderPreservePattern:
* @reader: the xmlTextReaderPtr used
* @pattern: an XPath subset pattern
* @namespaces: the prefix definitions, array of [URI, prefix] or NULL
*
* This tells the XML Reader to preserve all nodes matched by the
* pattern. The caller must also use xmlTextReaderCurrentDoc() to
......@@ -3562,13 +3563,15 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
* Returns a positive number in case of success and -1 in case of error
*/
int
xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern) {
xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern,
const xmlChar **namespaces)
{
xmlPatternPtr comp;
if ((reader == NULL) || (pattern == NULL))
return(-1);
comp = xmlPatterncompile(pattern, reader->dict, 0);
comp = xmlPatterncompile(pattern, reader->dict, 0, namespaces);
if (comp == NULL)
return(-1);
......
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