XML / XSLT transformation question...

webmasterbeta

New Member
here's the situation...

what i would like to do is, output (to XHTML) every word between the <emphasis> tags (from the XML file), with surrounding <strong></strong> tags, and appear in the same order as they are found in the XML file.

any help with this would be much appreciated.

thanks!




XML file:
<?xml version="1.0" encoding="UTF-8"?>

<section id="locating">
<title>Locating Images</title>

<para>This section describes how to locate images saved your computer's hard drive.</para>

<task>
<title>Locating images on your hard drive</title>

<procedure>

<step>
<para>If your <emphasis>Folder Browser</emphasis> is already open, move to Step 3.</para>
</step>

<step>
<para>If your <emphasis>Folder Browser</emphasis> is not open, from the <emphasis>File</emphasis> menu, click <emphasis>Show Folder Browser</emphasis>.</para>
</step>

<step>
<para>From the <emphasis>Folder Browser</emphasis> menu, navigate to the folder where your images are located.</para>
</step>

</procedure>
</task>
</section>


XSLT file:
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:template match="/">


<xsl:for-each select="section">

<h1><xsl:value-of select="title"/></h1>

<xsl:for-each select="para">
<p><xsl:value-of select="node()"/></p>
</xsl:for-each>

<xsl:for-each select="task">

<h2><xsl:value-of select="title"/></h2>

<ol>
<xsl:for-each select="procedure/step">
<li><xsl:value-of select="node()"/></li>
</xsl:for-each>
</ol>
</xsl:for-each>

</xsl:for-each>


</xsl:template>
</xsl:stylesheet>


a part of the resulting XHTML file (tags are just for show)
<h1>Locating Images</h1>
<p>This section describes how to locate images saved your computer's hard drive.</p>
<h2>Locating images on your hard drive</h2>
<ol>
<li>If your Folder Browser is already open, move to Step 3.</li>
<li>If your Folder Browser is not open, from the File menu, click Show Folder Browser.</li>
<li>From the Folder Browser menu, navigate to the folder where your images are located.</li>
</ol>


my desired result:
<h1>Locating Images</h1>
<p>This section describes how to locate images saved your computer's hard drive.</p>
<h2>Locating images on your hard drive</h2>
<ol>
<li>If your <strong>Folder Browser</strong> is already open, move to Step 3.</li>
<li>If your <strong>Folder Browser</strong> is not open, from the <strong>File</strong> menu, click <strong>Show Folder Browser</strong>.</li>
<li>From the <strong>Folder Browser</strong> menu, navigate to the folder where your images are located.</li>
</ol>

some more imfo... i use an ASP script to transform the XML with the XSLT into XHTML. my CSS style sheet is linked to the ASP/XHTML page.
 
Back
Top