Lines Matching defs:ns

56 xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
793 * @ns: a namespace pointer
798 xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
806 node->ns = ns;
820 "xmlFreeNs : ns == NULL\n");
841 "xmlFreeNsList : ns == NULL\n");
1821 xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
1856 cur->ns = ns;
1940 * @ns: the namespace
1948 xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
1959 return xmlNewPropInternal(node, ns, name, value, 0);
1965 * @ns: the namespace
1973 xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
1984 return xmlNewPropInternal(node, ns, name, value, 1);
2200 * @ns: namespace if any
2203 * Creation of a new node element. @ns is optional (NULL).
2209 xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
2232 cur->ns = ns;
2241 * @ns: namespace if any
2244 * Creation of a new node element. @ns is optional (NULL).
2251 xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
2275 cur->ns = ns;
2285 * @ns: namespace if any
2289 * Creation of a new node element within a document. @ns and @content
2299 xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
2304 cur = xmlNewNodeEatName(ns, (xmlChar *)
2307 cur = xmlNewNode(ns, name);
2322 * @ns: namespace if any
2326 * Creation of a new node element within a document. @ns and @content
2336 xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
2340 cur = xmlNewNodeEatName(ns, name);
2360 * @ns: namespace if any
2364 * Creation of a new node element within a document. @ns and @content
2370 xmlNewDocRawNode(xmlDocPtr doc, xmlNsPtr ns,
2374 cur = xmlNewDocNode(doc, ns, name, NULL);
2451 * @ns: a namespace if any
2456 * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly
2468 xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns,
2492 if (ns == NULL)
2493 cur = xmlNewDocRawNode(parent->doc, parent->ns, name, content);
2495 cur = xmlNewDocRawNode(parent->doc, ns, name, content);
2498 if (ns == NULL)
2501 cur = xmlNewDocRawNode((xmlDocPtr) parent, ns, name, content);
2503 cur = xmlNewDocRawNode( parent->doc, ns, name, content);
2833 * @ns: a namespace if any
2838 * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly
2848 xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
2872 if (ns == NULL)
2873 cur = xmlNewDocNode(parent->doc, parent->ns, name, content);
2875 cur = xmlNewDocNode(parent->doc, ns, name, content);
2878 if (ns == NULL)
2881 cur = xmlNewDocNode((xmlDocPtr) parent, ns, name, content);
2883 cur = xmlNewDocNode( parent->doc, ns, name, content);
2932 if (prop->ns == NULL)
2935 attr = xmlHasNsProp(cur->parent, prop->name, prop->ns->href);
3369 if (cur->ns == NULL)
3372 lastattr = xmlHasNsProp(parent, cur->name, cur->ns->href);
3987 if ((cur->ns != NULL) && (target != NULL)) {
3988 xmlNsPtr ns;
3990 ns = xmlSearchNs(target->doc, target, cur->ns->prefix);
3991 if (ns == NULL) {
3997 ns = xmlSearchNs(cur->doc, cur->parent, cur->ns->prefix);
3998 if (ns != NULL) {
4010 ret->ns = xmlNewNs(root, ns->href, ns->prefix);
4018 if (xmlStrEqual(ns->href, cur->ns->href)) {
4020 ret->ns = ns;
4026 ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
4031 ret->ns = NULL;
4228 if (node->ns != NULL) {
4229 xmlNsPtr ns;
4231 ns = xmlSearchNs(doc, ret, node->ns->prefix);
4232 if (ns == NULL) {
4238 ns = xmlSearchNs(node->doc, node, node->ns->prefix);
4239 if (ns != NULL) {
4243 ret->ns = xmlNewNs(root, ns->href, ns->prefix);
4245 ret->ns = xmlNewReconciliedNs(doc, ret, node->ns);
4251 ret->ns = ns;
4659 if (cur->ns) {
4660 if (cur->ns->prefix != NULL) {
4662 (char *)cur->ns->prefix, (char *)cur->name);
4685 ((tmp->ns == cur->ns) ||
4686 ((tmp->ns != NULL) && (cur->ns != NULL) &&
4687 (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))))
4697 ((tmp->ns == cur->ns) ||
4698 ((tmp->ns != NULL) && (cur->ns != NULL) &&
4699 (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))))
4800 if (cur->ns) {
4801 if (cur->ns->prefix != NULL)
4803 (char *)cur->ns->prefix, (char *)cur->name);
4928 xmlNsPtr ns;
4958 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
4959 if (ns == NULL)
4961 xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
5002 xmlNsPtr ns;
5032 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
5033 if (ns == NULL)
5037 xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default");
5040 xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve");
5149 xmlNsPtr ns;
5191 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
5192 if (ns == NULL)
5196 xmlSetNsProp(cur, ns, BAD_CAST "base", fixed);
5199 xmlSetNsProp(cur, ns, BAD_CAST "base", uri);
5917 * Returns the XML ns-struct or NULL on API and internal errors.
5927 xmlNsPtr ns;
5928 ns = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
5929 if (ns == NULL) {
5934 memset(ns, 0, sizeof(xmlNs));
5935 ns->type = XML_LOCAL_NAMESPACE;
5936 ns->href = xmlStrdup(XML_XML_NAMESPACE);
5937 ns->prefix = xmlStrdup((const xmlChar *)"xml");
5938 doc->oldNs = ns;
5939 return (ns);
6018 cur = node->ns;
6151 cur = node->ns;
6171 * @ns: the original namespace
6175 * @ns trying to reuse the same prefix. However if the given prefix is
6181 xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
6193 if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {
6196 "xmlNewReconciliedNs : ns == NULL\n");
6203 def = xmlSearchNsByHref(doc, tree, ns->href);
6211 if (ns->prefix == NULL)
6214 snprintf((char *) prefix, sizeof(prefix), "%.20s", (char *)ns->prefix);
6219 if (ns->prefix == NULL)
6223 (char *)ns->prefix, counter++);
6230 def = xmlNewNs(tree, ns->href, prefix);
6268 if (node->ns != NULL) {
6289 if (oldNs[i] == node->ns) {
6290 node->ns = newNs[i];
6298 n = xmlNewReconciliedNs(doc, tree, node->ns);
6321 oldNs[nbCache++] = node->ns;
6322 node->ns = n;
6332 if (attr->ns != NULL) {
6353 if (oldNs[i] == attr->ns) {
6354 attr->ns = newNs[i];
6362 n = xmlNewReconciliedNs(doc, tree, attr->ns);
6385 oldNs[nbCache++] = attr->ns;
6386 attr->ns = n;
6447 if ((prop->ns == NULL) && xmlStrEqual(prop->name, name)) {
6457 if ((prop->ns != NULL) && xmlStrEqual(prop->name, name) &&
6458 ((prop->ns->href == nsName) ||
6459 xmlStrEqual(prop->ns->href, nsName)))
6483 if ((node->ns != NULL) && (node->ns->prefix != NULL)) {
6484 tmpstr = xmlStrdup(node->ns->prefix);
6507 * ns-decls corresponding to @nsName.
6753 * @ns: the namespace definition
6760 xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
6763 prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
6782 * error it there's no such ns-binding for the prefix in
6800 xmlNsPtr ns;
6802 ns = xmlSearchNs(node->doc, node, prefix);
6805 if (ns != NULL)
6806 return(xmlSetNsProp(node, ns, nqname, value));
6814 * @ns: the namespace definition
6819 * The ns structure must be in scope, this is not checked
6824 xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
6829 if (ns && (ns->href == NULL))
6831 prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
6844 prop->ns = ns;
6871 return(xmlNewPropInternal(node, ns, name, value, 0));
7762 xmlNsPtr oldNs; /* old ns decl reference */
7763 xmlNsPtr newNs; /* new ns decl reference */
7767 * >= 0 == @node's ns-decls
7768 * -1 == @parent's ns-decls
7769 * -2 == the doc->oldNs XML ns-decl
7770 * -3 == the doc->oldNs storage ns-decls
7771 * -4 == ns-decls provided via custom ns-handling
7797 * @map: the ns-map
7799 * Frees the ns-map
7825 * @map: the ns-map
7826 * @oldNs: the old ns-struct
7827 * @newNs: the new ns-struct
7828 * @depth: depth and ns-kind information
7830 * Adds an ns-mapping item.
7847 * Create the ns-map.
7916 * Returns the aquired ns struct or NULL in case of an API
7924 xmlNsPtr ns;
7928 ns = xmlTreeEnsureXMLDecl(doc);
7929 if (ns == NULL)
7931 if (ns->next != NULL) {
7933 ns = ns->next;
7934 while (ns != NULL) {
7935 if (((ns->prefix == prefix) ||
7936 xmlStrEqual(ns->prefix, prefix)) &&
7937 xmlStrEqual(ns->href, nsName)) {
7938 return (ns);
7940 if (ns->next == NULL)
7942 ns = ns->next;
7946 if (ns != NULL) {
7947 ns->next = xmlNewNs(NULL, nsName, prefix);
7948 return (ns->next);
7995 * @nsList: a list of ns-structs
7998 * Searches for a ns-decl with the given prefix in @nsList.
8000 * Returns the ns-decl if found, NULL if not found and on
8009 xmlNsPtr ns;
8010 ns = nsList;
8012 if ((prefix == ns->prefix) ||
8013 xmlStrEqual(prefix, ns->prefix)) {
8014 return (ns);
8016 ns = ns->next;
8017 } while (ns != NULL);
8028 * Puts in-scope namespaces into the ns-map.
8037 xmlNsPtr ns;
8046 * Get in-scope ns-decls of @parent.
8052 ns = cur->nsDef;
8060 if ((ns->prefix == mi->newNs->prefix) ||
8061 xmlStrEqual(ns->prefix, mi->newNs->prefix)) {
8071 ns, XML_TREE_NSMAP_PARENT);
8076 ns = ns->next;
8077 } while (ns != NULL);
8121 * For internal use. Adds a ns-decl mapping.
8132 xmlTreeErrMemory("alloc ns map item");
8142 xmlTreeErrMemory("realloc ns map item");
8160 * This will substitute ns-references to node->nsDef for
8161 * ns-references to doc->oldNs, thus ensuring the removed
8162 * branch to be autark wrt ns-references.
8175 xmlNsPtr ns;
8200 * Save out-of-scope ns-references in doc->oldNs.
8206 ns = node->nsDef;
8209 &nbList, ns, ns) == -1)
8211 ns = ns->next;
8212 } while (ns != NULL);
8216 if (node->ns != NULL) {
8222 if (node->ns == list[j]) {
8223 node->ns = list[++j];
8228 ns = NULL;
8237 ns = xmlDOMWrapStoreNs(doc, node->ns->href,
8238 node->ns->prefix);
8239 if (ns == NULL)
8242 if (ns != NULL) {
8247 &nbList, node->ns, ns) == -1)
8250 node->ns = ns;
8293 * @retNs: the resulting ns-decl
8294 * @prefixed: if the found ns-decl must have a prefix (for attributes)
8296 * Dynamically searches for a ns-declaration which matches
8299 * Returns 1 if a ns-decl was found, 0 if not and -1 on API
8308 xmlNsPtr ns, prevns;
8326 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
8327 if (prefixed && (ns->prefix == NULL))
8331 * Check the last level of ns-decls for a
8336 if ((prevns->prefix == ns->prefix) ||
8338 (ns->prefix != NULL) &&
8339 xmlStrEqual(prevns->prefix, ns->prefix))) {
8353 if ((nsName == ns->href) ||
8354 xmlStrEqual(nsName, ns->href)) {
8358 * ns-decls.
8363 ret = xmlNsInScope(doc, node, prev, ns->prefix);
8367 * TODO: Should we try to find a matching ns-name
8370 * be an other matching ns-decl with an unshadowed
8376 *retNs = ns;
8396 * @retNs: the resulting ns-decl
8398 * Dynamically searches for a ns-declaration which matches
8401 * Returns 1 if a ns-decl was found, 0 if not and -1 on API
8410 xmlNsPtr ns;
8429 ns = cur->nsDef;
8431 if ((prefix == ns->prefix) ||
8432 xmlStrEqual(prefix, ns->prefix))
8437 if (ns->href == NULL)
8440 *retNs = ns;
8443 ns = ns->next;
8444 } while (ns != NULL);
8458 * @nsName: the namespace-name of the ns-decl
8459 * @prefix: the preferred prefix of the ns-decl
8460 * @checkShadow: ensure that the new ns-decl doesn't shadow ancestor ns-decls
8463 * given @prefix; if a ns-decl with the given prefix is already existent
8466 * Returns 1 if a ns-decl was found, 0 if not and -1 on API
8485 * Create a ns-decl on @anchor.
8490 * Lookup whether the prefix is unused in elem's ns-decls.
8498 * Does it shadow ancestor ns-decls?
8533 * @ns: the ns-struct to use for the search
8534 * @retNs: the found/created ns-struct
8535 * @nsMap: the ns-map
8537 * @ancestorsOnly: search in ancestor ns-decls only
8538 * @prefixed: if the searched ns-decl must have a prefix (for attributes)
8540 * Searches for a matching ns-name in the ns-decls of @nsMap, if not
8542 * If a new ns-decl needs to be declared on @elem, it tries to use the
8543 * @ns->prefix for it, if this prefix is already in use on @elem, it will
8544 * change the prefix or the new ns-decl.
8551 xmlNsPtr ns,
8561 if ((doc == NULL) || (ns == NULL) || (retNs == NULL) ||
8569 if (IS_STR_XML(ns->prefix)) {
8586 * Try to find an equal ns-name in in-scope ns-decls.
8593 * ns-wellformed and no stale references existed.
8604 /* Equal ns name */
8605 ((mi->newNs->href == ns->href) ||
8606 xmlStrEqual(mi->newNs->href, ns->href))) {
8608 mi->oldNs = ns;
8621 * Store ns-decls in "oldNs" of the document-node.
8623 tmpns = xmlDOMWrapStoreNs(doc, ns->href, ns->prefix);
8629 if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns,
8638 tmpns = xmlDOMWrapNSNormDeclareNsForced(doc, elem, ns->href,
8639 ns->prefix, 0);
8645 * Does it shadow ancestor ns-decls?
8650 ((ns->prefix == mi->newNs->prefix) ||
8651 xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
8660 if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns, tmpns, depth) == NULL) {
8679 * Ensures that ns-references point to ns-decls hold on element-nodes.
8681 * ns-decls where needed. Note that, since prefixes of already existent
8682 * ns-decls can be shadowed by this process, it could break QNames in
8696 xmlNsPtr ns, prevns;
8725 ns = cur->nsDef;
8726 while (ns != NULL) {
8731 * Gather ancestor in-scope ns-decls.
8741 * Lookup the ns ancestor-axis for equal ns-decls in scope.
8747 ((ns->prefix == mi->newNs->prefix) ||
8748 xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&
8749 ((ns->href == mi->newNs->href) ||
8750 xmlStrEqual(ns->href, mi->newNs->href)))
8753 * A redundant ns-decl was found.
8754 * Add it to the list of redundant ns-decls.
8757 &sizeRedund, &nbRedund, ns, mi->newNs) == -1)
8760 * Remove the ns-decl from the element-node.
8763 prevns->next = ns->next;
8765 cur->nsDef = ns->next;
8772 * Skip ns-references handling if the referenced
8773 * ns-decl is declared on the same element.
8775 if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
8778 * Does it shadow any ns-decl?
8784 ((ns->prefix == mi->newNs->prefix) ||
8785 xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
8794 if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,
8798 prevns = ns;
8800 ns = ns->next;
8807 /* No ns, no fun. */
8808 if (cur->ns == NULL)
8821 * Adjust the reference if this was a redundant ns-decl.
8825 if (cur->ns == listRedund[j]) {
8826 cur->ns = listRedund[++j];
8832 * Adopt ns-references.
8840 (cur->ns == mi->oldNs)) {
8842 cur->ns = mi->newNs;
8848 * Aquire a normalized ns-decl and add it to the map.
8851 cur->ns, &ns,
8856 cur->ns = ns;
8940 * Ensures that ns-references point to @destDoc: either to
8944 * wellformed by creating additional ns-decls where needed.
8945 * Note that, since prefixes of already existent ns-decls can be
8965 xmlNsPtr ns = NULL;
8967 /* gather @parent's ns-decls. */
8982 * Get the ns-map from the context if available.
8987 * Disable search for ns-decls in the parent-axis of the
8990 * 2) custom ns-reference handling is used
9039 * - ns->href and ns->prefix are never in the dict, so
9041 * - Note that for custom handling of ns-references,
9042 * the ns-decls need not be stored in the ns-map,
9043 * since they won't be referenced by node->ns.
9050 * Gather @parent's in-scope ns-decls.
9057 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
9059 * NOTE: ns->prefix and ns->href are never in the dict.
9060 * XML_TREE_ADOPT_STR(ns->prefix)
9061 * XML_TREE_ADOPT_STR(ns->href)
9064 * Does it shadow any ns-decl?
9070 ((ns->prefix == mi->newNs->prefix) ||
9071 xmlStrEqual(ns->prefix,
9082 ns, ns, depth) == NULL)
9089 if (cur->ns == NULL)
9099 * Adopt ns-references.
9107 (cur->ns == mi->oldNs)) {
9109 cur->ns = mi->newNs;
9121 ns = ctxt->getNsForNodeFunc(ctxt, cur,
9122 cur->ns->href, cur->ns->prefix);
9124 * Insert mapping if ns is available; it's the users fault
9128 cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL)
9130 cur->ns = ns;
9133 * Aquire a normalized ns-decl and add it to the map.
9136 /* ns-decls on curElem or on destDoc->oldNs */
9138 cur->ns, &ns,
9141 /* ns-decls must be prefixed for attributes. */
9144 cur->ns = ns;
9302 * References of out-of scope ns-decls are remapped to point to @destDoc:
9309 * wellformed by creating additional ns-decls where needed.
9310 * Note that, since prefixes of already existent ns-decls can be
9335 xmlNsPtr ns;
9338 /* gather @parent's ns-decls. */
9505 * Gather @parent's in-scope ns-decls.
9517 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
9530 if (ns->href != NULL)
9531 cloneNs->href = xmlStrdup(ns->href);
9532 if (ns->prefix != NULL)
9533 cloneNs->prefix = xmlStrdup(ns->prefix);
9539 * Note that for custom handling of ns-references,
9540 * the ns-decls need not be stored in the ns-map,
9541 * since they won't be referenced by node->ns.
9547 * Does it shadow any ns-decl?
9553 ((ns->prefix == mi->newNs->prefix) ||
9554 xmlStrEqual(ns->prefix,
9568 ns, cloneNs, depth) == NULL)
9573 /* cur->ns will be processed further down. */
9577 /* cur->ns will be processed further down. */
9623 if (cur->ns == NULL)
9628 ** The following will take care of references to ns-decls ********
9640 * Adopt ns-references.
9648 (cur->ns == mi->oldNs)) {
9652 clone->ns = mi->newNs;
9664 ns = ctxt->getNsForNodeFunc(ctxt, cur,
9665 cur->ns->href, cur->ns->prefix);
9670 cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL)
9672 clone->ns = ns;
9675 * Aquire a normalized ns-decl and add it to the map.
9678 /* ns-decls on curElem or on destDoc->oldNs */
9680 cur->ns, &ns,
9684 /* ns-decls must be prefixed for attributes. */
9687 clone->ns = ns;
9841 * Ensures that ns-references point to @destDoc: either to
9862 if (attr->ns != NULL) {
9863 xmlNsPtr ns = NULL;
9869 if (IS_STR_XML(attr->ns->prefix)) {
9870 ns = xmlTreeEnsureXMLDecl(destDoc);
9875 ns = xmlDOMWrapStoreNs(destDoc, attr->ns->href, attr->ns->prefix);
9880 if (xmlSearchNsByNamespaceStrict(destDoc, destParent, attr->ns->href,
9881 &ns, 1) == -1)
9883 if (ns == NULL) {
9884 ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent,
9885 attr->ns->href, attr->ns->prefix, 1);
9888 if (ns == NULL)
9890 attr->ns = ns;
9962 * References of out-of scope ns-decls are remapped to point to @destDoc:
9969 * wellformed by creating additional ns-decls where needed.
9970 * Note that, since prefixes of already existent ns-decls can be