?
Solved

XLST display nodes greater than 19 but less than 25

Posted on 2003-02-19
7
Medium Priority
?
265 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:dokks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:sparkplug
ID: 7981001
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<
0
 
LVL 9

Accepted Solution

by:
sparkplug earned 300 total points
ID: 7981009
:-) left the single quote in myself:

{...

should be:

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

...)

>S'Plug<
0
 

Author Comment

by:dokks
ID: 7981628
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?
0
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 

Author Comment

by:dokks
ID: 7981720
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?
0
 
LVL 9

Expert Comment

by:sparkplug
ID: 7981772
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<
0
 

Author Comment

by:dokks
ID: 7982368
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...
0
 

Author Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question