This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: In Tears... (learning XPath)


At 11:45 14-07-2000 -0500, Jason A. Buss wrote:
>I cannot, for the life of me, get the expression syntax correct.
>
>concat(sect1,$sect1num,.htm)... failed.
>concat("sect1",$sect1num,".htm")... failed.
>concat("sect1"$sect1num".htm")... failed.
>concat(sect1{,$sect1num,.htm}*)... failed.
>concat(sect1,$sect1num,.htm*)... failed.
>
>I know this is a newbie question, but I am stuck here.
>The XPath spec uses concat(expression1,expression2,expression3*) as the
>example...
>The SAXON documentation shows concat(expression1{,expression2}*)...
>
>I can't get either to work.

Both of those syntactic expressions are somewhat misleading.  The XPath one 
means that concat() takes multiple expressions, separated by commas.  The 
asterisk indicates that there should be two, and that the third one is not 
only optional but also repeatable (i.e., that there may be more than three 
arguments).

The SAXON documentation correctly observes that concat() can take one 
expression.  The curly braces encapsulate both the comma and the second 
expression, and indicate that the encapsulation may be repeated.

Both are saying that concat() takes multiple arguments separated by commas.

The main problem you're having is with the nature of an expression.  The 
variable part ($sect1num) is correct, since a variable reference is a valid 
expression.  But the .htm for instance is wrong.  A literal string 
expression must be surrounded by quotes: '.htm'.  It's not clear whether 
sect1 is an XPath or a string.  If it were a string, you'd want

concat('sect1', $sect1num, '.htm')

If sect1 is a path intended to get the value of the sect1 child of the 
current node, then you would do

concat(sect1, $sect1num, '.htm')

HTH,
Chris
--
Christopher R. Maden, Senior XML Analyst, Lexica LLC
222 Kearny St., Ste. 202, San Francisco, CA 94108-4510
+1.415.901.3631 tel./+1.415.477.3619 fax
<URL:http://www.lexica.net/> <URL:http://www.oreilly.com/%7Ecrism/>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]