MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlDOMWrapNSNormAcquireNormalizedNs

Function xmlDOMWrapNSNormAcquireNormalizedNs

ThirdParty/libxml2/vtklibxml2/tree.c:8552–8669  ·  view source on GitHub ↗

* xmlDOMWrapNSNormAcquireNormalizedNs: * @doc: the doc * @elem: the element-node to declare namespaces on * @ns: the ns-struct to use for the search * @retNs: the found/created ns-struct * @nsMap: the ns-map * @depth: the current tree depth * @ancestorsOnly: search in ancestor ns-decls only * @prefixed: if the searched ns-decl must have a prefix (for attributes) * * Searches for a matching ns-name

Source from the content-addressed store, hash-verified

8550* Returns 0 if succeeded, -1 otherwise and on API/internal errors.
8551*/
8552static int
8553xmlDOMWrapNSNormAcquireNormalizedNs(xmlDocPtr doc,
8554 xmlNodePtr elem,
8555 xmlNsPtr ns,
8556 xmlNsPtr *retNs,
8557 xmlNsMapPtr *nsMap,
8558
8559 int depth,
8560 int ancestorsOnly,
8561 int prefixed)
8562{
8563 xmlNsMapItemPtr mi;
8564
8565 if ((doc == NULL) || (ns == NULL) || (retNs == NULL) ||
8566 (nsMap == NULL))
8567 return (-1);
8568
8569 *retNs = NULL;
8570 /*
8571 * Handle XML namespace.
8572 */
8573 if (IS_STR_XML(ns->prefix)) {
8574 /*
8575 * Insert XML namespace mapping.
8576 */
8577 *retNs = xmlTreeEnsureXMLDecl(doc);
8578 if (*retNs == NULL)
8579 return (-1);
8580 return (0);
8581 }
8582 /*
8583 * If the search should be done in ancestors only and no
8584 * @elem (the first ancestor) was specified, then skip the search.
8585 */
8586 if ((XML_NSMAP_NOTEMPTY(*nsMap)) &&
8587 (! (ancestorsOnly && (elem == NULL))))
8588 {
8589 /*
8590 * Try to find an equal ns-name in in-scope ns-decls.
8591 */
8592 XML_NSMAP_FOREACH(*nsMap, mi) {
8593 if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
8594 /*
8595 * ancestorsOnly: This should be turned on to gain speed,
8596 * if one knows that the branch itself was already
8597 * ns-wellformed and no stale references existed.
8598 * I.e. it searches in the ancestor axis only.
8599 */
8600 ((! ancestorsOnly) || (mi->depth == XML_TREE_NSMAP_PARENT)) &&
8601 /* Skip shadowed prefixes. */
8602 (mi->shadowDepth == -1) &&
8603 /* Skip xmlns="" or xmlns:foo="". */
8604 ((mi->newNs->href != NULL) &&
8605 (mi->newNs->href[0] != 0)) &&
8606 /* Ensure a prefix if wanted. */
8607 ((! prefixed) || (mi->newNs->prefix != NULL)) &&
8608 /* Equal ns name */
8609 ((mi->newNs->href == ns->href) ||

Callers 3

xmlDOMWrapAdoptBranchFunction · 0.85
xmlDOMWrapCloneNodeFunction · 0.85

Calls 5

xmlTreeEnsureXMLDeclFunction · 0.85
xmlStrEqualFunction · 0.85
xmlDOMWrapStoreNsFunction · 0.85
xmlDOMWrapNsMapAddItemFunction · 0.85

Tested by

no test coverage detected