XSLT : getting the prefix of an element?
function, prefix, xml, xslt
Solution
Not as far as I know. If you're sure the node name has a prefix, you can use this:
substring-before(name(), ':')
or this, if you are not sure:
substring-before(
name(),
concat(':', local-name())
)
The latter expression is based on the fact that `substring-before()` returns the empty string when the searched string is not found. This way it will work correctly for prefixed and unprefixed names.
Problem
In XSLT 1.0, you can get the local name or the namespaceUri of an XML element using the functions: ``` string local-name (node) ``` and ``` string namespace-uri(node) ``` but is there a standard function to get the prefix of an element having a qualified name ?