Link to home
Start Free TrialLog in
Avatar of dokks
dokks

asked on

XLST display nodes greater than 19 but less than 25

I am trying to display and sort only the top 5 members that are levels 20 - 25 by their "lastwkrp" totals...

Here is a sample of the XML (note I cannot modify the XML)


<guild_status>
 <guild name="Ravens Myst" realm="Hibernia" activechars="72" activemembers="47" guildrp="3253" guildlastrp="3248" contacturl="" websiteurl="http://www.ravensmyst.server.us" timestamp="2003-02-19 03:14:53" "http://www.camelotherald.com/shields/6-2-2-full.png" semblem="http://www.camelotherald.com/realms/insignia/h_emblem_004.gif" alliance="0" keepowned="" realultimatepower="0">

<character name="Corell Kinslayer" id="465400" laston="Recently">
  <race>Lurikeen</race>
  <class>Ranger</class>
  <level>50</level>
  <guildrank>0</guildrank>
  <totalrp>16720</totalrp>
  <lastweekrp>1748</lastweekrp>
  <totaldeaths>151</totaldeaths>
  <lastweekdeaths>8</lastweekdeaths>
  <anon>False</anon>
  <weaponcraft>1</weaponcraft>
  <armorcraft>1</armorcraft>
  <tailoring>1</tailoring>
  <fletching>150</fletching>
 </character>

<character name="Milany Roxx" id="474246" laston="Recently">
  <race>Celt</race>
  <class>Bard</class>
  <level>47</level>
  <guildrank>1</guildrank>
  <totalrp>23994</totalrp>
  <lastweekrp>2590</lastweekrp>
  <totaldeaths>58</totaldeaths>
  <lastweekdeaths>2</lastweekdeaths>
  <anon>False</anon>
  <spellcraft>1</spellcraft>
  <alchemy>562</alchemy>
 </character>

Here is the XSLT I am using:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />

<xsl:template match="/">
<html>
<head>
<style type="text/css">
#table {margin: 5px 5px 5px 5px;}
td.top {font: 900 12px arial;color: #000000}
td.low {font: 600 12px arial;color: #cccccc;}
tr {border: 1px solid #cccccc}
</style>
</head>
<body>
<center>
<div id="table">
<table cellpadding="4" cellspacing="0" border="0" width="96%">
      <tr bgcolor="#cccccc">
     <td class="top">Name</td>
     <td class="top">Level</td>
     <td class="top">Realm Points </td>
     <td class="top">Last Weeks RP</td>
     <td class="top">Last Weeks Deaths</td>
     </tr>
      <xsl:for-each select="guild_status/guild/character">
      <xsl:sort select="lastweekrp" data-type="number" order="descending"/>

                    <xsl:if test="level &lt;25' and position()&lt;6">
     <tr>
           <td class="low"><xsl:value-of select="@name" /></td>
           <td class="low"><xsl:value-of select="level" /></td>
           <td class="low"><xsl:value-of select="totalrp" /></td>
           <td class="low"><xsl:value-of select="lastweekrp" /></td>
           <td class="low"><xsl:value-of select="lastweekdeaths" /></td>
     </tr>
           </xsl:if>
        </xsl:for-each>
    </table>
  </div>
</center>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

and here is the error:

msxml3.dll error '80004005'

A string literal was not closed. level <25-->' and position()<6<--

/GP2Content/XmlXslTransform.asp, line 33
Avatar of sparkplug
sparkplug

Hi,

This line has an extra single quote:

<xsl:if test="level &lt;25' and position()&lt;6">

should be:

<xsl:if test="level &lt;25' and position()&lt;6">

However to get the top 5 members that are levels 20 - 25, you should change the code as follows:

<xsl:for-each select="guild_status/guild/character[level &gt; 19 and level &lt; 26]">
     <xsl:sort select="lastweekrp" data-type="number" order="descending"/>
     <xsl:if test="position()&lt;6">
     <tr>
          <td class="low"><xsl:value-of select="@name" /></td>
          <td class="low"><xsl:value-of select="level" /></td>
          <td class="low"><xsl:value-of select="totalrp" /></td>
          <td class="low"><xsl:value-of select="lastweekrp" /></td>
          <td class="low"><xsl:value-of select="lastweekdeaths" /></td>
     </tr>
     </xsl:if>
</xsl:for-each>

In this case the top 5 are selected from the ones with the correct levels instead of selecting the correct levels from the top 5 overall.

Hope this helps,

>S'Plug<
ASKER CERTIFIED SOLUTION
Avatar of sparkplug
sparkplug

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dokks

ASKER

Wow fast response. I thought you had it there, but now I am getting this error:

msxml3.dll error '80004005'

The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

/GP2Content/XmlXslTransform.asp, line 33

Any ideas?
Avatar of dokks

ASKER

Wow fast response. I thought you had it there, but now I am getting this error:

msxml3.dll error '80004005'

The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

/GP2Content/XmlXslTransform.asp, line 33

Any ideas?
doks, can you show us your ASP. There seems to be an error parsing the XSL. Are you checking the parseError property of the XML Dom object? This will give us more information. e.g.

sXSLFile = Server.MapPath(sXSLFile)
If Not oXSLDom.Load(sXSLFile) Then
   Set oErr = oXSLDom.parseError
   sErrMsg = "XML Parsing Error. File: " & oErr.url & "  Reason : " & oErr.reason & " Line: " & oErr.line & ", Character: " & oErr.linepos & ", Text: " & oErr.srcText
   Err.Raise 999, sErrMsg
End If

>S'Plug<
Avatar of dokks

ASKER

Unfortunately I cannot. This site is a hosted server that specializes in online gaming. I can tell you that this code works perfectly fine with this command:

<xsl:for-each select="guild_status/guild/character">
      <xsl:sort select="lastweekrp" data-type="number" order="descending"/>
              <xsl:if test="position()&lt;6">

However that simply lists the highest "lastweekrp" regardless of any other attributes...
Avatar of dokks

ASKER

Nevermind... operator error. This was the fix! Of course it won't work if I forget to add </body> hehe