Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
232 xmlXPathContext *ctx;
233 xmlXPathObject *xpath;
234 xmlNodePtr node, ret_node;
235 xmlChar *href, *p, *node_id;
237 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
238 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name)
239 + xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
244 sprintf(
id,
"//%s:%s[@%s:id='%s']", (
char *) xnode->ns->prefix,
245 (
char *) xnode->name,
246 (
char *) xnode->ns->prefix,
249 ctx = xmlXPathNewContext(xnode->doc);
258 ns = xmlGetNsList(xnode->doc, xnode);
259 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
263 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
265 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
268 xmlXPathFreeObject(xpath);
269 xmlXPathFreeContext(ctx);
272 ret_node = xpath->nodesetval->nodeTab[0];
273 xmlXPathFreeObject(xpath);
274 xmlXPathFreeContext(ctx);
277 for (node = xnode ; node != NULL ; node = node->parent)
279 if (node->type != XML_ELEMENT_NODE)
continue;
283 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)