diff --git a/ChangeLog b/ChangeLog
index 1c1e255e..62e5d501 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Dec 5 17:07:29 CET 2003 Daniel Veillard
xmlLoadCatalog
xmlLoadCatalogs
+xmlPatterncompile
xmlSAX2StartElementNs
+xmlTextReaderPreservePattern
xmlValidateDtd
xmlOutputBufferWriteString
diff --git a/doc/APIfunctions.html b/doc/APIfunctions.html
index 5832dda8..c21ab2fd 100644
--- a/doc/APIfunctions.html
+++ b/doc/APIfunctions.html
@@ -682,9 +682,11 @@ A:link, A:visited, A:active { text-decoration: underline }
startElementSAXFunc
xlinkExtendedLinkFunk
xlinkExtendedLinkSetFunk
+xmlPatterncompile
xmlSAX2StartElement
xmlSAX2StartElementNs
xmlSAX2StartElementNs
+xmlTextReaderPreservePattern
xmlValidGetPotentialChildren
xmlValidGetValidElements
xmlListCopy
diff --git a/doc/examples/reader3.c b/doc/examples/reader3.c
index 715deeec..e9815cd8 100644
--- a/doc/examples/reader3.c
+++ b/doc/examples/reader3.c
@@ -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);
}
diff --git a/doc/html/libxml-xmlreader.html b/doc/html/libxml-xmlreader.html
index 083cd33e..17bd9957 100644
--- a/doc/html/libxml-xmlreader.html
+++ b/doc/html/libxml-xmlreader.html
@@ -79,7 +79,7 @@ void xmlTextReaderErrorFunc (void * arg,
int xmlTextReaderNormalization (xmlTextReaderPtr reader)
xmlChar * xmlTextReaderPrefix (xmlTextReaderPtr reader)
xmlNodePtr xmlTextReaderPreserve (xmlTextReaderPtr reader)-
int xmlTextReaderPreservePattern (xmlTextReaderPtr reader,+
const xmlChar * pattern)
int xmlTextReaderPreservePattern (xmlTextReaderPtr reader,
const xmlChar * pattern,
const xmlChar ** namespaces)
int xmlTextReaderQuoteChar (xmlTextReaderPtr reader)
int xmlTextReaderRead (xmlTextReaderPtr reader)
int xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader)@@ -249,9 +249,9 @@ void xmlTextReaderErrorFunc (void * arg,
A shorthand reference to the namespace associated with the node.
reader: | the xmlTextReaderPtr used |
Returns: | the prefix or NULL if not available |
xmlNodePtr xmlTextReaderPreserve (xmlTextReaderPtr reader)
current node being accessed by the xmlTextReader. This is dangerous because the underlying node may be destroyed on the next Reads.
-reader: | the xmlTextReaderPtr used |
Returns: | the xmlNodePtr or NULL in case of error. |
int xmlTextReaderPreservePattern (xmlTextReaderPtr reader,
const xmlChar * pattern)
+
reader: the xmlTextReaderPtr used Returns: the xmlNodePtr or NULL in case of error. Function: xmlTextReaderPreservePattern
int xmlTextReaderPreservePattern (xmlTextReaderPtr reader,
const xmlChar * pattern,
const xmlChar ** namespaces)
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
-
reader: the xmlTextReaderPtr used pattern: an XPath subset pattern Returns: a positive number in case of success and -1 in case of error Function: xmlTextReaderQuoteChar
int xmlTextReaderQuoteChar (xmlTextReaderPtr reader)
+
reader: the xmlTextReaderPtr used pattern: an XPath subset pattern namespaces: the prefix definitions, array of [URI, prefix] or NULL Returns: a positive number in case of success and -1 in case of error Function: xmlTextReaderQuoteChar
int xmlTextReaderQuoteChar (xmlTextReaderPtr reader)
The quotation mark character used to enclose the value of an attribute.
reader: the xmlTextReaderPtr used Returns: " or ' and -1 in case of error Function: xmlTextReaderRead
int xmlTextReaderRead (xmlTextReaderPtr reader)
Moves the position of the current instance to the next node in the stream, exposing its properties.
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 274a445d..155ba3f4 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -10024,11 +10024,12 @@ actually an xmlCharEncoding'/>- Compile a pattern +Compile a pattern. + Set and return the previous value for enabling pedantic warnings. @@ -11764,6 +11765,7 @@ actually an xmlCharEncoding'/>+ The quotation mark character used to enclose the value of an attribute. diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml index 1088559a..3169d24f 100644 --- a/doc/libxml2-refs.xml +++ b/doc/libxml2-refs.xml @@ -7085,9 +7085,11 @@ + + @@ -18242,7 +18244,9 @@ + +diff --git a/include/libxml/pattern.h b/include/libxml/pattern.h index bac6b4ef..9db9c4e7 100644 --- a/include/libxml/pattern.h +++ b/include/libxml/pattern.h @@ -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); diff --git a/include/libxml/xmlreader.h b/include/libxml/xmlreader.h index c9c79899..f4add562 100644 --- a/include/libxml/xmlreader.h +++ b/include/libxml/xmlreader.h @@ -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 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; diff --git a/python/libxml2class.txt b/python/libxml2class.txt index b73910b5..271dbebc 100644 --- a/python/libxml2class.txt +++ b/python/libxml2class.txt @@ -739,7 +739,6 @@ Class xmlTextReader(xmlTextReaderCore) Normalization() Prefix() Preserve() - PreservePattern() QuoteChar() Read() ReadAttributeValue() diff --git a/xmllint.c b/xmllint.c index 8cc8e581..37dc72e7 100644 --- a/xmllint.c +++ b/xmllint.c @@ -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); diff --git a/xmlreader.c b/xmlreader.c index 0295ddc3..0ce19db7 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -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);