Hi

I wanted to pass a namespace to the xslt through a parameter and got this
weird behavior.
Given then xml:

<?xml version="1.0" encoding="UTF-8"?>
<common:VICData xmlns:common="http://www.blahblah.com/schema/common";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<t1:page xmlns:t1="http://www.blahblah.com/schema/t1/0"; duration="3"
sequence="1" style="1">
</t1:page>
</common:VICData>

with the following xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
 
xmlns:generic="http://www.blahablah.com/schema/generic";>

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:param
name="param-namespace">http://www.blahablah.com/schema/t1/0</xsl:param>
        <xsl:template match="/">
                <xsl:apply-templates select="*"/>
        </xsl:template>
        <xsl:template  match="node()">
                <xsl:copy>
                        <xsl:copy-of select="@*" />
                        <xsl:value-of select="text()"/>
                <xsl:apply-templates select="*" />
        </xsl:copy>
        </xsl:template>
        <xsl:template match="*[local-name()='page' and
namespace-uri()=$param-namespace]">
                <generic:frame duration="[EMAIL PROTECTED]"
sequence="[EMAIL PROTECTED]">
                        <xsl:apply-templates  select="*"/>
                </generic:frame>
        </xsl:template>
</xsl:stylesheet>

Everything's ok until I try to assign the parameter value through:
theXalanTransformer->setStylesheetParam("param-namespace",
"http://www.blahblah.com/schema/t1/0";);

the transformation fails and I get the following error:
XPathParserException: Unable to resolve prefix 'http'.
experssion = 'http://www.blahblah.com/schema/t1/0'
Remaining token:() (, line -1, column -1)

I looked a bit inside the code and discovered that when the function
XPathProcessorImpl::tokenize sees a colon it assumes that what came before
is a namespace-prefix and that's why it thought that 'http' is a prefix.
I didn't want to mess with the code, since I'm not familiar with it enough.
Is this a bug, or am I doing something wrong?

Cheers
Dvir Ofek


Reply via email to