Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
238 xmlXPathContext *ctx;
239 xmlXPathObject *xpath;
240 xmlNodePtr node, ret_node;
241 xmlChar *href, *p, *node_id;
243 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
244 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name)
245 + xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
250 sprintf(
id,
"//%s:%s[@%s:id='%s']", (
char *) xnode->ns->prefix,
251 (
char *) xnode->name,
252 (
char *) xnode->ns->prefix,
255 ctx = xmlXPathNewContext(xnode->doc);
264 ns = xmlGetNsList(xnode->doc, xnode);
265 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
269 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
271 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
274 xmlXPathFreeObject(xpath);
275 xmlXPathFreeContext(ctx);
278 ret_node = xpath->nodesetval->nodeTab[0];
279 xmlXPathFreeObject(xpath);
280 xmlXPathFreeContext(ctx);
283 for (node = xnode ; node != NULL ; node = node->parent)
285 if (node->type != XML_ELEMENT_NODE)
continue;
289 if (!xmlStrcmp(node_id, p))
void * lwalloc(size_t size)
static xmlChar * gmlGetProp(xmlNodePtr xnode, xmlChar *prop)
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)