aboutsummaryrefslogtreecommitdiffstats
path: root/pattern.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-12-05 16:10:21 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-12-05 16:10:21 +0000
commitffa7b7e2ba3841a80f9c5a69e89cc4b4e457840b (patch)
treef356168db9ab6ff414ed9525dda84c18b51a39ad /pattern.c
parent1e90661bb817402f85103c3b9d3ce6ebab570f38 (diff)
downloadandroid_external_libxml2-ffa7b7e2ba3841a80f9c5a69e89cc4b4e457840b.tar.gz
android_external_libxml2-ffa7b7e2ba3841a80f9c5a69e89cc4b4e457840b.tar.bz2
android_external_libxml2-ffa7b7e2ba3841a80f9c5a69e89cc4b4e457840b.zip
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
Diffstat (limited to 'pattern.c')
-rw-r--r--pattern.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/pattern.c b/pattern.c
index 01f974c3..5cac2df0 100644
--- a/pattern.c
+++ b/pattern.c
@@ -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;