[xslt] Issues using parameters with namespaces
- From: George Joseph <gjoseph sangoma com>
- To: xslt gnome org
- Subject: [xslt] Issues using parameters with namespaces
- Date: Mon, 28 Feb 2022 10:50:38 -0700
Greetings,
I've been having a heck of a time trying to pass a parameter to xsltApplyStylesheet
that has namespaces in the xpath _expression_.
For example (abbreviated):
stylesheet:
<xsl:stylesheet xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" ...>
<xsl:param name="path" select="/*" />
<xsl:template match="/">
<xsl:apply-templates select="$path"/>
</xsl:template>
xml:
<presence xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" ...>
<dm:device/>
...
$ xsltproc --param path "//dm:device" pidf_lo.xslt pidf_lo_test.xml
XPath error : Undefined namespace prefix
runtime error
Evaluating user parameter path failed
if I hard code that select="//dm:device" it works fine.
Finally I did find a workaround by calling xsltNewTransformContext() then iterating
over the nsDefs in the stylesheet document and calling xmlXPathRegisterNs on
ctxt->xpathCtxt for each nsDef.
I would have thought this would have been done automatically though. Did I
miss something or is there a better way to do this?
Thanks!
--
Asterisk Software Developer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]