Commit e456646d authored by Daniel Veillard's avatar Daniel Veillard
Browse files

More work, bugfixes for problems detected by XSLT, and addition of

a new specific type for XSLT:
- xpathInternals.h xpath.[ch] debugXML.c: added the XPATH_XSLT_TREE
  type correponding to an XSLT result tree fragment. Share most
  of the data format with node set, as well as operators.
- HTMLtree.c: added a newline at the end of the doctype output
  whe this one is not present initially.
- tree.c: make sure taht the parent and doc pointers are properly
  set when copying attributes (lists).
Daniel
parent 8a7efd04
Mon Jan 22 10:35:40 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xpathInternals.h xpath.[ch] debugXML.c: added the XPATH_XSLT_TREE
type correponding to an XSLT result tree fragment. Share most
of the data format with node set, as well as operators.
* HTMLtree.c: added a newline at the end of the doctype output
whe this one is not present initially.
* tree.c: make sure taht the parent and doc pointers are properly
set when copying attributes (lists).
Sun Jan 21 10:47:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* htmlTree.[ch] xmlIO.h: exported htmlDocContentDumpOutput
......
......@@ -657,9 +657,6 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
* *
************************************************************************/
void
htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding);
/**
* htmlDtdDump:
* @buf: the HTML buffer output
......@@ -950,7 +947,7 @@ htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *enco
htmlDtdDumpOutput(buf, cur, NULL);
else {
/* Default to HTML-4.0 transitionnal @@@@ */
xmlOutputBufferWriteString(buf, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">");
xmlOutputBufferWriteString(buf, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
}
if (cur->children != NULL) {
......
......@@ -1725,6 +1725,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
break;
case XPATH_XSLT_TREE:
xmlGenericError(xmlGenericErrorContext,
"%s is an XSLT value tree\n", arg);
break;
}
xmlXPathFreeNodeSetList(list);
} else {
......@@ -1785,6 +1789,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
break;
case XPATH_XSLT_TREE:
xmlGenericError(xmlGenericErrorContext,
"%s is an XSLT value tree\n", arg);
break;
}
xmlXPathFreeNodeSetList(list);
} else {
......@@ -1848,6 +1856,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
break;
case XPATH_XSLT_TREE:
xmlGenericError(xmlGenericErrorContext,
"%s is an XSLT value tree\n", arg);
break;
}
xmlXPathFreeNodeSetList(list);
} else {
......
......@@ -82,7 +82,8 @@ typedef enum {
XPATH_POINT = 5,
XPATH_RANGE = 6,
XPATH_LOCATIONSET = 7,
XPATH_USERS = 8
XPATH_USERS = 8,
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
} xmlXPathObjectType;
typedef struct _xmlXPathObject xmlXPathObject;
......
......@@ -136,6 +136,7 @@ xmlXPathObjectPtr xmlXPathNewCString (const char *val);
xmlXPathObjectPtr xmlXPathNewFloat (double val);
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
xmlNodePtr val);
......
......@@ -874,6 +874,7 @@ xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
xmlAttrPtr
xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
xmlAttrPtr cur;
xmlDocPtr doc = NULL;
if (name == NULL) {
#ifdef DEBUG_TREE
......@@ -896,17 +897,22 @@ xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
cur->type = XML_ATTRIBUTE_NODE;
cur->parent = node;
if (node != NULL) {
doc = node->doc;
cur->doc = doc;
}
cur->name = xmlStrdup(name);
if (value != NULL) {
xmlChar *buffer;
xmlNodePtr tmp;
buffer = xmlEncodeEntitiesReentrant(node->doc, value);
cur->children = xmlStringGetNodeList(node->doc, buffer);
buffer = xmlEncodeEntitiesReentrant(doc, value);
cur->children = xmlStringGetNodeList(doc, buffer);
cur->last = NULL;
tmp = cur->children;
while (tmp != NULL) {
tmp->parent = (xmlNodePtr) cur;
tmp->doc = doc;
if (tmp->next == NULL)
cur->last = tmp;
tmp = tmp->next;
......@@ -4101,7 +4107,11 @@ xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *namespace) {
xmlAttrPtr
xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
xmlAttrPtr prop = node->properties;
xmlDocPtr doc = NULL;
if ((node == NULL) || (name == NULL))
return(NULL);
doc = node->doc;
while (prop != NULL) {
if (xmlStrEqual(prop->name, name)) {
if (prop->children != NULL)
......@@ -4115,9 +4125,11 @@ xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
buffer = xmlEncodeEntitiesReentrant(node->doc, value);
prop->children = xmlStringGetNodeList(node->doc, buffer);
prop->last = NULL;
prop->doc = doc;
tmp = prop->children;
while (tmp != NULL) {
tmp->parent = (xmlNodePtr) prop;
tmp->doc = doc;
if (tmp->next == NULL)
prop->last = tmp;
tmp = tmp->next;
......@@ -5458,7 +5470,7 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
* Disable escaping, needed for XSLT
*/
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, cur->content);
xmlOutputBufferWriteString(buf, (const char *) cur->content);
#else
xmlOutputBufferWriteString(buf, xmlBufferContent(cur->content));
#endif
......
......@@ -282,6 +282,10 @@ void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
fprintf(output, "Object is a Node Set :\n");
xmlXPathDebugDumpNodeSet(output, cur->nodesetval, depth);
break;
case XPATH_XSLT_TREE:
fprintf(output, "Object is an XSLT value tree :\n");
xmlXPathDebugDumpNode(output, cur->user, depth);
break;
case XPATH_BOOLEAN:
fprintf(output, "Object is a Boolean : ");
if (cur->boolval) fprintf(output, "true\n");
......@@ -788,6 +792,31 @@ xmlXPathNewNodeSet(xmlNodePtr val) {
return(ret);
}
/**
* xmlXPathNewValueTree:
* @val: the NodePtr value
*
* Create a new xmlXPathObjectPtr of type Value Tree (XSLT) and initialize
* it with the tree root @val
*
* Returns the newly created object.
*/
xmlXPathObjectPtr
xmlXPathNewValueTree(xmlNodePtr val) {
xmlXPathObjectPtr ret;
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
if (ret == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathNewNodeSet: out of memory\n");
return(NULL);
}
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
ret->type = XPATH_XSLT_TREE;
ret->nodesetval = xmlXPathNodeSetCreate(val);
return(ret);
}
/**
* xmlXPathNewNodeSetList:
* @val: an existing NodeSet
......@@ -1297,10 +1326,12 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
switch (val->type) {
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_STRING:
case XPATH_POINT:
case XPATH_RANGE:
break;
case XPATH_STRING:
ret->stringval = xmlStrdup(val->stringval);
case XPATH_XSLT_TREE:
case XPATH_NODESET:
ret->nodesetval = xmlXPathNodeSetMerge(NULL, val->nodesetval);
break;
......@@ -1317,6 +1348,7 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathObjectCopy: unsupported type %d\n",
val->type);
break;
}
return(ret);
}
......@@ -1341,6 +1373,9 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
} else if (obj->type == XPATH_STRING) {
if (obj->stringval != NULL)
xmlFree(obj->stringval);
} else if (obj->type == XPATH_XSLT_TREE) {
if (obj->nodesetval != NULL)
xmlXPathFreeNodeSet(obj->nodesetval);
}
#ifdef DEBUG
......@@ -1839,6 +1874,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
"Equal: undefined\n");
#endif
break;
case XPATH_XSLT_TREE:
case XPATH_NODESET:
switch (arg2->type) {
case XPATH_UNDEFINED:
......@@ -1847,6 +1883,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
"Equal: undefined\n");
#endif
break;
case XPATH_XSLT_TREE:
case XPATH_NODESET:
ret = xmlXPathEqualNodeSets(arg1, arg2);
break;
......@@ -1880,6 +1917,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
#endif
break;
case XPATH_NODESET:
case XPATH_XSLT_TREE:
if ((arg2->nodesetval == NULL) ||
(arg2->nodesetval->nodeNr == 0)) ret = 0;
else
......@@ -1922,6 +1960,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
#endif
break;
case XPATH_NODESET:
case XPATH_XSLT_TREE:
ret = xmlXPathEqualNodeSetFloat(arg2, arg1->floatval);
break;
case XPATH_BOOLEAN:
......@@ -1954,6 +1993,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
#endif
break;
case XPATH_NODESET:
case XPATH_XSLT_TREE:
ret = xmlXPathEqualNodeSetString(arg2, arg1->stringval);
break;
case XPATH_BOOLEAN:
......@@ -3476,6 +3516,7 @@ xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
#endif
valuePush(ctxt, xmlXPathNewCString(""));
break;
case XPATH_XSLT_TREE:
case XPATH_NODESET:
if (cur->nodesetval->nodeNr == 0) {
valuePush(ctxt, xmlXPathNewCString(""));
......@@ -4135,6 +4176,7 @@ xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
#endif
valuePush(ctxt, xmlXPathNewFloat(0.0));
break;
case XPATH_XSLT_TREE:
case XPATH_NODESET:
valuePush(ctxt, cur);
xmlXPathStringFunction(ctxt, 1);
......
......@@ -82,7 +82,8 @@ typedef enum {
XPATH_POINT = 5,
XPATH_RANGE = 6,
XPATH_LOCATIONSET = 7,
XPATH_USERS = 8
XPATH_USERS = 8,
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
} xmlXPathObjectType;
typedef struct _xmlXPathObject xmlXPathObject;
......
......@@ -136,6 +136,7 @@ xmlXPathObjectPtr xmlXPathNewCString (const char *val);
xmlXPathObjectPtr xmlXPathNewFloat (double val);
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
xmlNodePtr val);
......
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