aboutsummaryrefslogtreecommitdiffstats
path: root/xmllint.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2005-02-03 22:24:10 +0000
committerDaniel Veillard <veillard@src.gnome.org>2005-02-03 22:24:10 +0000
commitd4301aba26ab6d415be85a80b084bd91b3cfcc05 (patch)
tree337109da4c07cb4c26dd8ce63247c6b6933cc851 /xmllint.c
parent364fbed5af033155bfa4acab041388c473647532 (diff)
downloadandroid_external_libxml2-d4301aba26ab6d415be85a80b084bd91b3cfcc05.tar.gz
android_external_libxml2-d4301aba26ab6d415be85a80b084bd91b3cfcc05.tar.bz2
android_external_libxml2-d4301aba26ab6d415be85a80b084bd91b3cfcc05.zip
use the walker to test the patterns instead of the normal reader bug fixes
* Makefile.am: use the walker to test the patterns instead of the normal reader * pattern.c xmllint.c: bug fixes in the train including fixing the stupid build break. Daniel
Diffstat (limited to 'xmllint.c')
-rw-r--r--xmllint.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/xmllint.c b/xmllint.c
index 66ff16b2..94c66f74 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -910,6 +910,15 @@ static void streamFile(char *filename) {
#endif
reader = xmlReaderForFile(filename, NULL, options);
#ifdef LIBXML_PATTERN_ENABLED
+ if (pattern != NULL) {
+ patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
+ if (patternc == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "Pattern %s failed to compile\n", pattern);
+ progresult = XMLLINT_ERR_SCHEMAPAT;
+ pattern = NULL;
+ }
+ }
if (patternc != NULL) {
patstream = xmlPatternGetStreamCtxt(patternc);
if (patstream != NULL) {
@@ -1029,6 +1038,31 @@ static void walkDoc(xmlDocPtr doc) {
xmlTextReaderPtr reader;
int ret;
+#ifdef LIBXML_PATTERN_ENABLED
+ xmlNodePtr root;
+ const xmlChar *namespaces[22];
+ int i;
+ xmlNsPtr ns;
+
+ root = xmlDocGetRootElement(doc);
+ for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) {
+ namespaces[i++] = ns->href;
+ namespaces[i++] = ns->prefix;
+ }
+ namespaces[i++] = NULL;
+ namespaces[i++] = NULL;
+
+ if (pattern != NULL) {
+ patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict,
+ 0, &namespaces[0]);
+ if (patternc == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "Pattern %s failed to compile\n", pattern);
+ progresult = XMLLINT_ERR_SCHEMAPAT;
+ pattern = NULL;
+ }
+ }
+#endif /* LIBXML_PATTERN_ENABLED */
reader = xmlReaderWalker(doc);
if (reader != NULL) {
if ((timing) && (!repeat)) {
@@ -2262,7 +2296,7 @@ main(int argc, char **argv) {
}
#endif /* LIBXML_SCHEMAS_ENABLED */
#ifdef LIBXML_PATTERN_ENABLED
- if (pattern != NULL) {
+ if ((pattern != NULL) && (walker == 0)) {
patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
if (patternc == NULL) {
xmlGenericError(xmlGenericErrorContext,