Subject: [xsl] Re: [answered] collecting multiple tokenize() results into one sequence From: Lars Huttar <huttarl@xxxxxxxxx> Date: Tue, 29 Jul 2008 12:17:10 -0500 |
Date: Thu, 24 Jul 2008 17:12:13 +0100 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> From: "Michael Kay" <mike@xxxxxxxxxxxx> Subject: RE: [xsl] [answered] collecting multiple tokenize() results into one sequence Message-ID: <24A7AFA7A62E4D5BBE3DE8A0C02157D8@Sealion>
How to clarify the error message? What about (borrowing language from the above paragraph):
"Invalid initial / or // in path step: Cannot select the root node of the tree that contains the context node, because the context item is not a node."
It's a little long, but given that I'm not the first one who has been unhelped by the existing error message, wouldn't it be worth it to make this somewhat obscure problem clearer?
I'll see what I can do to improve it.
One of the difficulties in designing run-time error messages
Actually this was labeled as a compile-time error message in my case. But no doubt it can occur at run-time as well...
is that it's dangerous to make assumptions about what constructs were used in the original source code, since the same run-time code can be produced from many different source code formulations.
However, there are many cases where
Saxon saves information at compile time for use in the event of a run-time
error, so that better diagnostics can be produced, and it might be possible
to do the same here.
Date: Thu, 24 Jul 2008 12:49:06 -0400 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Subject: RE: [xsl] [answered] collecting multiple tokenize() results into one sequence
At 12:12 PM 7/24/2008, Mike wrote:
How to clarify the error message? What about (borrowing
language from the above paragraph):
"Invalid initial / or // in path step: Cannot select the root
node of the tree that contains the context node, because the
context item is not a node."
It's more general than that, since you'll also get the error for a path such as ".//node".
Maybe something like "Path expression invalid: the context item is not a node".
One of the difficulties in designing run-time error messages is that it's
dangerous to make assumptions about what constructs were used in the
original source code, since the same run-time code can be produced from many
different source code formulations.
Indeed. This is why saying less is often better. Hence, my suggestion says even less than the current "Cannot select a node here: the context item is an atomic value".
Hey Lars,
<!-- gather all tokens into one sequence of strings, then group
by identical strings -->
<xsl:for-each-group select="for $tags in //item/meta return
tokenize($tags, ',')" group-by=".">
<xsl:sort select="." /> <!-- alphabetical order -->
<h2><xsl:value-of select="."/>:</h2>
<ul>
<xsl:for-each select="//item[contains(meta, .)]">
<xsl:sort select="name"/>
<li>...
How about:
<xsl:for-each-group select="//item" group-by="tokenize(meta,',')"> <xsl:sort select="current-grouping-key()"/> <h2><xsl:value-of select="current-grouping-key()"/>:</h2> <ul> <xsl:for-each select="current-group()"> <xsl:sort select="name"/> <li>...
Grouping does not require that there be a single grouping key for each item grouped, and an item may appear in more than one group.
Thanks, Lars
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: xsl-list Digest 29 Jul 20, XSL-List Owner | Thread | RE: [xsl] Re: [answered] collecting, Michael Kay |
[xsl] Re: xsl-list Digest 29 Jul 20, XSL-List Owner | Date | RE: [xsl] Re: [answered] collecting, Michael Kay |
Month |