Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
262 xmlXPathContext *ctx;
263 xmlXPathObject *xpath;
264 xmlNodePtr node, ret_node;
265 xmlChar *href, *p, *node_id;
267 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
273 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name) +
274 xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
276 sprintf(
id,
"//%s:%s[@%s:id='%s']",
277 (
char *) xnode->ns->prefix,
278 (
char *) xnode->name,
279 (
char *) xnode->ns->prefix,
284 id =
lwalloc((xmlStrlen(xnode->name) +
285 xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
287 sprintf(
id,
"//%s[@id='%s']",
288 (
char *) xnode->name,
292 ctx = xmlXPathNewContext(xnode->doc);
301 ns = xmlGetNsList(xnode->doc, xnode);
302 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
306 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
308 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
311 xmlXPathFreeObject(xpath);
312 xmlXPathFreeContext(ctx);
315 ret_node = xpath->nodesetval->nodeTab[0];
316 xmlXPathFreeObject(xpath);
317 xmlXPathFreeContext(ctx);
320 for (node = xnode ; node != NULL ; node = node->parent)
322 if (node->type != XML_ELEMENT_NODE)
continue;
326 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)