V
Variable
I have a webpage where I'm opening an XML page with MSXML, pushing it
through an XSL file to generate some HTML which is incorporated into
the body of the main HTML page. I have other pages where this all
works great. One page, however, seems to bypass the a for-each
iteration, and I can't understand why. I've used XMLSpy to validate
the XML and XSL, and as far as I can see, the simulated generation
through XMLSpy is correct.
Here is a sample of my XML, XSL.
---------------------------------------------------------
<?xml version="1.0" standalone="no" ?>
<WCP>
<action type="get_stats">
<swbf stattype="summary">
<hostname>1.2.3.4</hostname>
<port>12345</port>
<gamename>Blah</gamename>
<mapname map="map1">Unknown</mapname>
<maxplayers>25</maxplayers>
<players numplayers="2">
<member kills="1" deaths="2">Bob</member>
<member kills="1" deaths="2">Tim</member>
</players>
<status>0</status>
<detailsURL>
<![CDATA[ <a
href="swbf_details.asp?host=1.2.3.4&port=12345">Details</a>
]]>
</detailsURL>
</swbf>
</action>
</WCP>
---------------------------------------------------------
---------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl
utput method="html" />
<xsl:template match="/WCP/action/swbf">
<xsl:if test="@stattype='summary'">
<xsl:value-of select="hostname" />:<xsl:value-of select="port"
/><br />
<xsl:choose>
<xsl:when test="players/@numplayers = 0">
No players currently in the game
</xsl:when>
<xsl
therwise>
<xsl:for-each select="players/member">
<xsl:value-of select="text()" /> -
<xsl:value-of select="@team" /> -
<xsl:value-of select="@kills" /> -
<xsl:value-of select="@deaths" /><br />
</xsl:for-each>
</xsl
therwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------
When the above XML is pushed through the XSL stylesheet with MSXML,
only the host name will show up. But when run through XMLSpy, the
hostname and all the players show up.
Any ideas? Thanks!
through an XSL file to generate some HTML which is incorporated into
the body of the main HTML page. I have other pages where this all
works great. One page, however, seems to bypass the a for-each
iteration, and I can't understand why. I've used XMLSpy to validate
the XML and XSL, and as far as I can see, the simulated generation
through XMLSpy is correct.
Here is a sample of my XML, XSL.
---------------------------------------------------------
<?xml version="1.0" standalone="no" ?>
<WCP>
<action type="get_stats">
<swbf stattype="summary">
<hostname>1.2.3.4</hostname>
<port>12345</port>
<gamename>Blah</gamename>
<mapname map="map1">Unknown</mapname>
<maxplayers>25</maxplayers>
<players numplayers="2">
<member kills="1" deaths="2">Bob</member>
<member kills="1" deaths="2">Tim</member>
</players>
<status>0</status>
<detailsURL>
<![CDATA[ <a
href="swbf_details.asp?host=1.2.3.4&port=12345">Details</a>
]]>
</detailsURL>
</swbf>
</action>
</WCP>
---------------------------------------------------------
---------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl
<xsl:template match="/WCP/action/swbf">
<xsl:if test="@stattype='summary'">
<xsl:value-of select="hostname" />:<xsl:value-of select="port"
/><br />
<xsl:choose>
<xsl:when test="players/@numplayers = 0">
No players currently in the game
</xsl:when>
<xsl
<xsl:for-each select="players/member">
<xsl:value-of select="text()" /> -
<xsl:value-of select="@team" /> -
<xsl:value-of select="@kills" /> -
<xsl:value-of select="@deaths" /><br />
</xsl:for-each>
</xsl
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------
When the above XML is pushed through the XSL stylesheet with MSXML,
only the host name will show up. But when run through XMLSpy, the
hostname and all the players show up.
Any ideas? Thanks!