Al said:
I wrote a C tutorial that I covert to XML.
...
<content>
Lots of Text......
<code_block>Some Example Code</code_block>
More Text...
</content>
...
... The problem is the
<xsl:value-of select="."/> ( . is the <content> node) includes the
<code_block> values in the <content> value.
Yep, that's your problem, all right.
Is there a better way to set up my XML file or is it my XSL?
Your XML is fine. (Some people will tell you that you should
avoid mixed content; when your schema is for documents, as
opposed to database records, these people are, ah, wrong.)
If I were you, I'd change
<xsl:template match="content">
<xsl:element name="div">
<xsl:value-of select="." />
<xsl:apply-templates select="code_block"/>
</xsl:element>
</xsl:template>
to
<xsl:template match="content">
<xsl:element name="div">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
Since the default for apply-templates is to select the
child nodes of the current node, you'll get the initial
text node, followed by the code block, followed by
the final text node. One rule for processing mixed content
is to let your data drive the stylesheet and not try to
control everything using manual selects.
I hope this helps.
-C. M. Sperberg-McQueen
World Wide Web Consortium