Help with xslt syntax error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Kettenbach

    #1

    Help with xslt syntax error

    Hi Peter,
    I get error when processing the stylesheet. It errors here.

    <xsl:for-each select="registr ation[count(.|key('en try',company
    [1])=1]">

    specifically:

    Expression does not return a DOM node.
    registration[-->count(.|key('e ntry',company[1])=1]<--

    Ideas?


    Thanks,
    Chris

    "Peter Flynn" <peter.nosp@m.s ilmaril.ie> wrote in message
    news:3n48ajF19a gvsU1@individua l.net...[color=blue]
    > Chris Kettenbach wrote:
    >[color=green]
    >> Good Morning,
    >> Sorry for xposting. Just need a liitle help.
    >> I have an xml file that's generated from a database. How do I select
    >> distinct values from a field[/color]
    >
    > XML doesn't have fields -- the database did but this isn't a database any
    > more. In XML they're called elements (they've got a lot in common with
    > fields but they ain't the same).
    >[color=green]
    >> in xslt and then loop through the records and
    >> produce output.[/color]
    >
    > It looks like you need to process the information grouped by company name,
    > and there's a technique in XSLT 1.0 for doing this called Muenchian
    > grouping
    > (it won't be needed in XSLT 2 because that has a built-in group-processing
    > command, but XSLT 2 is not a Recommendation yet).
    >
    > Check the XSLT FAQ for "Muenchian" to find examples.
    >
    > ///Peter
    >
    > [Group and followup corrected to comp.text.xml]
    >[color=green]
    >> Example
    >>
    >> <registration s>
    >> <registration >
    >> <company>Awesom e Printers</company>
    >> <first>John</first>
    >> <last>Smith</last>
    >> </registration>
    >> <registration >
    >> <company>Awesom e Printers</company>
    >> <first>Bob</first>
    >> <last>Roberts </last>
    >> </registration>
    >> <registration >
    >> <company>Awesom e Printers</company>
    >> <first>John</first>
    >> <last>Johnson </last>
    >> </registration>
    >> <registration >
    >> <company>Othe r Company</company>
    >> <first>Tom</first>
    >> <last>Thomas</last>
    >> </registration>
    >> <registration >
    >> <company>Othe r Company</company>
    >> <first>Dan</first>
    >> <last>Daniels </last>
    >> </registration>
    >> </registrations>
    >> +++++++++++++++ +++++++++++++++ +++++++++++++++ +++
    >> I want the out put to be something like this
    >>
    >> <table>
    >> <tr>
    >> <td>Company Name</td>
    >> <td>Employees </td>
    >> </tr>
    >> <tr>
    >> <td>Awesome Printers</td>
    >> <td>John Smith<br/>
    >> Bob Roberts<br/>
    >> John Johnson<br/></td>
    >> </tr>
    >> <tr>
    >> <td>Other Company</td>
    >> <td>Tom Thomas<br/>
    >> Dan Daniels<br/></td>
    >> </tr>
    >> </table>
    >>
    >> Effectively writing unique company names once and then putting only the
    >> employees from that company into the employee table cell.[/color]
    >
    > If you scrolled down this far then you've been rewarded :-)
    >
    > The trick is to use lookup keys to test the selected group of elements
    > against, in order to pick only the first ocurrence in each group; then
    > output the group header at that point; and only then go and process all
    > the
    > elements in the group to extract the detail from each of them.
    >
    > The syntax is tricky because it's very compact. It selects all
    > registration
    > elements, but subjects each of them to the test that [the number of nodes
    > in
    > the union of (the current node and the first node with the current company
    > value returned by the lookup) is equal to 1] -- in effect meaning they are
    > one and the same node, ie the first in their company name grouping. You'll
    > probably need to read that 3 or 4 times -- it took me a week to grok it.
    >
    > <?xml version="1.0" encoding="iso-8859-1"?>
    > <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    > version="1.0">
    >
    > <xsl:output method="html"/>
    >
    > <xsl:key name="entry" match="registra tion" use="company"/>
    >
    > <xsl:template match="/">
    > <html>
    > <head>
    > <title>Registra tions</title>
    > </head>
    > <body>
    > <xsl:apply-templates/>
    > </body>
    > </html>
    > </xsl:template>
    >
    > <xsl:template match="registra tions">
    > <table>
    > <xsl:for-each select="registr ation[count(.|key('en try',company
    > [1])=1]">
    > <xsl:sort select="company "/>
    > <tr>
    > <th valign="top">
    > <xsl:value-of select="company "/>
    > </th>
    > <td valign="top">
    > <xsl:for-each select="key('en try',current()/company)">
    > <xsl:sort select="last"/>
    > <xsl:value-of select="first"/>
    > <xsl:text> </xsl:text>
    > <xsl:value-of select="last"/>
    > <xsl:if test="position( )!=last()">
    > <br/>
    > </xsl:if>
    > </xsl:for-each>
    > </td>
    > </tr>
    > </xsl:for-each>
    > </table>
    > </xsl:template>
    >
    > </xsl:stylesheet>
    >
    > ///Peter
    >[/color]



  • Dimitre Novatchev

    #2
    Re: Help with xslt syntax error

    Unbalanced left <--> right parenthenses



    "Chris Kettenbach" <info@piasd.net > wrote in message
    news:QYednQ7AnY QFcpDeRVn-iQ@giganews.com ...[color=blue]
    > Hi Peter,
    > I get error when processing the stylesheet. It errors here.
    >
    > <xsl:for-each select="registr ation[count(.|key('en try',company
    > [1])=1]">
    >
    > specifically:
    >
    > Expression does not return a DOM node.
    > registration[-->count(.|key('e ntry',company[1])=1]<--
    >
    > Ideas?
    >
    >
    > Thanks,
    > Chris
    >
    > "Peter Flynn" <peter.nosp@m.s ilmaril.ie> wrote in message
    > news:3n48ajF19a gvsU1@individua l.net...[color=green]
    >> Chris Kettenbach wrote:
    >>[color=darkred]
    >>> Good Morning,
    >>> Sorry for xposting. Just need a liitle help.
    >>> I have an xml file that's generated from a database. How do I select
    >>> distinct values from a field[/color]
    >>
    >> XML doesn't have fields -- the database did but this isn't a database any
    >> more. In XML they're called elements (they've got a lot in common with
    >> fields but they ain't the same).
    >>[color=darkred]
    >>> in xslt and then loop through the records and
    >>> produce output.[/color]
    >>
    >> It looks like you need to process the information grouped by company
    >> name,
    >> and there's a technique in XSLT 1.0 for doing this called Muenchian
    >> grouping
    >> (it won't be needed in XSLT 2 because that has a built-in
    >> group-processing
    >> command, but XSLT 2 is not a Recommendation yet).
    >>
    >> Check the XSLT FAQ for "Muenchian" to find examples.
    >>
    >> ///Peter
    >>
    >> [Group and followup corrected to comp.text.xml]
    >>[color=darkred]
    >>> Example
    >>>
    >>> <registration s>
    >>> <registration >
    >>> <company>Awesom e Printers</company>
    >>> <first>John</first>
    >>> <last>Smith</last>
    >>> </registration>
    >>> <registration >
    >>> <company>Awesom e Printers</company>
    >>> <first>Bob</first>
    >>> <last>Roberts </last>
    >>> </registration>
    >>> <registration >
    >>> <company>Awesom e Printers</company>
    >>> <first>John</first>
    >>> <last>Johnson </last>
    >>> </registration>
    >>> <registration >
    >>> <company>Othe r Company</company>
    >>> <first>Tom</first>
    >>> <last>Thomas</last>
    >>> </registration>
    >>> <registration >
    >>> <company>Othe r Company</company>
    >>> <first>Dan</first>
    >>> <last>Daniels </last>
    >>> </registration>
    >>> </registrations>
    >>> +++++++++++++++ +++++++++++++++ +++++++++++++++ +++
    >>> I want the out put to be something like this
    >>>
    >>> <table>
    >>> <tr>
    >>> <td>Company Name</td>
    >>> <td>Employees </td>
    >>> </tr>
    >>> <tr>
    >>> <td>Awesome Printers</td>
    >>> <td>John Smith<br/>
    >>> Bob Roberts<br/>
    >>> John Johnson<br/></td>
    >>> </tr>
    >>> <tr>
    >>> <td>Other Company</td>
    >>> <td>Tom Thomas<br/>
    >>> Dan Daniels<br/></td>
    >>> </tr>
    >>> </table>
    >>>
    >>> Effectively writing unique company names once and then putting only the
    >>> employees from that company into the employee table cell.[/color]
    >>
    >> If you scrolled down this far then you've been rewarded :-)
    >>
    >> The trick is to use lookup keys to test the selected group of elements
    >> against, in order to pick only the first ocurrence in each group; then
    >> output the group header at that point; and only then go and process all
    >> the
    >> elements in the group to extract the detail from each of them.
    >>
    >> The syntax is tricky because it's very compact. It selects all
    >> registration
    >> elements, but subjects each of them to the test that [the number of nodes
    >> in
    >> the union of (the current node and the first node with the current
    >> company
    >> value returned by the lookup) is equal to 1] -- in effect meaning they
    >> are
    >> one and the same node, ie the first in their company name grouping.
    >> You'll
    >> probably need to read that 3 or 4 times -- it took me a week to grok it.
    >>
    >> <?xml version="1.0" encoding="iso-8859-1"?>
    >> <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    >> version="1.0">
    >>
    >> <xsl:output method="html"/>
    >>
    >> <xsl:key name="entry" match="registra tion" use="company"/>
    >>
    >> <xsl:template match="/">
    >> <html>
    >> <head>
    >> <title>Registra tions</title>
    >> </head>
    >> <body>
    >> <xsl:apply-templates/>
    >> </body>
    >> </html>
    >> </xsl:template>
    >>
    >> <xsl:template match="registra tions">
    >> <table>
    >> <xsl:for-each select="registr ation[count(.|key('en try',company
    >> [1])=1]">
    >> <xsl:sort select="company "/>
    >> <tr>
    >> <th valign="top">
    >> <xsl:value-of select="company "/>
    >> </th>
    >> <td valign="top">
    >> <xsl:for-each select="key('en try',current()/company)">
    >> <xsl:sort select="last"/>
    >> <xsl:value-of select="first"/>
    >> <xsl:text> </xsl:text>
    >> <xsl:value-of select="last"/>
    >> <xsl:if test="position( )!=last()">
    >> <br/>
    >> </xsl:if>
    >> </xsl:for-each>
    >> </td>
    >> </tr>
    >> </xsl:for-each>
    >> </table>
    >> </xsl:template>
    >>
    >> </xsl:stylesheet>
    >>
    >> ///Peter
    >>[/color]
    >
    >
    >[/color]


    Comment

    • Chris Kettenbach

      #3
      Re: Help with xslt syntax error

      Do you have an example of how it should look?
      Thanks for your help.
      Chris


      "Dimitre Novatchev" <dimitren@tpg.c om.au> wrote in message
      news:430e1bdc$0 $80641$892e7fe2 @authen.white.r eadfreenews.net ...[color=blue]
      > Unbalanced left <--> right parenthenses
      >
      >
      >
      > "Chris Kettenbach" <info@piasd.net > wrote in message
      > news:QYednQ7AnY QFcpDeRVn-iQ@giganews.com ...[color=green]
      >> Hi Peter,
      >> I get error when processing the stylesheet. It errors here.
      >>
      >> <xsl:for-each select="registr ation[count(.|key('en try',company
      >> [1])=1]">
      >>
      >> specifically:
      >>
      >> Expression does not return a DOM node.
      >> registration[-->count(.|key('e ntry',company[1])=1]<--
      >>
      >> Ideas?
      >>
      >>
      >> Thanks,
      >> Chris
      >>
      >> "Peter Flynn" <peter.nosp@m.s ilmaril.ie> wrote in message
      >> news:3n48ajF19a gvsU1@individua l.net...[color=darkred]
      >>> Chris Kettenbach wrote:
      >>>
      >>>> Good Morning,
      >>>> Sorry for xposting. Just need a liitle help.
      >>>> I have an xml file that's generated from a database. How do I select
      >>>> distinct values from a field
      >>>
      >>> XML doesn't have fields -- the database did but this isn't a database
      >>> any
      >>> more. In XML they're called elements (they've got a lot in common with
      >>> fields but they ain't the same).
      >>>
      >>>> in xslt and then loop through the records and
      >>>> produce output.
      >>>
      >>> It looks like you need to process the information grouped by company
      >>> name,
      >>> and there's a technique in XSLT 1.0 for doing this called Muenchian
      >>> grouping
      >>> (it won't be needed in XSLT 2 because that has a built-in
      >>> group-processing
      >>> command, but XSLT 2 is not a Recommendation yet).
      >>>
      >>> Check the XSLT FAQ for "Muenchian" to find examples.
      >>>
      >>> ///Peter
      >>>
      >>> [Group and followup corrected to comp.text.xml]
      >>>
      >>>> Example
      >>>>
      >>>> <registration s>
      >>>> <registration >
      >>>> <company>Awesom e Printers</company>
      >>>> <first>John</first>
      >>>> <last>Smith</last>
      >>>> </registration>
      >>>> <registration >
      >>>> <company>Awesom e Printers</company>
      >>>> <first>Bob</first>
      >>>> <last>Roberts </last>
      >>>> </registration>
      >>>> <registration >
      >>>> <company>Awesom e Printers</company>
      >>>> <first>John</first>
      >>>> <last>Johnson </last>
      >>>> </registration>
      >>>> <registration >
      >>>> <company>Othe r Company</company>
      >>>> <first>Tom</first>
      >>>> <last>Thomas</last>
      >>>> </registration>
      >>>> <registration >
      >>>> <company>Othe r Company</company>
      >>>> <first>Dan</first>
      >>>> <last>Daniels </last>
      >>>> </registration>
      >>>> </registrations>
      >>>> +++++++++++++++ +++++++++++++++ +++++++++++++++ +++
      >>>> I want the out put to be something like this
      >>>>
      >>>> <table>
      >>>> <tr>
      >>>> <td>Company Name</td>
      >>>> <td>Employees </td>
      >>>> </tr>
      >>>> <tr>
      >>>> <td>Awesome Printers</td>
      >>>> <td>John Smith<br/>
      >>>> Bob Roberts<br/>
      >>>> John Johnson<br/></td>
      >>>> </tr>
      >>>> <tr>
      >>>> <td>Other Company</td>
      >>>> <td>Tom Thomas<br/>
      >>>> Dan Daniels<br/></td>
      >>>> </tr>
      >>>> </table>
      >>>>
      >>>> Effectively writing unique company names once and then putting only the
      >>>> employees from that company into the employee table cell.
      >>>
      >>> If you scrolled down this far then you've been rewarded :-)
      >>>
      >>> The trick is to use lookup keys to test the selected group of elements
      >>> against, in order to pick only the first ocurrence in each group; then
      >>> output the group header at that point; and only then go and process all
      >>> the
      >>> elements in the group to extract the detail from each of them.
      >>>
      >>> The syntax is tricky because it's very compact. It selects all
      >>> registration
      >>> elements, but subjects each of them to the test that [the number of
      >>> nodes
      >>> in
      >>> the union of (the current node and the first node with the current
      >>> company
      >>> value returned by the lookup) is equal to 1] -- in effect meaning they
      >>> are
      >>> one and the same node, ie the first in their company name grouping.
      >>> You'll
      >>> probably need to read that 3 or 4 times -- it took me a week to grok it.
      >>>
      >>> <?xml version="1.0" encoding="iso-8859-1"?>
      >>> <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
      >>> version="1.0">
      >>>
      >>> <xsl:output method="html"/>
      >>>
      >>> <xsl:key name="entry" match="registra tion" use="company"/>
      >>>
      >>> <xsl:template match="/">
      >>> <html>
      >>> <head>
      >>> <title>Registra tions</title>
      >>> </head>
      >>> <body>
      >>> <xsl:apply-templates/>
      >>> </body>
      >>> </html>
      >>> </xsl:template>
      >>>
      >>> <xsl:template match="registra tions">
      >>> <table>
      >>> <xsl:for-each select="registr ation[count(.|key('en try',company
      >>> [1])=1]">
      >>> <xsl:sort select="company "/>
      >>> <tr>
      >>> <th valign="top">
      >>> <xsl:value-of select="company "/>
      >>> </th>
      >>> <td valign="top">
      >>> <xsl:for-each select="key('en try',current()/company)">
      >>> <xsl:sort select="last"/>
      >>> <xsl:value-of select="first"/>
      >>> <xsl:text> </xsl:text>
      >>> <xsl:value-of select="last"/>
      >>> <xsl:if test="position( )!=last()">
      >>> <br/>
      >>> </xsl:if>
      >>> </xsl:for-each>
      >>> </td>
      >>> </tr>
      >>> </xsl:for-each>
      >>> </table>
      >>> </xsl:template>
      >>>
      >>> </xsl:stylesheet>
      >>>
      >>> ///Peter
      >>>[/color]
      >>
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Dimitre Novatchev

        #4
        Re: Help with xslt syntax error


        "Chris Kettenbach" <info@piasd.net > wrote in message
        news:8_mdnWIPV_ ixgJPeRVn-3A@giganews.com ...[color=blue]
        > Do you have an example of how it should look?
        > Thanks for your help.
        > Chris[/color]

        I am not a compiler, but I have developed a tool that may help -- use the
        XPath Visualizer to play with XPath and learn it the fun way.


        Cheers,
        Dimitre Novatchev

        P.S. By not answering your question and directing you to serious
        self-training with the XPath Visualizer I am actually saving you a lot of
        time -- just try it and you'll see :o)


        [color=blue]
        >
        >
        > "Dimitre Novatchev" <dimitren@tpg.c om.au> wrote in message
        > news:430e1bdc$0 $80641$892e7fe2 @authen.white.r eadfreenews.net ...[color=green]
        >> Unbalanced left <--> right parenthenses
        >>
        >>
        >>
        >> "Chris Kettenbach" <info@piasd.net > wrote in message
        >> news:QYednQ7AnY QFcpDeRVn-iQ@giganews.com ...[color=darkred]
        >>> Hi Peter,
        >>> I get error when processing the stylesheet. It errors here.
        >>>
        >>> <xsl:for-each select="registr ation[count(.|key('en try',company
        >>> [1])=1]">
        >>>
        >>> specifically:
        >>>
        >>> Expression does not return a DOM node.
        >>> registration[-->count(.|key('e ntry',company[1])=1]<--
        >>>
        >>> Ideas?
        >>>
        >>>
        >>> Thanks,
        >>> Chris
        >>>
        >>> "Peter Flynn" <peter.nosp@m.s ilmaril.ie> wrote in message
        >>> news:3n48ajF19a gvsU1@individua l.net...
        >>>> Chris Kettenbach wrote:
        >>>>
        >>>>> Good Morning,
        >>>>> Sorry for xposting. Just need a liitle help.
        >>>>> I have an xml file that's generated from a database. How do I select
        >>>>> distinct values from a field
        >>>>
        >>>> XML doesn't have fields -- the database did but this isn't a database
        >>>> any
        >>>> more. In XML they're called elements (they've got a lot in common with
        >>>> fields but they ain't the same).
        >>>>
        >>>>> in xslt and then loop through the records and
        >>>>> produce output.
        >>>>
        >>>> It looks like you need to process the information grouped by company
        >>>> name,
        >>>> and there's a technique in XSLT 1.0 for doing this called Muenchian
        >>>> grouping
        >>>> (it won't be needed in XSLT 2 because that has a built-in
        >>>> group-processing
        >>>> command, but XSLT 2 is not a Recommendation yet).
        >>>>
        >>>> Check the XSLT FAQ for "Muenchian" to find examples.
        >>>>
        >>>> ///Peter
        >>>>
        >>>> [Group and followup corrected to comp.text.xml]
        >>>>
        >>>>> Example
        >>>>>
        >>>>> <registration s>
        >>>>> <registration >
        >>>>> <company>Awesom e Printers</company>
        >>>>> <first>John</first>
        >>>>> <last>Smith</last>
        >>>>> </registration>
        >>>>> <registration >
        >>>>> <company>Awesom e Printers</company>
        >>>>> <first>Bob</first>
        >>>>> <last>Roberts </last>
        >>>>> </registration>
        >>>>> <registration >
        >>>>> <company>Awesom e Printers</company>
        >>>>> <first>John</first>
        >>>>> <last>Johnson </last>
        >>>>> </registration>
        >>>>> <registration >
        >>>>> <company>Othe r Company</company>
        >>>>> <first>Tom</first>
        >>>>> <last>Thomas</last>
        >>>>> </registration>
        >>>>> <registration >
        >>>>> <company>Othe r Company</company>
        >>>>> <first>Dan</first>
        >>>>> <last>Daniels </last>
        >>>>> </registration>
        >>>>> </registrations>
        >>>>> +++++++++++++++ +++++++++++++++ +++++++++++++++ +++
        >>>>> I want the out put to be something like this
        >>>>>
        >>>>> <table>
        >>>>> <tr>
        >>>>> <td>Company Name</td>
        >>>>> <td>Employees </td>
        >>>>> </tr>
        >>>>> <tr>
        >>>>> <td>Awesome Printers</td>
        >>>>> <td>John Smith<br/>
        >>>>> Bob Roberts<br/>
        >>>>> John Johnson<br/></td>
        >>>>> </tr>
        >>>>> <tr>
        >>>>> <td>Other Company</td>
        >>>>> <td>Tom Thomas<br/>
        >>>>> Dan Daniels<br/></td>
        >>>>> </tr>
        >>>>> </table>
        >>>>>
        >>>>> Effectively writing unique company names once and then putting only
        >>>>> the
        >>>>> employees from that company into the employee table cell.
        >>>>
        >>>> If you scrolled down this far then you've been rewarded :-)
        >>>>
        >>>> The trick is to use lookup keys to test the selected group of elements
        >>>> against, in order to pick only the first ocurrence in each group; then
        >>>> output the group header at that point; and only then go and process all
        >>>> the
        >>>> elements in the group to extract the detail from each of them.
        >>>>
        >>>> The syntax is tricky because it's very compact. It selects all
        >>>> registration
        >>>> elements, but subjects each of them to the test that [the number of
        >>>> nodes
        >>>> in
        >>>> the union of (the current node and the first node with the current
        >>>> company
        >>>> value returned by the lookup) is equal to 1] -- in effect meaning they
        >>>> are
        >>>> one and the same node, ie the first in their company name grouping.
        >>>> You'll
        >>>> probably need to read that 3 or 4 times -- it took me a week to grok
        >>>> it.
        >>>>
        >>>> <?xml version="1.0" encoding="iso-8859-1"?>
        >>>> <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
        >>>> version="1.0">
        >>>>
        >>>> <xsl:output method="html"/>
        >>>>
        >>>> <xsl:key name="entry" match="registra tion" use="company"/>
        >>>>
        >>>> <xsl:template match="/">
        >>>> <html>
        >>>> <head>
        >>>> <title>Registra tions</title>
        >>>> </head>
        >>>> <body>
        >>>> <xsl:apply-templates/>
        >>>> </body>
        >>>> </html>
        >>>> </xsl:template>
        >>>>
        >>>> <xsl:template match="registra tions">
        >>>> <table>
        >>>> <xsl:for-each select="registr ation[count(.|key('en try',company
        >>>> [1])=1]">
        >>>> <xsl:sort select="company "/>
        >>>> <tr>
        >>>> <th valign="top">
        >>>> <xsl:value-of select="company "/>
        >>>> </th>
        >>>> <td valign="top">
        >>>> <xsl:for-each select="key('en try',current()/company)">
        >>>> <xsl:sort select="last"/>
        >>>> <xsl:value-of select="first"/>
        >>>> <xsl:text> </xsl:text>
        >>>> <xsl:value-of select="last"/>
        >>>> <xsl:if test="position( )!=last()">
        >>>> <br/>
        >>>> </xsl:if>
        >>>> </xsl:for-each>
        >>>> </td>
        >>>> </tr>
        >>>> </xsl:for-each>
        >>>> </table>
        >>>> </xsl:template>
        >>>>
        >>>> </xsl:stylesheet>
        >>>>
        >>>> ///Peter
        >>>>
        >>>
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Peter Flynn

          #5
          Re: Help with xslt syntax error

          Dimitre Novatchev wrote:
          [color=blue]
          > Unbalanced left <--> right parenthenses[/color]

          Quite right, it looks like something chewed off the closing parenthesis.
          I pasted the code from the working file, so it may have been garbled in
          transmission. The line should read

          <xsl:for-each select="registr ation[count(.|key('en try',company)[1])=1]">

          (that too is cut'n'paste so if that gets screwed, I'm sorry).

          ///Peter
          [color=blue]
          >
          >
          > "Chris Kettenbach" <info@piasd.net > wrote in message
          > news:QYednQ7AnY QFcpDeRVn-iQ@giganews.com ...[color=green]
          >> Hi Peter,
          >> I get error when processing the stylesheet. It errors here.
          >>
          >> <xsl:for-each select="registr ation[count(.|key('en try',company
          >> [1])=1]">
          >>
          >> specifically:
          >>
          >> Expression does not return a DOM node.
          >> registration[-->count(.|key('e ntry',company[1])=1]<--
          >>
          >> Ideas?
          >>
          >>
          >> Thanks,
          >> Chris
          >>
          >> "Peter Flynn" <peter.nosp@m.s ilmaril.ie> wrote in message
          >> news:3n48ajF19a gvsU1@individua l.net...[color=darkred]
          >>> Chris Kettenbach wrote:
          >>>
          >>>> Good Morning,
          >>>> Sorry for xposting. Just need a liitle help.
          >>>> I have an xml file that's generated from a database. How do I select
          >>>> distinct values from a field
          >>>
          >>> XML doesn't have fields -- the database did but this isn't a database
          >>> any more. In XML they're called elements (they've got a lot in common
          >>> with fields but they ain't the same).
          >>>
          >>>> in xslt and then loop through the records and
          >>>> produce output.
          >>>
          >>> It looks like you need to process the information grouped by company
          >>> name,
          >>> and there's a technique in XSLT 1.0 for doing this called Muenchian
          >>> grouping
          >>> (it won't be needed in XSLT 2 because that has a built-in
          >>> group-processing
          >>> command, but XSLT 2 is not a Recommendation yet).
          >>>
          >>> Check the XSLT FAQ for "Muenchian" to find examples.
          >>>
          >>> ///Peter
          >>>
          >>> [Group and followup corrected to comp.text.xml]
          >>>
          >>>> Example
          >>>>
          >>>> <registration s>
          >>>> <registration >
          >>>> <company>Awesom e Printers</company>
          >>>> <first>John</first>
          >>>> <last>Smith</last>
          >>>> </registration>
          >>>> <registration >
          >>>> <company>Awesom e Printers</company>
          >>>> <first>Bob</first>
          >>>> <last>Roberts </last>
          >>>> </registration>
          >>>> <registration >
          >>>> <company>Awesom e Printers</company>
          >>>> <first>John</first>
          >>>> <last>Johnson </last>
          >>>> </registration>
          >>>> <registration >
          >>>> <company>Othe r Company</company>
          >>>> <first>Tom</first>
          >>>> <last>Thomas</last>
          >>>> </registration>
          >>>> <registration >
          >>>> <company>Othe r Company</company>
          >>>> <first>Dan</first>
          >>>> <last>Daniels </last>
          >>>> </registration>
          >>>> </registrations>
          >>>> +++++++++++++++ +++++++++++++++ +++++++++++++++ +++
          >>>> I want the out put to be something like this
          >>>>
          >>>> <table>
          >>>> <tr>
          >>>> <td>Company Name</td>
          >>>> <td>Employees </td>
          >>>> </tr>
          >>>> <tr>
          >>>> <td>Awesome Printers</td>
          >>>> <td>John Smith<br/>
          >>>> Bob Roberts<br/>
          >>>> John Johnson<br/></td>
          >>>> </tr>
          >>>> <tr>
          >>>> <td>Other Company</td>
          >>>> <td>Tom Thomas<br/>
          >>>> Dan Daniels<br/></td>
          >>>> </tr>
          >>>> </table>
          >>>>
          >>>> Effectively writing unique company names once and then putting only the
          >>>> employees from that company into the employee table cell.
          >>>
          >>> If you scrolled down this far then you've been rewarded :-)
          >>>
          >>> The trick is to use lookup keys to test the selected group of elements
          >>> against, in order to pick only the first ocurrence in each group; then
          >>> output the group header at that point; and only then go and process all
          >>> the
          >>> elements in the group to extract the detail from each of them.
          >>>
          >>> The syntax is tricky because it's very compact. It selects all
          >>> registration
          >>> elements, but subjects each of them to the test that [the number of
          >>> nodes in
          >>> the union of (the current node and the first node with the current
          >>> company
          >>> value returned by the lookup) is equal to 1] -- in effect meaning they
          >>> are
          >>> one and the same node, ie the first in their company name grouping.
          >>> You'll
          >>> probably need to read that 3 or 4 times -- it took me a week to grok it.
          >>>
          >>> <?xml version="1.0" encoding="iso-8859-1"?>
          >>> <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
          >>> version="1.0">
          >>>
          >>> <xsl:output method="html"/>
          >>>
          >>> <xsl:key name="entry" match="registra tion" use="company"/>
          >>>
          >>> <xsl:template match="/">
          >>> <html>
          >>> <head>
          >>> <title>Registra tions</title>
          >>> </head>
          >>> <body>
          >>> <xsl:apply-templates/>
          >>> </body>
          >>> </html>
          >>> </xsl:template>
          >>>
          >>> <xsl:template match="registra tions">
          >>> <table>
          >>> <xsl:for-each select="registr ation[count(.|key('en try',company
          >>> [1])=1]">
          >>> <xsl:sort select="company "/>
          >>> <tr>
          >>> <th valign="top">
          >>> <xsl:value-of select="company "/>
          >>> </th>
          >>> <td valign="top">
          >>> <xsl:for-each select="key('en try',current()/company)">
          >>> <xsl:sort select="last"/>
          >>> <xsl:value-of select="first"/>
          >>> <xsl:text> </xsl:text>
          >>> <xsl:value-of select="last"/>
          >>> <xsl:if test="position( )!=last()">
          >>> <br/>
          >>> </xsl:if>
          >>> </xsl:for-each>
          >>> </td>
          >>> </tr>
          >>> </xsl:for-each>
          >>> </table>
          >>> </xsl:template>
          >>>
          >>> </xsl:stylesheet>
          >>>
          >>> ///Peter
          >>>[/color]
          >>
          >>
          >>[/color][/color]

          Comment

          Working...