-
1
- #1
I have the following XML File:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../XSLT/forum.xsl"?>
<webboard>
<forums>
<forum id="1">
<reference name="category" id="1"/>
<name>XML</name>
<desc/>
</forum>
<forum id="2">
<reference name="category" id="2"/>
<name>Windows 9x/NT/Me/2k</name>
<desc/>
</forum>
</forums>
<categories>
<category id="1">
<name>Internet Programming</name>
<desc/>
</category>
<category id="2">
<name>Operating Systems</name>
<desc/>
</category>
</categories>
<users>
<user id="1">
<alias>Admin</alias>
<email>Admin@gibble.yi.org</email>
</user>
<user id="2">
<alias>Gibble</alias>
<email>Gibble@gibble.yi.org</email>
</user>
</users>
<threads>
<thread id="1">
<reference name="forum" id="1"/>
<reference name="user" id="2"/>
<name>What is XML?</name>
<date>11/24/2000</date>
<file>T000001.xml</file>
</thread>
<thread id="2">
<reference name="forum" id="1"/>
<reference name="user" id="2"/>
<name>What is XSL?</name>
<date>11/24/2000</date>
<file>T000002.xml</file>
</thread>
<thread id="3">
<reference name="forum" id="2"/>
<reference name="user" id="1"/>
<name>What is the difference b/w Win 9x and Win Me</name>
<date>11/24/2000</date>
<file>T000003.xml</file>
</thread>
</threads>
</webboard>
And I need to transform it with the following XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="webboard">
<xsl:apply-templates select="categories"/>
</xsl:template>
<xsl:template match="categories">
<xsl:apply-templates select="category"/>
</xsl:template>
<xsl:template match="category">
<div class="CategoryName">
<xsl:for-each select="//forums/forum/reference/@id">
<xsl:value-of select="."/>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match="forums">
<xsl:apply-templates select="forum"/>
</xsl:template>
<xsl:template match="forum">
<div class="ForumName"><xsl:value-of select="name"/></div>
</xsl:template>
</xsl:stylesheet>
The problem is in the XSL here:
<xsl:template match="category">
<div class="CategoryName">
<xsl:for-each select="//forums/forum/reference/@id">
<xsl:value-of select="."/>
</xsl:for-each>
</div>
</xsl:template>
I need the for-each to select all of the forums that have the id referencing the category and I can't figure out how to select that I NEED help!!
TIA
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../XSLT/forum.xsl"?>
<webboard>
<forums>
<forum id="1">
<reference name="category" id="1"/>
<name>XML</name>
<desc/>
</forum>
<forum id="2">
<reference name="category" id="2"/>
<name>Windows 9x/NT/Me/2k</name>
<desc/>
</forum>
</forums>
<categories>
<category id="1">
<name>Internet Programming</name>
<desc/>
</category>
<category id="2">
<name>Operating Systems</name>
<desc/>
</category>
</categories>
<users>
<user id="1">
<alias>Admin</alias>
<email>Admin@gibble.yi.org</email>
</user>
<user id="2">
<alias>Gibble</alias>
<email>Gibble@gibble.yi.org</email>
</user>
</users>
<threads>
<thread id="1">
<reference name="forum" id="1"/>
<reference name="user" id="2"/>
<name>What is XML?</name>
<date>11/24/2000</date>
<file>T000001.xml</file>
</thread>
<thread id="2">
<reference name="forum" id="1"/>
<reference name="user" id="2"/>
<name>What is XSL?</name>
<date>11/24/2000</date>
<file>T000002.xml</file>
</thread>
<thread id="3">
<reference name="forum" id="2"/>
<reference name="user" id="1"/>
<name>What is the difference b/w Win 9x and Win Me</name>
<date>11/24/2000</date>
<file>T000003.xml</file>
</thread>
</threads>
</webboard>
And I need to transform it with the following XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="webboard">
<xsl:apply-templates select="categories"/>
</xsl:template>
<xsl:template match="categories">
<xsl:apply-templates select="category"/>
</xsl:template>
<xsl:template match="category">
<div class="CategoryName">
<xsl:for-each select="//forums/forum/reference/@id">
<xsl:value-of select="."/>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match="forums">
<xsl:apply-templates select="forum"/>
</xsl:template>
<xsl:template match="forum">
<div class="ForumName"><xsl:value-of select="name"/></div>
</xsl:template>
</xsl:stylesheet>
The problem is in the XSL here:
<xsl:template match="category">
<div class="CategoryName">
<xsl:for-each select="//forums/forum/reference/@id">
<xsl:value-of select="."/>
</xsl:for-each>
</div>
</xsl:template>
I need the for-each to select all of the forums that have the id referencing the category and I can't figure out how to select that I NEED help!!
TIA