mindlessLemming
12-13-2004, 12:35 AM
Me again :)
Ok, first, here's an abridged version of my XML:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="text2.xsl" alternate="no" ?>
<texts>
<text id="t001">
<name>The Tortoise and the Hare</name>
<content>The <n>Hare</n> <v>ran</v> past the <adj>lazy</adj> <n>Tortoise</n>.</content>
</text>
</texts>
What I'm trying to do, is output the <content> element as a paragraph and each of the <n>,<v> and <adj> elements as spans within the <p>.
Here's my XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="texts">
<html>
<head>
<title>Text Test</title>
</head>
<body>
<xsl:for-each select="text">
<div class="text" id="{@id}">
<h2><xsl:value-of select="name"/></h2>
<xsl:apply-templates select="content"/>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="content">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="n">
<span class="noun"><xsl:value-of select="n"/></span>
</xsl:template>
<xsl:template match="v">
<span class="verb"><xsl:value-of select="v"/></span>
</xsl:template>
<xsl:template match="adj">
<span class="adj"><xsl:value-of select="adj"/></span>
</xsl:template>
</xsl:stylesheet>
Unfortunately, it doesn't output any of the tags nested within <content>.
Any help would be greatly appreciated (of course! :))
Ok, first, here's an abridged version of my XML:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="text2.xsl" alternate="no" ?>
<texts>
<text id="t001">
<name>The Tortoise and the Hare</name>
<content>The <n>Hare</n> <v>ran</v> past the <adj>lazy</adj> <n>Tortoise</n>.</content>
</text>
</texts>
What I'm trying to do, is output the <content> element as a paragraph and each of the <n>,<v> and <adj> elements as spans within the <p>.
Here's my XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="texts">
<html>
<head>
<title>Text Test</title>
</head>
<body>
<xsl:for-each select="text">
<div class="text" id="{@id}">
<h2><xsl:value-of select="name"/></h2>
<xsl:apply-templates select="content"/>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="content">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="n">
<span class="noun"><xsl:value-of select="n"/></span>
</xsl:template>
<xsl:template match="v">
<span class="verb"><xsl:value-of select="v"/></span>
</xsl:template>
<xsl:template match="adj">
<span class="adj"><xsl:value-of select="adj"/></span>
</xsl:template>
</xsl:stylesheet>
Unfortunately, it doesn't output any of the tags nested within <content>.
Any help would be greatly appreciated (of course! :))