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

Function xlinkIsLink

ThirdParty/libxml2/vtklibxml2/xlink.c:104–162  ·  view source on GitHub ↗

* xlinkIsLink: * @doc: the document containing the node * @node: the node pointer itself * * Check whether the given node carries the attributes needed * to be a link element (or is one of the linking elements issued * from the (X)HTML DtDs). * This routine don't try to do full checking of the link validity * but tries to detect and return the appropriate link type. * * Returns the xli

Source from the content-addressed store, hash-verified

102 * link detected.
103 */
104xlinkType
105xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) {
106 xmlChar *type = NULL, *role = NULL;
107 xlinkType ret = XLINK_TYPE_NONE;
108
109 if (node == NULL) return(XLINK_TYPE_NONE);
110 if (doc == NULL) doc = node->doc;
111 if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
112 /*
113 * This is an HTML document.
114 */
115 } else if ((node->ns != NULL) &&
116 (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) {
117 /*
118 * !!!! We really need an IS_XHTML_ELEMENT function from HTMLtree.h @@@
119 */
120 /*
121 * This is an XHTML element within an XML document
122 * Check whether it's one of the element able to carry links
123 * and in that case if it holds the attributes.
124 */
125 }
126
127 /*
128 * We don't prevent a-priori having XML Linking constructs on
129 * XHTML elements
130 */
131 type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE);
132 if (type != NULL) {
133 if (xmlStrEqual(type, BAD_CAST "simple")) {
134 ret = XLINK_TYPE_SIMPLE;
135 } else if (xmlStrEqual(type, BAD_CAST "extended")) {
136 role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE);
137 if (role != NULL) {
138 xmlNsPtr xlink;
139 xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE);
140 if (xlink == NULL) {
141 /* Humm, fallback method */
142 if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset"))
143 ret = XLINK_TYPE_EXTENDED_SET;
144 } else {
145 xmlChar buf[200];
146 snprintf((char *) buf, sizeof(buf), "%s:external-linkset",
147 (char *) xlink->prefix);
148 buf[sizeof(buf) - 1] = 0;
149 if (xmlStrEqual(role, buf))
150 ret = XLINK_TYPE_EXTENDED_SET;
151
152 }
153
154 }
155 ret = XLINK_TYPE_EXTENDED;
156 }
157 }
158
159 if (type != NULL) xmlFree(type);
160 if (role != NULL) xmlFree(role);
161 return(ret);

Callers

nothing calls this directly

Calls 3

xmlStrEqualFunction · 0.85
xmlGetNsPropFunction · 0.85
xmlSearchNsFunction · 0.85

Tested by

no test coverage detected