Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
231 xmlXPathContext *ctx;
232 xmlXPathObject *xpath;
233 xmlNodePtr node, ret_node;
234 xmlChar *href, *p, *node_id;
236 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
237 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name)
238 + xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
243 sprintf(
id,
"//%s:%s[@%s:id='%s']", (
char *) xnode->ns->prefix,
244 (
char *) xnode->name,
245 (
char *) xnode->ns->prefix,
248 ctx = xmlXPathNewContext(xnode->doc);
257 ns = xmlGetNsList(xnode->doc, xnode);
258 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
262 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
264 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
267 xmlXPathFreeObject(xpath);
268 xmlXPathFreeContext(ctx);
271 ret_node = xpath->nodesetval->nodeTab[0];
272 xmlXPathFreeObject(xpath);
273 xmlXPathFreeContext(ctx);
276 for (node = xnode ; node != NULL ; node = node->parent)
278 if (node->type != XML_ELEMENT_NODE)
continue;
282 if (!xmlStrcmp(node_id, p))
static void gml_lwpgerror(char *msg, int error_code)
static xmlChar * gmlGetProp(xmlNodePtr xnode, xmlChar *prop)
Retrieve a GML propertie from a node or NULL otherwise Respect namespaces if presents in the node ele...
void * lwalloc(size_t size)