[xslt] Issues using parameters with namespaces


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):
<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"/>

<presence xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" ...>

$ 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?


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

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