Re: [xslt] XPath functions arguments



On Tue, Jan 14, 2003 at 06:50:07PM +0300, Alexey Efimov wrote:
> Hello.
> 
> Is such concat() function behavior correct?
> 
> >cat test.xsl
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0" >
> 
> <xsl:template match="/">
>         <xsl:value-of select="concat('a', 'b', )"/>
> <!--                                       ^^^^^ -->
> </xsl:template>
> 
> </xsl:stylesheet>
> >
> >xslproc test.xsl d1.xml
> <?xml version="1.0"?>
> ab
> >
> >xsltproc --version
> Using libxml 20501, libxslt 10023 and libexslt 714
> xsltproc was compiled against libxml 20428, libxslt 10023 and libexslt 714
> libxslt 10023 was compiled against libxml 20428
> libexslt 714 was compiled against libxml 20428
> 
> http://www.w3.org/TR/xpath#NT-FunctionCall says:
> ---
> [16]    FunctionCall    ::=    FunctionName '(' ( Argument ( ',' Argument )* )? ')'
> ---
> 
> but http://www.w3.org/TR/xpath#concat-func:
> ---
> Function: string concat(string, string, string*)
> ---
> 
> With msxml I have an error message:
> "Expression expected. concat('a', 'b', -->)<--"

  Yup, it's a bug !

> Sorry, I cannot create a patch (if it's a bug) -- xpath.c is not fully
> clear for me yet ;)

  Big surprize :-)

Very small patch:

before:
paphio:~/XML -> ./testXPath "concat('a', 'b', )"
Object is a string : ab
paphio:~/XML ->

after:
paphio:~/XML -> ./testXPath "concat('a', 'b', )"
XPath error Invalid expression
concat('a', 'b', )
                 ^
XPath error Invalid expression
concat('a', 'b', )
	         ^
Object is empty (NULL)
paphio:~/XML ->

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Index: xpath.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xpath.c,v
retrieving revision 1.213
diff -c -r1.213 xpath.c
*** xpath.c	10 Jan 2003 17:06:09 -0000	1.213
--- xpath.c	14 Jan 2003 16:06:06 -0000
***************
*** 7617,7635 ****
      SKIP_BLANKS;
  
      ctxt->comp->last = -1;
!     while (CUR != ')') {
! 	int op1 = ctxt->comp->last;
! 	ctxt->comp->last = -1;
!         xmlXPathCompileExpr(ctxt);
! 	CHECK_ERROR;
! 	PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0);
! 	nbargs++;
! 	if (CUR == ')') break;
! 	if (CUR != ',') {
! 	    XP_ERROR(XPATH_EXPR_ERROR);
  	}
- 	NEXT;
- 	SKIP_BLANKS;
      }
      PUSH_LONG_EXPR(XPATH_OP_FUNCTION, nbargs, 0, 0,
  	           name, prefix);
--- 7617,7637 ----
      SKIP_BLANKS;
  
      ctxt->comp->last = -1;
!     if (CUR != ')') {
! 	while (CUR != 0) {
! 	    int op1 = ctxt->comp->last;
! 	    ctxt->comp->last = -1;
! 	    xmlXPathCompileExpr(ctxt);
! 	    CHECK_ERROR;
! 	    PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0);
! 	    nbargs++;
! 	    if (CUR == ')') break;
! 	    if (CUR != ',') {
! 		XP_ERROR(XPATH_EXPR_ERROR);
! 	    }
! 	    NEXT;
! 	    SKIP_BLANKS;
  	}
      }
      PUSH_LONG_EXPR(XPATH_OP_FUNCTION, nbargs, 0, 0,
  	           name, prefix);


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