Commit 5344c60d authored by Daniel Veillard's avatar Daniel Veillard

Fixed a few other problems raised by Charlie Bozeman. fixed the output

* DOCBparser.c parser.c valid.c include/libxml/parserInternals.h
  include/libxml/xmlerror.h include/libxml/xpathInternals.h:
  Fixed a few other problems raised by Charlie Bozeman.
* result/VC/ElementValid[5-7]: fixed the output
Daniel
parent cbaf3995
Mon Dec 31 17:35:40 CET 2001 Daniel Veillard <daniel@veillard.com>
* DOCBparser.c parser.c valid.c include/libxml/parserInternals.h
include/libxml/xmlerror.h include/libxml/xpathInternals.h:
Fixed a few other problems raised by Charlie Bozeman.
* result/VC/ElementValid[5-7]: fixed the output
Mon Dec 31 17:13:34 CET 2001 Daniel Veillard <daniel@veillard.com>
* *.c include/libxml/*.h doc/html/*: applied 42 documentation
......
......@@ -1057,72 +1057,6 @@ docbAutoCloseTag(docbDocPtr doc, const xmlChar *name, docbNodePtr elem) {
return(0);
}
#if 0
/**
* docbIsAutoClosed:
* @doc: the SGML document
* @elem: the SGML element
*
* The list is kept in docbStartClose array. This function checks
* if a tag is autoclosed by one of it's child
*
* Returns 1 if autoclosed, 0 otherwise
*/
static int
docbIsAutoClosed(docbDocPtr doc, docbNodePtr elem) {
docbNodePtr child;
if (elem == NULL) return(1);
child = elem->children;
while (child != NULL) {
if (docbAutoCloseTag(doc, elem->name, child)) return(1);
child = child->next;
}
return(0);
}
#endif
/**
* docbCheckParagraph
* @ctxt: an SGML parser context
*
* Check whether a p element need to be implied before inserting
* characters in the current element.
*
* Returns 1 if a paragraph has been inserted, 0 if not and -1
* in case of error.
*/
static int
docbCheckParagraph(docbParserCtxtPtr ctxt) {
const xmlChar *tag;
int i;
if (ctxt == NULL)
return(-1);
tag = ctxt->name;
if (tag == NULL) {
docbAutoClose(ctxt, BAD_CAST"p");
docbnamePush(ctxt, xmlStrdup(BAD_CAST"p"));
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
ctxt->sax->startElement(ctxt->userData, BAD_CAST"p", NULL);
return(1);
}
for (i = 0; docbNoContentElements[i] != NULL; i++) {
if (xmlStrEqual(tag, BAD_CAST docbNoContentElements[i])) {
#ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Implied element paragraph\n");
#endif
docbAutoClose(ctxt, BAD_CAST"p");
docbnamePush(ctxt, xmlStrdup(BAD_CAST"p"));
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
ctxt->sax->startElement(ctxt->userData, BAD_CAST"p", NULL);
return(1);
}
}
return(0);
}
/************************************************************************
* *
* The list of SGML predefined entities *
......@@ -3105,7 +3039,6 @@ docbParseCharData(docbParserCtxtPtr ctxt) {
ctxt->sax->ignorableWhitespace(ctxt->userData,
buf, nbchar);
} else {
docbCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData, buf, nbchar);
}
......@@ -3124,7 +3057,6 @@ docbParseCharData(docbParserCtxtPtr ctxt) {
if (ctxt->sax->ignorableWhitespace != NULL)
ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar);
} else {
docbCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData, buf, nbchar);
}
......@@ -4051,7 +3983,6 @@ docbParseReference(docbParserCtxtPtr ctxt) {
}
out[i] = 0;
docbCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, out, i);
} else {
......@@ -4102,7 +4033,6 @@ docbParseReference(docbParserCtxtPtr ctxt) {
} else if (name != NULL) {
ent = docbEntityLookup(name);
if ((ent == NULL) || (ent->value <= 0)) {
docbCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL)) {
ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
ctxt->sax->characters(ctxt->userData, name, xmlStrlen(name));
......@@ -4127,12 +4057,10 @@ docbParseReference(docbParserCtxtPtr ctxt) {
}
out[i] = 0;
docbCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, out, i);
}
} else {
docbCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
return;
......@@ -5607,7 +5535,6 @@ docbParseTryOrFinish(docbParserCtxtPtr ctxt, int terminate) {
xmlChar chr[2] = { 0 , 0 } ;
chr[0] = (xmlChar) ctxt->token;
docbCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, chr, 1);
ctxt->token = 0;
......@@ -5622,7 +5549,6 @@ docbParseTryOrFinish(docbParserCtxtPtr ctxt, int terminate) {
ctxt->sax->ignorableWhitespace(
ctxt->userData, &cur, 1);
} else {
docbCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(
ctxt->userData, &cur, 1);
......
......@@ -197,7 +197,6 @@ int xmlIsChar (int c);
/**
* Parser context
*/
xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *filename);
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer,
int size);
......
......@@ -110,7 +110,7 @@ typedef enum {
XML_ERR_EQUAL_REQUIRED,
XML_ERR_TAG_NAME_MISMATCH, /* 77 */
XML_ERR_TAG_NOT_FINISED,
XML_ERR_TAG_NOT_FINISHED,
XML_ERR_STANDALONE_VALUE, /* 79 */
......
......@@ -177,7 +177,7 @@ void * xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
*
* Pushes an empty node-set on the context stack
*/
#define xmlXPathReturnEmptyNodeSet(ctxt, ns) \
#define xmlXPathReturnEmptyNodeSet(ctxt) \
valuePush((ctxt), xmlXPathNewNodeSet(NULL))
/**
......
......@@ -6848,7 +6848,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
*/
xmlParseContent(ctxt);
if (!IS_CHAR(RAW)) {
ctxt->errNo = XML_ERR_TAG_NOT_FINISED;
ctxt->errNo = XML_ERR_TAG_NOT_FINISHED;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
"Premature end of data in tag %.30s\n", openTag);
......
./test/VC/ElementValid5:7: validity error: Element doc content doesn't follow the Dtd
./test/VC/ElementValid5:7: validity error: Element doc content doesn't follow the DTD
Expecting (a , b* , c+), got (a b c b)
<doc><a/><b> but this</b><c>was not declared</c><b>seems</b></doc>
^
./test/VC/ElementValid6:7: validity error: Element doc content doesn't follow the Dtd
./test/VC/ElementValid6:7: validity error: Element doc content doesn't follow the DTD
Expecting (a , b? , c+)?, got (a b)
<doc><a/><b>lacks c</b></doc>
^
./test/VC/ElementValid7:7: validity error: Element doc content doesn't follow the Dtd
./test/VC/ElementValid7:7: validity error: Element doc content doesn't follow the DTD
Expecting ((a | b)* , c+ , a , b? , c , a?), got (a b a c c a)
<doc><a/><b/><a/><c/><c/><a/></doc>
^
......@@ -97,11 +97,11 @@ typedef struct _xmlValidState {
#define OCCURS ctxt->vstate->occurs
#define STATE ctxt->vstate->state
#define OCCURENCE (ctxt->vstate->occurs & (1 << DEPTH))
#define PARENT_OCCURENCE (ctxt->vstate->occurs & ((1 << DEPTH) - 1))
#define OCCURRENCE (ctxt->vstate->occurs & (1 << DEPTH))
#define PARENT_OCCURRENCE (ctxt->vstate->occurs & ((1 << DEPTH) - 1))
#define SET_OCCURENCE ctxt->vstate->occurs |= (1 << DEPTH)
#define RESET_OCCURENCE ctxt->vstate->occurs &= ((1 << DEPTH) - 1)
#define SET_OCCURRENCE ctxt->vstate->occurs |= (1 << DEPTH)
#define RESET_OCCURRENCE ctxt->vstate->occurs &= ((1 << DEPTH) - 1)
static int
vstateVPush(xmlValidCtxtPtr ctxt, xmlElementContentPtr cont,
......@@ -3445,7 +3445,7 @@ cont:
(CONT->parent->type != XML_ELEMENT_CONTENT_OR)) &&
((CONT->ocur == XML_ELEMENT_CONTENT_MULT) ||
(CONT->ocur == XML_ELEMENT_CONTENT_OPT) ||
((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURENCE)))) {
((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURRENCE)))) {
DEBUG_VALID_MSG("saving parent branch");
vstateVPush(ctxt, CONT, NODE, DEPTH, OCCURS, ROLLBACK_PARENT);
}
......@@ -3616,7 +3616,7 @@ analyze:
determinist = -3;
goto cont;
case XML_ELEMENT_CONTENT_PLUS:
if (OCCURENCE == 0) {
if (OCCURRENCE == 0) {
cur = ctxt->vstate->node;
DEBUG_VALID_MSG("Plus branch failed, rollback");
if (vstateVPop(ctxt) < 0 ) {
......@@ -3632,7 +3632,7 @@ analyze:
break;
case XML_ELEMENT_CONTENT_MULT:
#ifdef DEBUG_VALID_ALGO
if (OCCURENCE == 0) {
if (OCCURRENCE == 0) {
DEBUG_VALID_MSG("Mult branch failed");
} else {
DEBUG_VALID_MSG("Mult branch found");
......@@ -3667,7 +3667,7 @@ analyze:
break;
}
DEBUG_VALID_MSG("Plus branch succeeded, continuing");
SET_OCCURENCE;
SET_OCCURRENCE;
goto cont;
case XML_ELEMENT_CONTENT_MULT:
if (STATE == ROLLBACK_PARENT) {
......@@ -3681,7 +3681,7 @@ analyze:
break;
}
DEBUG_VALID_MSG("Mult branch succeeded, continuing");
/* SET_OCCURENCE; */
/* SET_OCCURRENCE; */
goto cont;
}
}
......@@ -3690,7 +3690,7 @@ analyze:
/*
* Then act accordingly at the parent level
*/
RESET_OCCURENCE;
RESET_OCCURRENCE;
if (CONT->parent == NULL)
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment