Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
263 xmlXPathContext *ctx;
264 xmlXPathObject *xpath;
265 xmlNodePtr node, ret_node;
266 xmlChar *href, *p, *node_id;
268 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
269 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name)
270 + xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
275 sprintf(
id,
"//%s:%s[@%s:id='%s']", (
char *) xnode->ns->prefix,
276 (
char *) xnode->name,
277 (
char *) xnode->ns->prefix,
280 ctx = xmlXPathNewContext(xnode->doc);
289 ns = xmlGetNsList(xnode->doc, xnode);
290 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
294 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
296 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
299 xmlXPathFreeObject(xpath);
300 xmlXPathFreeContext(ctx);
303 ret_node = xpath->nodesetval->nodeTab[0];
304 xmlXPathFreeObject(xpath);
305 xmlXPathFreeContext(ctx);
308 for (node = xnode ; node != NULL ; node = node->parent)
310 if (node->type != XML_ELEMENT_NODE)
continue;
314 if (!xmlStrcmp(node_id, p))
void * lwalloc(size_t size)
static xmlChar * gmlGetProp(xmlNodePtr xnode, const char *charProp)
Retrieve a GML property from a node or NULL otherwise Respect namespaces if presents in the node elem...
static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code)