mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-03 08:58:17 +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:
parent
2c748c612e
commit
cfa0d81221
@ -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>
|
||||
|
||||
* tree.c: update xmlNodeSetContent() and xmlNodeSetContentLen()
|
||||
|
24
debugXML.c
24
debugXML.c
@ -1423,6 +1423,27 @@ xmlShellBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
||||
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:
|
||||
* @ctxt: the shell context
|
||||
@ -1940,6 +1961,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
||||
break;
|
||||
if (!strcmp(command, "help")) {
|
||||
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, "\tcat [node] display node or current node\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);
|
||||
} else if (!strcmp(command, "base")) {
|
||||
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"))) {
|
||||
int dir = (!strcmp(command, "dir"));
|
||||
|
||||
|
32
tree.c
32
tree.c
@ -3249,6 +3249,8 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
|
||||
*/
|
||||
void
|
||||
xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
|
||||
xmlNsPtr ns;
|
||||
|
||||
if (cur == NULL) return;
|
||||
switch(cur->type) {
|
||||
case XML_TEXT_NODE:
|
||||
@ -3277,7 +3279,10 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
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
|
||||
xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
|
||||
xmlNsPtr ns;
|
||||
|
||||
if (cur == NULL) return;
|
||||
switch(cur->type) {
|
||||
case XML_TEXT_NODE:
|
||||
@ -3342,13 +3349,15 @@ xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
break;
|
||||
}
|
||||
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
|
||||
if (ns == NULL)
|
||||
return;
|
||||
switch (val) {
|
||||
case 0:
|
||||
xmlSetProp(cur, BAD_CAST "xml:space", BAD_CAST "default");
|
||||
xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default");
|
||||
break;
|
||||
case 1:
|
||||
xmlSetProp(cur, BAD_CAST "xml:space",
|
||||
BAD_CAST "preserve");
|
||||
xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3368,7 +3377,7 @@ xmlNodeGetSpacePreserve(xmlNodePtr cur) {
|
||||
xmlChar *space;
|
||||
|
||||
while (cur != NULL) {
|
||||
space = xmlGetProp(cur, BAD_CAST "xml:space");
|
||||
space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
|
||||
if (space != NULL) {
|
||||
if (xmlStrEqual(space, BAD_CAST "preserve")) {
|
||||
xmlFree(space);
|
||||
@ -3437,6 +3446,8 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
|
||||
*/
|
||||
void
|
||||
xmlNodeSetBase(xmlNodePtr cur, xmlChar* uri) {
|
||||
xmlNsPtr ns;
|
||||
|
||||
if (cur == NULL) return;
|
||||
switch(cur->type) {
|
||||
case XML_TEXT_NODE:
|
||||
@ -3465,7 +3476,11 @@ xmlNodeSetBase(xmlNodePtr cur, xmlChar* uri) {
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
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 (xmlStrEqual(href, XML_XML_NAMESPACE)) {
|
||||
/*
|
||||
* Only the document can hold the XML spec namespace.
|
||||
*/
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
if (doc->oldNs == NULL) {
|
||||
/*
|
||||
* Allocate a new Namespace and fill the fields.
|
||||
|
Loading…
x
Reference in New Issue
Block a user