You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Voytenko, Dimitry" <dv...@sectordatallc.com> on 2002/07/26 21:28:16 UTC
XLTC: variable node-sets in x-path predicates
Hi,
I encountered following problem with following xml/xslt pair (I tried it
with Xalan/xsltc 2.4.D1 build):
XML is:
<?xml version="1.0"?>
<config>
<period-types>
<period-type id="fn" label="Q#"/>
</period-types>
<fields>
<field name="f1">
<period type="fn"/>
</field>
</fields>
</config>
XSLT is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:variable name="period-type"
select="config/period-types/period-type"/>
<fields>
<xsl:for-each select="config/fields/field">
<xsl:variable name="period" select="period"/>
<field name="{@name}">
<period type="{$period/@type}"
label="{$period-type[@id = $period/@type]/@label}"/>
</field>
</xsl:for-each>
</fields>
</xsl:template>
</xsl:stylesheet>
Using Xalan gives result (which is correct):
<?xml version="1.0" encoding="UTF-8"?>
<fields>
<field name="f1">
<period label="Q#" type="fn"/>
</field>
</fields>
Using XSLTC gives result (not correct):
<?xml version="1.0" encoding="UTF-8"?>
<fields>
<field name="f1">
<period type="fn" label=""/>
</field>
</fields>
As you can see, in the XSLTC result attribute @label is empty, while it
should be the same as in case of Xalan usage. So it looks like X-Path
expression "$period-type[@id = $period/@type]/@label" doesn't work correctly
in case of xsltc. To be more exact I think "$period/@type" part in predicate
is not executed right, b/c if you'd replace it with constant value
everything will be fine.
Have anyone reported this problem? I didn't find it in bugzilla. I can go
ahead and submit it as a xsltc bug there. I didn't test it with latest Xalan
build from CVS so it could have been fixed already.
Thanks,
Dmitry
Re: XLTC: variable node-sets in x-path predicates
Posted by Tom Amiro <To...@Sun.COM>.
Dimitry,
I verified this is still a problem in the latest build, so please
put in a bug.
Tom
"Voytenko, Dimitry" wrote:
>
> Hi,
>
> I encountered following problem with following xml/xslt pair (I tried it
> with Xalan/xsltc 2.4.D1 build):
> XML is:
> <?xml version="1.0"?>
> <config>
> <period-types>
> <period-type id="fn" label="Q#"/>
> </period-types>
> <fields>
> <field name="f1">
> <period type="fn"/>
> </field>
> </fields>
> </config>
>
> XSLT is:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="xml"/>
>
> <xsl:template match="/">
> <xsl:variable name="period-type"
> select="config/period-types/period-type"/>
> <fields>
> <xsl:for-each select="config/fields/field">
> <xsl:variable name="period" select="period"/>
> <field name="{@name}">
> <period type="{$period/@type}"
> label="{$period-type[@id = $period/@type]/@label}"/>
> </field>
> </xsl:for-each>
> </fields>
> </xsl:template>
>
> </xsl:stylesheet>
>
> Using Xalan gives result (which is correct):
> <?xml version="1.0" encoding="UTF-8"?>
> <fields>
> <field name="f1">
> <period label="Q#" type="fn"/>
> </field>
> </fields>
>
> Using XSLTC gives result (not correct):
> <?xml version="1.0" encoding="UTF-8"?>
> <fields>
> <field name="f1">
> <period type="fn" label=""/>
> </field>
> </fields>
>
> As you can see, in the XSLTC result attribute @label is empty, while it
> should be the same as in case of Xalan usage. So it looks like X-Path
> expression "$period-type[@id = $period/@type]/@label" doesn't work correctly
> in case of xsltc. To be more exact I think "$period/@type" part in predicate
> is not executed right, b/c if you'd replace it with constant value
> everything will be fine.
>
> Have anyone reported this problem? I didn't find it in bugzilla. I can go
> ahead and submit it as a xsltc bug there. I didn't test it with latest Xalan
> build from CVS so it could have been fixed already.
>
> Thanks,
> Dmitry
--
Tom Amiro -- SQA Engineer
Sun XML Technology Development
voice: 781-442-0589 Fax: 781-442-1437
eMail: tom.amiro@.sun.com