You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/10/17 00:36:20 UTC
DO NOT REPLY [Bug 13711] New: -
Incorrect validation of func:function
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13711>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13711
Incorrect validation of func:function
Summary: Incorrect validation of func:function
Product: XalanJ2
Version: 2.4
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Major
Priority: Other
Component: org.apache.xalan.processor
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: avandenhoven@cucbc.com
Currently, if a func:function block includes the following:
<xsl:variable name="tfilepath">
<xsl:choose>
<xsl:when test="contains($ref, '#')">
<xsl:value-of select="substring-before($ref,'#')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$ref"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
It throws "misplaced literal result in a func:function container." This is
wrong since nothing in a variable is a result.
The problem here seems to be in the following snippet from
org.apache.xalan.processor.ProcessorExsltFunction.validate:
if (elem instanceof ElemValueOf ||
(elem instanceof ElemLiteralResult || elem instanceof ElemElement)
&& !(ancestorIsOk(elem)))
This is like saying:
if (x || y && !z)
And I'm not sure the logic is explicit enough to be correct. Not to mention the
fact that the grouping seems to be a little odd. It would be better, I think to
use:
if (( elem instanceof ElemValueOf
|| elem instanceof ElemLiteralResult
|| elem instanceof ElemElement)
&& !(ancestorIsOk(elem)))
In addition the validation in incomplete. The EXSLT pages for func: says:
Begin Quote:
Function Results
The content of the func:function element is a template. When the function is
called, the template is instantiated to give the result of the function. The
template is instantiated with the context node from the expression in which the
function was called as the current node, and with the context node list from
the expression in which the function was called as the current node list.
It is an error if the instantiation of the template results in the generation
of result nodes.
...
:End Quote
Now my reading of this suggests that you should also invalidate for anything
that results in a node of any sort being generated. You should be checking for:
xsl:element
xsl:attribute
xsl:text
xsl:processing-instruction
xsl:comment
xsl:copy
xsl:value-of
xsl:number
xsl:apply-templates
xsl:apply-import
xsl:call-templates
xsl:text
All these should fail unless they are children of result, param or
variable. Now the if statement from above (if my quick survey of the
source code was correct) should probably be:
if((elem instanceof ElemApplyImport
|| elem instanceof ElemApplyTemplates
|| elem instanceof ElemAttribute
|| elem instanceof ElemCallTemplate
|| elem instanceof ElemComment
|| elem instanceof ElemCopy
|| elem instanceof ElemCopyOf
|| elem instanceof ElemElement
|| elem instanceof ElemLiteralResult
|| elem instanceof ElemNumber
|| elem instanceof ElemPI
|| elem instanceof ElemText
|| elem instanceof ElemTextLiteral
|| elem instanceof ElemVariable)
&& !(ancestorIsOk(elem)))
This should work and meat the requirements of EXSLT
Adam