This is my first post. Sorry if it is a little sloppy. So I am compiling a list from the WFB.xml. It has a lot of information about all the countries of the world. I am trying to get the name of each country and print it in my h2 tag. However, it is printing the first NAME in the list until all the places have been sorted.
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="html" indent="yes"/>
<xsl:variable name="config"
select="document('fb_config.xml')"/>
<xsl:variable name="wfb"
select="document('world_factbook_2008.xml')"/>
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'>
<!DOCTYPE html>

</xsl:text>
<html>
<head>
<title>
<xsl:text>CIA World Factbook</xsl:text>
</title>
</head>
<body>
<xsl:variable name="wfbYear"
select="$wfb/WFB/@YEAR"/>
<h1>
<xsl:value-of select="concat('CIA World ', $wfbYear, ' Factbook')" />
<xsl:text></xsl:text>
</h1>
<xsl:if test="$config/config/order/@output = 'asc'">
<!-- DIV TEST --> <xsl:apply-templates select="$wfb/WFB/PLACE" >
<xsl:sort order="ascending"/>
</xsl:apply-templates>
</xsl:if>
<xsl:if test="$config/config/order/@output = 'dec'">
<!-- DIV TEST --> <xsl:apply-templates select="$wfb/WFB/PLACE" >
<xsl:sort order="descending"/>
</xsl:apply-templates>
</xsl:if>
</body>
</html>
</xsl:template>
<xsl:template match="PLACE">
<div style="border:1px solid black;">
<h2>
<xsl:apply-templates select="$wfb/WFB/PLACE/NAME"/>
</h2>
</div>
</xsl:template>
<xsl:template match="NAME">
<xsl:value-of select="current()"/>
</xsl:template>
</xsl:stylesheet>
Currently this code prints Adelie Land over and over again. This is the first NAME in the xml file.
I think my error is in:
<xsl:template match="PLACE">
<div style="border:1px solid black;">
<h2>
<xsl:apply-templates select="$wfb/WFB/PLACE/NAME"/>
</h2>
</div>
</xsl:template>
If I take out my template matching NAME then this prints out all of the NAMEs in a single line and does this until all PLACEs have been sorted.
Any tips or suggestions?
No comments:
Post a Comment