Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT the prefix xsl for element is not bound

Tags:

xslt

I have an xml generated by a webservice based on openerp, it contains a prefix pp for many elements. I want to convert that xml file to another xml using xslt by selecting many elements. When i try to execute the transformation, it shows me the error 'the prefix xsl for element is not bound' for the prefix pp. I can't declare pp as it is described in many answers, how I can ignore the use of that prefix?

like image 527
Rida Avatar asked Nov 02 '22 20:11

Rida


1 Answers

XPath provides the pp:* syntax to select all elements/attributes with a particular namespace URI regardless of their local names, but not (directly) to select all elements/attributes with a particular local name regardless of namespace. If you don't know in advance what the namespace URI will be then instead of

pp:foo/pp:bar

you have to use tricks like

*[local-name() = 'foo']/*[local-name() = 'bar']

The fact that the document uses "pp" as the prefix is irrelevant, what matters to XPath and XSLT (and to any other namespace-aware XML processing tools) is the local name of an element and its namespace URI. The prefix is simply a device to allow the parser to attach the correct namespace URI to each node.

like image 108
Ian Roberts Avatar answered Dec 15 '22 08:12

Ian Roberts