1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-28 00:21:53 +03:00

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
This commit is contained in:
Daniel Veillard
2003-02-04 14:43:39 +00:00
parent 419a7688d0
commit e5b110b384
5 changed files with 71 additions and 14 deletions

View File

@ -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> Tue Feb 4 00:20:58 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng: more work on grammars and refs/defs * relaxng: more work on grammars and refs/defs

View File

@ -3927,11 +3927,49 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
static htmlParserCtxtPtr static htmlParserCtxtPtr
htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) { htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
int len; int len;
htmlParserCtxtPtr ctxt;
if (cur == NULL) if (cur == NULL)
return(NULL); return(NULL);
len = xmlStrlen(cur); 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);
} }
/************************************************************************ /************************************************************************

View File

@ -51,7 +51,7 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
#define DEBUG_CONTENT 1 #define DEBUG_CONTENT 1
#define DEBUG_TYPE 1 #define DEBUG_TYPE 1
#define DEBUG_VALID 1 #define DEBUG_VALID 1
#define DEBUG_INTERLEAVE 1 */ /* #define DEBUG_INTERLEAVE 1 */
#define UNBOUNDED (1 << 30) #define UNBOUNDED (1 << 30)
#define TODO \ #define TODO \
@ -641,6 +641,8 @@ xmlRelaxNGNewValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node)
ctxt->error(ctxt->userData, "Out of memory\n"); ctxt->error(ctxt->userData, "Out of memory\n");
return (NULL); return (NULL);
} }
ret->value = NULL;
ret->endvalue = NULL;
if (node == NULL) { if (node == NULL) {
ret->node = (xmlNodePtr) ctxt->doc; ret->node = (xmlNodePtr) ctxt->doc;
ret->seq = root; ret->seq = root;
@ -1619,16 +1621,14 @@ xmlRelaxNGGetDataTypeLibrary(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
} }
node = node->parent; node = node->parent;
while ((node != NULL) && (node->type == XML_ELEMENT_NODE)) { while ((node != NULL) && (node->type == XML_ELEMENT_NODE)) {
if (IS_RELAXNG(node, "element")) { ret = xmlGetProp(node, BAD_CAST "datatypeLibrary");
ret = xmlGetProp(node, BAD_CAST "datatypeLibrary"); if (ret != NULL) {
if (ret != NULL) { escape = xmlURIEscapeStr(ret, BAD_CAST ":/#?");
escape = xmlURIEscapeStr(ret, BAD_CAST ":/#?"); if (escape == NULL) {
if (escape == NULL) { return(ret);
return(ret);
}
xmlFree(ret);
return(escape);
} }
xmlFree(ret);
return(escape);
} }
node = node->parent; node = node->parent;
} }
@ -4190,6 +4190,7 @@ xmlRelaxNGNextValue(xmlRelaxNGValidCtxtPtr ctxt) {
cur = ctxt->state->value; cur = ctxt->state->value;
if ((cur == NULL) || (ctxt->state->endvalue == NULL)) { if ((cur == NULL) || (ctxt->state->endvalue == NULL)) {
ctxt->state->value = NULL; ctxt->state->value = NULL;
ctxt->state->endvalue = NULL;
return(0); return(0);
} }
while (*cur != 0) cur++; while (*cur != 0) cur++;
@ -4993,6 +4994,12 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
VALID_ERROR("Expecting an element\n"); VALID_ERROR("Expecting an element\n");
return(-1); return(-1);
} }
/*
* This node was already validated successfully against
* this definition.
*/
if (node->_private == define)
break;
if (define->name != NULL) { if (define->name != NULL) {
if (!xmlStrEqual(node->name, define->name)) { if (!xmlStrEqual(node->name, define->name)) {
VALID_CTXT(); VALID_CTXT();
@ -5060,7 +5067,9 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
ctxt->state = oldstate; ctxt->state = oldstate;
xmlRelaxNGFreeValidState(state); xmlRelaxNGFreeValidState(state);
if (oldstate != NULL) if (oldstate != NULL)
oldstate->seq = node->next; oldstate->seq = xmlRelaxNGSkipIgnored(ctxt, node->next);
if (ret == 0)
node->_private = define;
#ifdef DEBUG #ifdef DEBUG

2
tree.c
View File

@ -2508,8 +2508,6 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
* *
* Add a new node to @parent, at the end of the child (or property) list * 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) * 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 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. * If there is an attribute with equal name, it is first destroyed.
* *

View File

@ -129,6 +129,8 @@ static xmlSchemaTypePtr xmlSchemaTypeDurationDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL; static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL;
static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeQNameDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL;
/* /*
* Derived types * Derived types
@ -146,6 +148,7 @@ static xmlSchemaTypePtr xmlSchemaTypeUnsignedLongDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeUnsignedIntDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedIntDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeUnsignedShortDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedShortDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeUnsignedByteDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeUnsignedByteDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeNCNameDef = NULL;
/* /*
* xmlSchemaInitBasicType: * xmlSchemaInitBasicType:
@ -202,6 +205,8 @@ xmlSchemaInitTypes(void) {
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN"); xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float"); xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float");
xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double"); xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double");
xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName");
xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI");
/* /*
* derived datatypes * derived datatypes
@ -219,6 +224,7 @@ xmlSchemaInitTypes(void) {
xmlSchemaTypeUnsignedShortDef = xmlSchemaInitBasicType("insignedShort");; xmlSchemaTypeUnsignedShortDef = xmlSchemaInitBasicType("insignedShort");;
xmlSchemaTypeUnsignedByteDef = xmlSchemaInitBasicType("unsignedByte");; xmlSchemaTypeUnsignedByteDef = xmlSchemaInitBasicType("unsignedByte");;
xmlSchemaTypePositiveIntegerDef = xmlSchemaInitBasicType("positiveInteger"); xmlSchemaTypePositiveIntegerDef = xmlSchemaInitBasicType("positiveInteger");
xmlSchemaTypeNCNameDef = xmlSchemaInitBasicType("NCName");
xmlSchemaTypesInitialized = 1; xmlSchemaTypesInitialized = 1;
} }