Lines Matching defs:ns

53 xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
775 * @ns: a namespace pointer
780 xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
788 node->ns = ns;
802 "xmlFreeNs : ns == NULL\n");
823 "xmlFreeNsList : ns == NULL\n");
1781 xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
1816 cur->ns = ns;
1900 * @ns: the namespace
1908 xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
1919 return xmlNewPropInternal(node, ns, name, value, 0);
1925 * @ns: the namespace
1933 xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
1944 return xmlNewPropInternal(node, ns, name, value, 1);
2160 * @ns: namespace if any
2163 * Creation of a new node element. @ns is optional (NULL).
2169 xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
2192 cur->ns = ns;
2201 * @ns: namespace if any
2204 * Creation of a new node element. @ns is optional (NULL).
2211 xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
2235 cur->ns = ns;
2245 * @ns: namespace if any
2249 * Creation of a new node element within a document. @ns and @content
2259 xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
2264 cur = xmlNewNodeEatName(ns, (xmlChar *)
2267 cur = xmlNewNode(ns, name);
2282 * @ns: namespace if any
2286 * Creation of a new node element within a document. @ns and @content
2296 xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
2300 cur = xmlNewNodeEatName(ns, name);
2320 * @ns: namespace if any
2324 * Creation of a new node element within a document. @ns and @content
2330 xmlNewDocRawNode(xmlDocPtr doc, xmlNsPtr ns,
2334 cur = xmlNewDocNode(doc, ns, name, NULL);
2411 * @ns: a namespace if any
2416 * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly
2428 xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns,
2452 if (ns == NULL)
2453 cur = xmlNewDocRawNode(parent->doc, parent->ns, name, content);
2455 cur = xmlNewDocRawNode(parent->doc, ns, name, content);
2458 if (ns == NULL)
2461 cur = xmlNewDocRawNode((xmlDocPtr) parent, ns, name, content);
2463 cur = xmlNewDocRawNode( parent->doc, ns, name, content);
2793 * @ns: a namespace if any
2798 * @ns and @content parameters are optional (NULL). If @ns is NULL, the newly
2808 xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
2832 if (ns == NULL)
2833 cur = xmlNewDocNode(parent->doc, parent->ns, name, content);
2835 cur = xmlNewDocNode(parent->doc, ns, name, content);
2838 if (ns == NULL)
2841 cur = xmlNewDocNode((xmlDocPtr) parent, ns, name, content);
2843 cur = xmlNewDocNode( parent->doc, ns, name, content);
2890 if (prop->ns == NULL)
2893 attr = xmlHasNsProp(cur->parent, prop->name, prop->ns->href);
3327 if (cur->ns == NULL)
3330 lastattr = xmlHasNsProp(parent, cur->name, cur->ns->href);
3936 if ((cur->ns != NULL) && (target != NULL)) {
3937 xmlNsPtr ns;
3939 ns = xmlSearchNs(target->doc, target, cur->ns->prefix);
3940 if (ns == NULL) {
3946 ns = xmlSearchNs(cur->doc, cur->parent, cur->ns->prefix);
3947 if (ns != NULL) {
3959 ret->ns = xmlNewNs(root, ns->href, ns->prefix);
3967 if (xmlStrEqual(ns->href, cur->ns->href)) {
3969 ret->ns = ns;
3975 ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
3980 ret->ns = NULL;
4175 if (node->ns != NULL) {
4176 xmlNsPtr ns;
4178 ns = xmlSearchNs(doc, ret, node->ns->prefix);
4179 if (ns == NULL) {
4185 ns = xmlSearchNs(node->doc, node, node->ns->prefix);
4186 if (ns != NULL) {
4190 ret->ns = xmlNewNs(root, ns->href, ns->prefix);
4192 ret->ns = xmlNewReconciliedNs(doc, ret, node->ns);
4198 ret->ns = ns;
4574 if (cur->ns) {
4575 if (cur->ns->prefix != NULL) {
4577 (char *)cur->ns->prefix, (char *)cur->name);
4600 ((tmp->ns == cur->ns) ||
4601 ((tmp->ns != NULL) && (cur->ns != NULL) &&
4602 (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))))
4612 ((tmp->ns == cur->ns) ||
4613 ((tmp->ns != NULL) && (cur->ns != NULL) &&
4614 (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))))
4715 if (cur->ns) {
4716 if (cur->ns->prefix != NULL)
4718 (char *)cur->ns->prefix, (char *)cur->name);
4843 xmlNsPtr ns;
4873 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
4874 if (ns == NULL)
4876 xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
4915 xmlNsPtr ns;
4945 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
4946 if (ns == NULL)
4950 xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default");
4953 xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve");
5060 xmlNsPtr ns;
5102 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
5103 if (ns == NULL)
5107 xmlSetNsProp(cur, ns, BAD_CAST "base", fixed);
5110 xmlSetNsProp(cur, ns, BAD_CAST "base", uri);
5797 * Returns the XML ns-struct or NULL on API and internal errors.
5807 xmlNsPtr ns;
5808 ns = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
5809 if (ns == NULL) {
5814 memset(ns, 0, sizeof(xmlNs));
5815 ns->type = XML_LOCAL_NAMESPACE;
5816 ns->href = xmlStrdup(XML_XML_NAMESPACE);
5817 ns->prefix = xmlStrdup((const xmlChar *)"xml");
5818 doc->oldNs = ns;
5819 return (ns);
5898 cur = node->ns;
6031 cur = node->ns;
6051 * @ns: the original namespace
6055 * @ns trying to reuse the same prefix. However if the given prefix is
6061 xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
6073 if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {
6076 "xmlNewReconciliedNs : ns == NULL\n");
6083 def = xmlSearchNsByHref(doc, tree, ns->href);
6091 if (ns->prefix == NULL)
6094 snprintf((char *) prefix, sizeof(prefix), "%.20s", (char *)ns->prefix);
6099 if (ns->prefix == NULL)
6103 (char *)ns->prefix, counter++);
6110 def = xmlNewNs(tree, ns->href, prefix);
6148 if (node->ns != NULL) {
6169 if (oldNs[i] == node->ns) {
6170 node->ns = newNs[i];
6178 n = xmlNewReconciliedNs(doc, tree, node->ns);
6201 oldNs[nbCache++] = node->ns;
6202 node->ns = n;
6212 if (attr->ns != NULL) {
6233 if (oldNs[i] == attr->ns) {
6234 attr->ns = newNs[i];
6242 n = xmlNewReconciliedNs(doc, tree, attr->ns);
6265 oldNs[nbCache++] = attr->ns;
6266 attr->ns = n;
6327 if ((prop->ns == NULL) && xmlStrEqual(prop->name, name)) {
6337 if ((prop->ns != NULL) && xmlStrEqual(prop->name, name) &&
6338 ((prop->ns->href == nsName) ||
6339 xmlStrEqual(prop->ns->href, nsName)))
6363 if ((node->ns != NULL) && (node->ns->prefix != NULL)) {
6364 tmpstr = xmlStrdup(node->ns->prefix);
6387 * ns-decls corresponding to @nsName.
6633 * @ns: the namespace definition
6640 xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
6643 prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
6662 * error it there's no such ns-binding for the prefix in
6680 xmlNsPtr ns;
6682 ns = xmlSearchNs(node->doc, node, prefix);
6685 if (ns != NULL)
6686 return(xmlSetNsProp(node, ns, nqname, value));
6694 * @ns: the namespace definition
6699 * The ns structure must be in scope, this is not checked
6704 xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
6709 if (ns && (ns->href == NULL))
6711 prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
6724 prop->ns = ns;
6751 return(xmlNewPropInternal(node, ns, name, value, 0));
7598 xmlNsPtr oldNs; /* old ns decl reference */
7599 xmlNsPtr newNs; /* new ns decl reference */
7603 * >= 0 == @node's ns-decls
7604 * -1 == @parent's ns-decls
7605 * -2 == the doc->oldNs XML ns-decl
7606 * -3 == the doc->oldNs storage ns-decls
7607 * -4 == ns-decls provided via custom ns-handling
7633 * @map: the ns-map
7635 * Frees the ns-map
7661 * @map: the ns-map
7662 * @oldNs: the old ns-struct
7663 * @newNs: the new ns-struct
7664 * @depth: depth and ns-kind information
7666 * Adds an ns-mapping item.
7683 * Create the ns-map.
7752 * Returns the aquired ns struct or NULL in case of an API
7760 xmlNsPtr ns;
7764 ns = xmlTreeEnsureXMLDecl(doc);
7765 if (ns == NULL)
7767 if (ns->next != NULL) {
7769 ns = ns->next;
7770 while (ns != NULL) {
7771 if (((ns->prefix == prefix) ||
7772 xmlStrEqual(ns->prefix, prefix)) &&
7773 xmlStrEqual(ns->href, nsName)) {
7774 return (ns);
7776 if (ns->next == NULL)
7778 ns = ns->next;
7782 if (ns != NULL) {
7783 ns->next = xmlNewNs(NULL, nsName, prefix);
7784 return (ns->next);
7831 * @nsList: a list of ns-structs
7834 * Searches for a ns-decl with the given prefix in @nsList.
7836 * Returns the ns-decl if found, NULL if not found and on
7845 xmlNsPtr ns;
7846 ns = nsList;
7848 if ((prefix == ns->prefix) ||
7849 xmlStrEqual(prefix, ns->prefix)) {
7850 return (ns);
7852 ns = ns->next;
7853 } while (ns != NULL);
7864 * Puts in-scope namespaces into the ns-map.
7873 xmlNsPtr ns;
7880 * Get in-scope ns-decls of @parent.
7886 ns = cur->nsDef;
7894 if ((ns->prefix == mi->newNs->prefix) ||
7895 xmlStrEqual(ns->prefix, mi->newNs->prefix)) {
7905 ns, XML_TREE_NSMAP_PARENT);
7910 ns = ns->next;
7911 } while (ns != NULL);
7955 * For internal use. Adds a ns-decl mapping.
7966 xmlTreeErrMemory("alloc ns map item");
7976 xmlTreeErrMemory("realloc ns map item");
7994 * This will substitute ns-references to node->nsDef for
7995 * ns-references to doc->oldNs, thus ensuring the removed
7996 * branch to be autark wrt ns-references.
8009 xmlNsPtr ns;
8034 * Save out-of-scope ns-references in doc->oldNs.
8040 ns = node->nsDef;
8043 &nbList, ns, ns) == -1)
8045 ns = ns->next;
8046 } while (ns != NULL);
8050 if (node->ns != NULL) {
8056 if (node->ns == list[j]) {
8057 node->ns = list[++j];
8062 ns = NULL;
8071 ns = xmlDOMWrapStoreNs(doc, node->ns->href,
8072 node->ns->prefix);
8073 if (ns == NULL)
8076 if (ns != NULL) {
8081 &nbList, node->ns, ns) == -1)
8084 node->ns = ns;
8127 * @retNs: the resulting ns-decl
8128 * @prefixed: if the found ns-decl must have a prefix (for attributes)
8130 * Dynamically searches for a ns-declaration which matches
8133 * Returns 1 if a ns-decl was found, 0 if not and -1 on API
8142 xmlNsPtr ns, prevns;
8158 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
8159 if (prefixed && (ns->prefix == NULL))
8163 * Check the last level of ns-decls for a
8168 if ((prevns->prefix == ns->prefix) ||
8170 (ns->prefix != NULL) &&
8171 xmlStrEqual(prevns->prefix, ns->prefix))) {
8185 if ((nsName == ns->href) ||
8186 xmlStrEqual(nsName, ns->href)) {
8190 * ns-decls.
8195 ret = xmlNsInScope(doc, node, prev, ns->prefix);
8199 * TODO: Should we try to find a matching ns-name
8202 * be an other matching ns-decl with an unshadowed
8208 *retNs = ns;
8228 * @retNs: the resulting ns-decl
8230 * Dynamically searches for a ns-declaration which matches
8233 * Returns 1 if a ns-decl was found, 0 if not and -1 on API
8242 xmlNsPtr ns;
8261 ns = cur->nsDef;
8263 if ((prefix == ns->prefix) ||
8264 xmlStrEqual(prefix, ns->prefix))
8269 if (ns->href == NULL)
8272 *retNs = ns;
8275 ns = ns->next;
8276 } while (ns != NULL);
8290 * @nsName: the namespace-name of the ns-decl
8291 * @prefix: the preferred prefix of the ns-decl
8292 * @checkShadow: ensure that the new ns-decl doesn't shadow ancestor ns-decls
8295 * given @prefix; if a ns-decl with the given prefix is already existent
8298 * Returns 1 if a ns-decl was found, 0 if not and -1 on API
8314 * Create a ns-decl on @anchor.
8319 * Lookup whether the prefix is unused in elem's ns-decls.
8327 * Does it shadow ancestor ns-decls?
8362 * @ns: the ns-struct to use for the search
8363 * @retNs: the found/created ns-struct
8364 * @nsMap: the ns-map
8366 * @ancestorsOnly: search in ancestor ns-decls only
8367 * @prefixed: if the searched ns-decl must have a prefix (for attributes)
8369 * Searches for a matching ns-name in the ns-decls of @nsMap, if not
8371 * If a new ns-decl needs to be declared on @elem, it tries to use the
8372 * @ns->prefix for it, if this prefix is already in use on @elem, it will
8373 * change the prefix or the new ns-decl.
8380 xmlNsPtr ns,
8390 if ((doc == NULL) || (ns == NULL) || (retNs == NULL) ||
8398 if (IS_STR_XML(ns->prefix)) {
8415 * Try to find an equal ns-name in in-scope ns-decls.
8422 * ns-wellformed and no stale references existed.
8433 /* Equal ns name */
8434 ((mi->newNs->href == ns->href) ||
8435 xmlStrEqual(mi->newNs->href, ns->href))) {
8437 mi->oldNs = ns;
8450 * Store ns-decls in "oldNs" of the document-node.
8452 tmpns = xmlDOMWrapStoreNs(doc, ns->href, ns->prefix);
8458 if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns,
8467 tmpns = xmlDOMWrapNSNormDeclareNsForced(doc, elem, ns->href,
8468 ns->prefix, 0);
8474 * Does it shadow ancestor ns-decls?
8479 ((ns->prefix == mi->newNs->prefix) ||
8480 xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
8489 if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns, tmpns, depth) == NULL) {
8508 * Ensures that ns-references point to ns-decls hold on element-nodes.
8510 * ns-decls where needed. Note that, since prefixes of already existent
8511 * ns-decls can be shadowed by this process, it could break QNames in
8525 xmlNsPtr ns, prevns;
8554 ns = cur->nsDef;
8555 while (ns != NULL) {
8560 * Gather ancestor in-scope ns-decls.
8570 * Lookup the ns ancestor-axis for equal ns-decls in scope.
8576 ((ns->prefix == mi->newNs->prefix) ||
8577 xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&
8578 ((ns->href == mi->newNs->href) ||
8579 xmlStrEqual(ns->href, mi->newNs->href)))
8582 * A redundant ns-decl was found.
8583 * Add it to the list of redundant ns-decls.
8586 &sizeRedund, &nbRedund, ns, mi->newNs) == -1)
8589 * Remove the ns-decl from the element-node.
8592 prevns->next = ns->next;
8594 cur->nsDef = ns->next;
8601 * Skip ns-references handling if the referenced
8602 * ns-decl is declared on the same element.
8604 if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
8607 * Does it shadow any ns-decl?
8613 ((ns->prefix == mi->newNs->prefix) ||
8614 xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
8623 if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,
8627 prevns = ns;
8629 ns = ns->next;
8636 /* No ns, no fun. */
8637 if (cur->ns == NULL)
8650 * Adjust the reference if this was a redundant ns-decl.
8654 if (cur->ns == listRedund[j]) {
8655 cur->ns = listRedund[++j];
8661 * Adopt ns-references.
8669 (cur->ns == mi->oldNs)) {
8671 cur->ns = mi->newNs;
8677 * Aquire a normalized ns-decl and add it to the map.
8680 cur->ns, &ns,
8685 cur->ns = ns;
8769 * Ensures that ns-references point to @destDoc: either to
8773 * wellformed by creating additional ns-decls where needed.
8774 * Note that, since prefixes of already existent ns-decls can be
8794 xmlNsPtr ns = NULL;
8796 /* gather @parent's ns-decls. */
8811 * Get the ns-map from the context if available.
8816 * Disable search for ns-decls in the parent-axis of the
8819 * 2) custom ns-reference handling is used
8865 * - ns->href and ns->prefix are never in the dict, so
8867 * - Note that for custom handling of ns-references,
8868 * the ns-decls need not be stored in the ns-map,
8869 * since they won't be referenced by node->ns.
8876 * Gather @parent's in-scope ns-decls.
8883 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
8885 * NOTE: ns->prefix and ns->href are never in the dict.
8886 * XML_TREE_ADOPT_STR(ns->prefix)
8887 * XML_TREE_ADOPT_STR(ns->href)
8890 * Does it shadow any ns-decl?
8896 ((ns->prefix == mi->newNs->prefix) ||
8897 xmlStrEqual(ns->prefix,
8908 ns, ns, depth) == NULL)
8915 if (cur->ns == NULL)
8925 * Adopt ns-references.
8933 (cur->ns == mi->oldNs)) {
8935 cur->ns = mi->newNs;
8947 ns = ctxt->getNsForNodeFunc(ctxt, cur,
8948 cur->ns->href, cur->ns->prefix);
8950 * Insert mapping if ns is available; it's the users fault
8954 cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL)
8956 cur->ns = ns;
8959 * Aquire a normalized ns-decl and add it to the map.
8962 /* ns-decls on curElem or on destDoc->oldNs */
8964 cur->ns, &ns,
8967 /* ns-decls must be prefixed for attributes. */
8970 cur->ns = ns;
9128 * References of out-of scope ns-decls are remapped to point to @destDoc:
9135 * wellformed by creating additional ns-decls where needed.
9136 * Note that, since prefixes of already existent ns-decls can be
9161 xmlNsPtr ns;
9164 /* gather @parent's ns-decls. */
9328 * Gather @parent's in-scope ns-decls.
9340 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
9353 if (ns->href != NULL)
9354 cloneNs->href = xmlStrdup(ns->href);
9355 if (ns->prefix != NULL)
9356 cloneNs->prefix = xmlStrdup(ns->prefix);
9362 * Note that for custom handling of ns-references,
9363 * the ns-decls need not be stored in the ns-map,
9364 * since they won't be referenced by node->ns.
9370 * Does it shadow any ns-decl?
9376 ((ns->prefix == mi->newNs->prefix) ||
9377 xmlStrEqual(ns->prefix,
9391 ns, cloneNs, depth) == NULL)
9396 /* cur->ns will be processed further down. */
9400 /* cur->ns will be processed further down. */
9446 if (cur->ns == NULL)
9451 ** The following will take care of references to ns-decls ********
9463 * Adopt ns-references.
9471 (cur->ns == mi->oldNs)) {
9475 clone->ns = mi->newNs;
9487 ns = ctxt->getNsForNodeFunc(ctxt, cur,
9488 cur->ns->href, cur->ns->prefix);
9493 cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL)
9495 clone->ns = ns;
9498 * Aquire a normalized ns-decl and add it to the map.
9501 /* ns-decls on curElem or on destDoc->oldNs */
9503 cur->ns, &ns,
9507 /* ns-decls must be prefixed for attributes. */
9510 clone->ns = ns;
9664 * Ensures that ns-references point to @destDoc: either to
9685 if (attr->ns != NULL) {
9686 xmlNsPtr ns = NULL;
9692 if (IS_STR_XML(attr->ns->prefix)) {
9693 ns = xmlTreeEnsureXMLDecl(destDoc);
9698 ns = xmlDOMWrapStoreNs(destDoc, attr->ns->href, attr->ns->prefix);
9703 if (xmlSearchNsByNamespaceStrict(destDoc, destParent, attr->ns->href,
9704 &ns, 1) == -1)
9706 if (ns == NULL) {
9707 ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent,
9708 attr->ns->href, attr->ns->prefix, 1);
9711 if (ns == NULL)
9713 attr->ns = ns;
9783 * References of out-of scope ns-decls are remapped to point to @destDoc:
9790 * wellformed by creating additional ns-decls where needed.
9791 * Note that, since prefixes of already existent ns-decls can be