try to fix # 105049 a couple of changes and extensions updated a function
* HTMLparser.c: try to fix # 105049
* relaxng.c xmlschemastypes.c: a couple of changes and extensions
* tree.c: updated a function comment
Daniel
diff --git a/ChangeLog b/ChangeLog
index 09e7b4d..7cbf475 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Feb 4 15:40:54 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * HTMLparser.c: try to fix # 105049
+ * relaxng.c xmlschemastypes.c: a couple of changes and extensions
+ * tree.c: updated a function comment
+
Tue Feb 4 00:20:58 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng: more work on grammars and refs/defs
diff --git a/HTMLparser.c b/HTMLparser.c
index bc437ed..186ab09 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -3927,11 +3927,49 @@
static htmlParserCtxtPtr
htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
int len;
+ htmlParserCtxtPtr ctxt;
if (cur == NULL)
return(NULL);
len = xmlStrlen(cur);
- return(htmlCreateMemoryParserCtxt((char *)cur, len));
+ ctxt = htmlCreateMemoryParserCtxt((char *)cur, len);
+
+ if (encoding != NULL) {
+ xmlCharEncoding enc;
+ xmlCharEncodingHandlerPtr handler;
+
+ if (ctxt->input->encoding != NULL)
+ xmlFree((xmlChar *) ctxt->input->encoding);
+ ctxt->input->encoding = (const xmlChar *) encoding;
+
+ enc = xmlParseCharEncoding(encoding);
+ /*
+ * registered set of known encodings
+ */
+ if (enc != XML_CHAR_ENCODING_ERROR) {
+ xmlSwitchEncoding(ctxt, enc);
+ if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
+ if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
+ ctxt->sax->error(ctxt->userData,
+ "Unsupported encoding %s\n", encoding);
+ ctxt->input->encoding = NULL;
+ }
+ } else {
+ /*
+ * fallback for unknown encodings
+ */
+ handler = xmlFindCharEncodingHandler((const char *) encoding);
+ if (handler != NULL) {
+ xmlSwitchToEncoding(ctxt, handler);
+ } else {
+ ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
+ if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
+ ctxt->sax->error(ctxt->userData,
+ "Unsupported encoding %s\n", encoding);
+ }
+ }
+ }
+ return(ctxt);
}
/************************************************************************
diff --git a/relaxng.c b/relaxng.c
index ab25bff..da83558 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -51,7 +51,7 @@
#define DEBUG_CONTENT 1
#define DEBUG_TYPE 1
#define DEBUG_VALID 1
-#define DEBUG_INTERLEAVE 1 */
+/* #define DEBUG_INTERLEAVE 1 */
#define UNBOUNDED (1 << 30)
#define TODO \
@@ -641,6 +641,8 @@
ctxt->error(ctxt->userData, "Out of memory\n");
return (NULL);
}
+ ret->value = NULL;
+ ret->endvalue = NULL;
if (node == NULL) {
ret->node = (xmlNodePtr) ctxt->doc;
ret->seq = root;
@@ -1619,16 +1621,14 @@
}
node = node->parent;
while ((node != NULL) && (node->type == XML_ELEMENT_NODE)) {
- if (IS_RELAXNG(node, "element")) {
- ret = xmlGetProp(node, BAD_CAST "datatypeLibrary");
- if (ret != NULL) {
- escape = xmlURIEscapeStr(ret, BAD_CAST ":/#?");
- if (escape == NULL) {
- return(ret);
- }
- xmlFree(ret);
- return(escape);
+ ret = xmlGetProp(node, BAD_CAST "datatypeLibrary");
+ if (ret != NULL) {
+ escape = xmlURIEscapeStr(ret, BAD_CAST ":/#?");
+ if (escape == NULL) {
+ return(ret);
}
+ xmlFree(ret);
+ return(escape);
}
node = node->parent;
}
@@ -4190,6 +4190,7 @@
cur = ctxt->state->value;
if ((cur == NULL) || (ctxt->state->endvalue == NULL)) {
ctxt->state->value = NULL;
+ ctxt->state->endvalue = NULL;
return(0);
}
while (*cur != 0) cur++;
@@ -4993,6 +4994,12 @@
VALID_ERROR("Expecting an element\n");
return(-1);
}
+ /*
+ * This node was already validated successfully against
+ * this definition.
+ */
+ if (node->_private == define)
+ break;
if (define->name != NULL) {
if (!xmlStrEqual(node->name, define->name)) {
VALID_CTXT();
@@ -5060,7 +5067,9 @@
ctxt->state = oldstate;
xmlRelaxNGFreeValidState(state);
if (oldstate != NULL)
- oldstate->seq = node->next;
+ oldstate->seq = xmlRelaxNGSkipIgnored(ctxt, node->next);
+ if (ret == 0)
+ node->_private = define;
#ifdef DEBUG
diff --git a/tree.c b/tree.c
index 69c6465..023b807 100644
--- a/tree.c
+++ b/tree.c
@@ -2508,8 +2508,6 @@
*
* Add a new node to @parent, at the end of the child (or property) list
* merging adjacent TEXT nodes (in which case @cur is freed)
- * If the new node was already inserted in a document it is
- * first unlinked from its existing context.
* If the new node is ATTRIBUTE, it is added into properties instead of children.
* If there is an attribute with equal name, it is first destroyed.
*
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index 52a069b..f7fc982 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -129,6 +129,8 @@
static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL;
static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL;
+static xmlSchemaTypePtr xmlSchemaTypeQNameDef = NULL;
+static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL;
/*
* Derived types
@@ -146,6 +148,7 @@
static xmlSchemaTypePtr xmlSchemaTypeUnsignedIntDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeUnsignedShortDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeUnsignedByteDef = NULL;
+static xmlSchemaTypePtr xmlSchemaTypeNCNameDef = NULL;
/*
* xmlSchemaInitBasicType:
@@ -202,6 +205,8 @@
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float");
xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double");
+ xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName");
+ xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI");
/*
* derived datatypes
@@ -219,6 +224,7 @@
xmlSchemaTypeUnsignedShortDef = xmlSchemaInitBasicType("insignedShort");;
xmlSchemaTypeUnsignedByteDef = xmlSchemaInitBasicType("unsignedByte");;
xmlSchemaTypePositiveIntegerDef = xmlSchemaInitBasicType("positiveInteger");
+ xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType("NCName");
xmlSchemaTypesInitialized = 1;
}