[xslt] Issues using parameters with namespaces



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!






--
George Joseph
Asterisk Software Developer
Check us out at www.sangoma.com and www.asterisk.org
image.png


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]