RE: [xsl] [answered] collecting multiple tokenize() results into one sequence

Subject: RE: [xsl] [answered] collecting multiple tokenize() results into one sequence
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 24 Jul 2008 12:49:06 -0400
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".


 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.

Which could also be very helpful.


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.

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread