mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-08 17:42:14 +03:00
fixed the funxtion to set the xml: attributes added "setbase" to test it.
* tree.c: fixed the funxtion to set the xml: attributes * debugXML.c: added "setbase" to test it. Daniel
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Thu Jan 17 09:44:44 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* tree.c: fixed the funxtion to set the xml: attributes
|
||||||
|
* debugXML.c: added "setbase" to test it.
|
||||||
|
|
||||||
Wed Jan 16 16:36:08 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Wed Jan 16 16:36:08 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* tree.c: update xmlNodeSetContent() and xmlNodeSetContentLen()
|
* tree.c: update xmlNodeSetContent() and xmlNodeSetContentLen()
|
||||||
|
24
debugXML.c
24
debugXML.c
@@ -1423,6 +1423,27 @@ xmlShellBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlShellSetBase:
|
||||||
|
* @ctxt: the shell context
|
||||||
|
* @arg: the new base
|
||||||
|
* @node: a node
|
||||||
|
* @node2: unused
|
||||||
|
*
|
||||||
|
* Implements the XML shell function "setbase"
|
||||||
|
* change the current XML base of the node
|
||||||
|
*
|
||||||
|
* Returns 0
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlShellSetBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
||||||
|
char *arg ATTRIBUTE_UNUSED, xmlNodePtr node,
|
||||||
|
xmlNodePtr node2 ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
xmlNodeSetBase(node, (xmlChar*) arg);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlShellDir:
|
* xmlShellDir:
|
||||||
* @ctxt: the shell context
|
* @ctxt: the shell context
|
||||||
@@ -1940,6 +1961,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
break;
|
break;
|
||||||
if (!strcmp(command, "help")) {
|
if (!strcmp(command, "help")) {
|
||||||
fprintf(stdout, "\tbase display XML base of the node\n");
|
fprintf(stdout, "\tbase display XML base of the node\n");
|
||||||
|
fprintf(stdout, "\tsetbase URI change the XML base of the node\n");
|
||||||
fprintf(stdout, "\tbye leave shell\n");
|
fprintf(stdout, "\tbye leave shell\n");
|
||||||
fprintf(stdout, "\tcat [node] display node or current node\n");
|
fprintf(stdout, "\tcat [node] display node or current node\n");
|
||||||
fprintf(stdout, "\tcd [path] change directory to path or to root\n");
|
fprintf(stdout, "\tcd [path] change directory to path or to root\n");
|
||||||
@@ -1981,6 +2003,8 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
|
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
|
||||||
} else if (!strcmp(command, "base")) {
|
} else if (!strcmp(command, "base")) {
|
||||||
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
|
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
|
||||||
|
} else if (!strcmp(command, "setbase")) {
|
||||||
|
xmlShellSetBase(ctxt, arg, ctxt->node, NULL);
|
||||||
} else if ((!strcmp(command, "ls")) || (!strcmp(command, "dir"))) {
|
} else if ((!strcmp(command, "ls")) || (!strcmp(command, "dir"))) {
|
||||||
int dir = (!strcmp(command, "dir"));
|
int dir = (!strcmp(command, "dir"));
|
||||||
|
|
||||||
|
32
tree.c
32
tree.c
@@ -3249,6 +3249,8 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
|
xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
|
||||||
|
xmlNsPtr ns;
|
||||||
|
|
||||||
if (cur == NULL) return;
|
if (cur == NULL) return;
|
||||||
switch(cur->type) {
|
switch(cur->type) {
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
@@ -3277,7 +3279,10 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
|
|||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xmlSetProp(cur, BAD_CAST "xml:lang", lang);
|
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
|
||||||
|
if (ns == NULL)
|
||||||
|
return;
|
||||||
|
xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3314,6 +3319,8 @@ xmlNodeGetLang(xmlNodePtr cur) {
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
|
xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
|
||||||
|
xmlNsPtr ns;
|
||||||
|
|
||||||
if (cur == NULL) return;
|
if (cur == NULL) return;
|
||||||
switch(cur->type) {
|
switch(cur->type) {
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
@@ -3342,13 +3349,15 @@ xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
|
|||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
|
||||||
|
if (ns == NULL)
|
||||||
|
return;
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 0:
|
case 0:
|
||||||
xmlSetProp(cur, BAD_CAST "xml:space", BAD_CAST "default");
|
xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
xmlSetProp(cur, BAD_CAST "xml:space",
|
xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve");
|
||||||
BAD_CAST "preserve");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3368,7 +3377,7 @@ xmlNodeGetSpacePreserve(xmlNodePtr cur) {
|
|||||||
xmlChar *space;
|
xmlChar *space;
|
||||||
|
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
space = xmlGetProp(cur, BAD_CAST "xml:space");
|
space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
|
||||||
if (space != NULL) {
|
if (space != NULL) {
|
||||||
if (xmlStrEqual(space, BAD_CAST "preserve")) {
|
if (xmlStrEqual(space, BAD_CAST "preserve")) {
|
||||||
xmlFree(space);
|
xmlFree(space);
|
||||||
@@ -3437,6 +3446,8 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlNodeSetBase(xmlNodePtr cur, xmlChar* uri) {
|
xmlNodeSetBase(xmlNodePtr cur, xmlChar* uri) {
|
||||||
|
xmlNsPtr ns;
|
||||||
|
|
||||||
if (cur == NULL) return;
|
if (cur == NULL) return;
|
||||||
switch(cur->type) {
|
switch(cur->type) {
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
@@ -3465,7 +3476,11 @@ xmlNodeSetBase(xmlNodePtr cur, xmlChar* uri) {
|
|||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xmlSetProp(cur, BAD_CAST "xml:base", uri);
|
|
||||||
|
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
|
||||||
|
if (ns == NULL)
|
||||||
|
return;
|
||||||
|
xmlSetNsProp(cur, ns, BAD_CAST "base", uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4113,6 +4128,11 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar *href) {
|
|||||||
|
|
||||||
if ((node == NULL) || (href == NULL)) return(NULL);
|
if ((node == NULL) || (href == NULL)) return(NULL);
|
||||||
if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
|
if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
|
||||||
|
/*
|
||||||
|
* Only the document can hold the XML spec namespace.
|
||||||
|
*/
|
||||||
|
if (doc == NULL)
|
||||||
|
return(NULL);
|
||||||
if (doc->oldNs == NULL) {
|
if (doc->oldNs == NULL) {
|
||||||
/*
|
/*
|
||||||
* Allocate a new Namespace and fill the fields.
|
* Allocate a new Namespace and fill the fields.
|
||||||
|
Reference in New Issue
Block a user