summaryrefslogtreecommitdiff
path: root/libxslt/namespaces.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-02-02 10:20:16 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-02-02 10:20:16 +0000
commit0726423c0f1d455e37671f2850845dd47c224527 (patch)
tree8dbad0b69f14686142da00fdeede6ee4dcde9f14 /libxslt/namespaces.c
parent22fc899b2da378bff95096d020154429228e3873 (diff)
downloadlibxslt-0726423c0f1d455e37671f2850845dd47c224527.tar.gz
And most of this is simply untested, yet...:
- FEATURES: updated - transform.c: added xsl:element support - namespaces.[ch]: added xsltGetSpecialNamespace() - attributes.c: added xsl:attribute namespace support. Daniel
Diffstat (limited to 'libxslt/namespaces.c')
-rw-r--r--libxslt/namespaces.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/libxslt/namespaces.c b/libxslt/namespaces.c
index 1e699788..b70670d6 100644
--- a/libxslt/namespaces.c
+++ b/libxslt/namespaces.c
@@ -120,6 +120,51 @@ error:
}
/**
+ * xsltGetSpecificNamespace:
+ * @ctxt: a transformation context
+ * @cur: the input node
+ * @URI: the namespace URI
+ * @prefix: the suggested prefix
+ * @out: the output node (or its parent)
+ *
+ * Find the right namespace value for this URI, if needed create
+ * and add a new namespace decalaration on the node
+ *
+ * Returns the namespace node to use or NULL
+ */
+xmlNsPtr
+xsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur,
+ const xmlChar *URI, const xmlChar *prefix, xmlNodePtr out) {
+ xmlNsPtr ret;
+ static int prefixno = 1;
+ char nprefix[10];
+
+ if ((ctxt == NULL) || (cur == NULL) || (out == NULL) || (URI == NULL))
+ return(NULL);
+
+ if ((out->parent != NULL) &&
+ (out->parent->type == XML_ELEMENT_NODE) &&
+ (out->parent->ns != NULL) &&
+ (xmlStrEqual(out->parent->ns->href, URI)))
+ ret = out->parent->ns;
+ else
+ ret = xmlSearchNsByHref(out->doc, out, URI);
+
+ if (ret == NULL) {
+ if (prefix == NULL) {
+ do {
+ sprintf(nprefix, "ns%d", prefixno++);
+ ret = xmlSearchNs(out->doc, out, (xmlChar *)nprefix);
+ } while (ret != NULL);
+ prefix = (const xmlChar *) &nprefix[0];
+ }
+ if (out->type == XML_ELEMENT_NODE)
+ ret = xmlNewNs(out, URI, prefix);
+ }
+ return(ret);
+}
+
+/**
* xsltGetNamespace:
* @ctxt: a transformation context
* @cur: the input node