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]
Other format: [Raw text]

Sorry No Text : Grouping and Sorting Problem


My XML Sheet looks like this:
<File>
<Script>
  <TestScript Name="Script1">
    <ScriptMessages>
      <SM ET="0" Grp="1">Script1 Error #1</SM>
      <SM ET="0" Grp="0">Script1 Error #0</SM>
      <SM ET="0" Grp="1">Script1 Error #1</SM>
      <SM ET="0" Grp="2">Script1 Error #2</SM>
      <SM ET="0" Grp="0">Script1 Error #0</SM>
      <SM ET="0" Grp="1">Script1 Error #1</SM>
      <SM ET="0" Grp="1">Script1 Error #1</SM>
      <SM ET="0" Grp="0">Script1 Error #0</SM>
      <SM ET="0" Grp="1">Script1 Error #1</SM>
      <SM ET="0" Grp="1">Script1 Error #1</SM>
    </ScriptMessages>
  </TestScript>
  <TestScript Name="Script2">
    <ScriptMessages>
      <SM ET="0" Grp="1">Script2 Error #1</SM>
      <SM ET="0" Grp="0">Script2 Error #0</SM>
      <SM ET="0" Grp="1">Script2 Error #1</SM>
      <SM ET="0" Grp="2">Script2 Error #2</SM>
      <SM ET="0" Grp="0">Script2 Error #0</SM>
      <SM ET="0" Grp="2">Script2 Error #2</SM>
      <SM ET="0" Grp="1">Script2 Error #1</SM>
    </ScriptMessages>
  </TestScript>
 </Script>
</File>

My XSL Looks like this:

<xsl:key name="GroupDesc" match="SM" use="@Grp"/>

<xsl:for-each select="//Scripts//TestScript">
<xsl:variable name="NumScripts" select="position()"/>
<xsl:variable name="NumScriptMessages"
select="count(ScriptMessages/SM)"/> 
<xsl:value-of select="@Name"/> - <xsl:value-of
select="$NumScriptMessages"/> messages
  <br></br>

  <xsl:for-each
select="/File/Scripts/TestScript[$NumScripts]/ScriptMessages/SM[generate-id(.)=
         generate-id(key('GroupDesc', @Grp)[1])]">
    <xsl:sort select="@Grp"/>
    <xsl:variable name="MessageNum"
select="position()"/>
    <xsl:for-each select="key('GroupDesc', @Grp)">
      <xsl:value-of
select="format-number(number(@ET),'###,###,###,###')"/>
      <xsl:value-of select="current()"/>
      <br></br>
    </xsl:for-each>
  </xsl:for-each>
<br></br>
</xsl:for-each>

I left some parts of my XSL sheet off here like the
processing instructions, etc.
I want my results to be grouped my Scripts, then by
the Grp attribute, but I keep getting
All the messages under the first script.

Please Advise.
Thanks in advance

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

 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]