Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
255 xmlXPathContext *ctx;
256 xmlXPathObject *xpath;
257 xmlNodePtr node, ret_node;
258 xmlChar *href, *p, *node_id;
260 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
266 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name) +
267 xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
269 sprintf(
id,
"//%s:%s[@%s:id='%s']",
270 (
char *) xnode->ns->prefix,
271 (
char *) xnode->name,
272 (
char *) xnode->ns->prefix,
277 id =
lwalloc((xmlStrlen(xnode->name) +
278 xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
280 sprintf(
id,
"//%s[@id='%s']",
281 (
char *) xnode->name,
285 ctx = xmlXPathNewContext(xnode->doc);
294 ns = xmlGetNsList(xnode->doc, xnode);
295 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
299 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
301 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
304 xmlXPathFreeObject(xpath);
305 xmlXPathFreeContext(ctx);
308 ret_node = xpath->nodesetval->nodeTab[0];
309 xmlXPathFreeObject(xpath);
310 xmlXPathFreeContext(ctx);
313 for (node = xnode ; node != NULL ; node = node->parent)
315 if (node->type != XML_ELEMENT_NODE)
continue;
319 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)