xsl-list
[Top] [All Lists]

Newbie: HTML output ordering problem.

2003-08-18 11:28:41
Hello all.

I've run into a problem with the ordering of my output. I've tried looking for 
an answer, but I 
can't find one in the archives or via Google, so I'm turning to you for help. 
If this is a 
FAQ/RTM question, please let me know where the FAQ list/Manual are as I can't 
seem to 
find them.

The project is to take an article for an ezine and transform it into HTML (and 
PDF 
eventually). I've got the XML for the articles created, and I'm working with 
the XSL file 
now. The problem I have is that when I run the XSL file as it is below through 
Xalan-J, I get 
an output file that has a list of headers followed by a list of paragraphs. 
What I'm looking to 
get is an intermingled list of headers and paragraphs.

Thanks for your help!

ARTICLE.XML
<?xml version="1.0" ?>
<article>
        <title>This would hold the title of the article.</title>
        <summary>This is a one sentance summary of the article.</summary>
        <author email="someone(_at_)someplace(_dot_)com" 
homepage="http://somewhere.com/author";>John Doe</author>
        <aboutAuthor>Biographical information goes in here.</aboutAuthor>
        <section>Introduction</section>
        <para sectionTitle="Introduction">put some text here.  put some text 
here.  put 
some text here.  put some text here.  </para>
        <para>
                <link destination="Slashdot.org" name="slashdot" />
                <link destination="http://www.cnn.com"; name="CNN" />
                <link destination="http://www.mozilla.org/"; name="Mozilla" />
        </para>
        <section>Installation</section>
        <para> put some text here.  put some text here.  put some text here.  
put some 
text here.  </para>
        <para>abcdefghijklmnopqrstuvwxyz.  abcdefghijklmnopqrstuvwxyz.  
abcdefghijklmnopqrstuvwxyz.  abcdefghijklmnopqrstuvwxyz.  </para>
        <section>Using the program</section>
        <para>put some text here.  put some text here.  put some text here.  
put some text 
here.  </para>
        <para><warning>Do Not feed the Lions!</warning>  <emphasis>put some 
text 
here.</emphasis>  put some <emphasis>text</emphasis> here.  put some text here. 
 
</para>
        <para>abcdefghijklmnopqrstuvwxyz.  <link 
destination="http://slashdot.org"; 
name="slashdot" /> abcdefghijklmnopqrstuvwxyz.  abcdefghijklmnopqrstuvwxyz.  
abcdefghijklmnopqrstuvwxyz.  </para>
        <para>  <keyboardInput>ftp ftp.mozilla.org</keyboardInput></para>
        <para>in the <objectName>System Setup</objectName> folder, select the 
<objectName>Mouse</objectName> object and go to the Comet Cursor page. Make 
sure 
the <dialogOption>Comet Cursor On</dialogOption> option has a checkmark in the 
box. 
Now you have to restart your computer, you can do this by pressing the 
<keys>Control-Alt-Delete</keys> combination.</para>
        <section>Summary</section>
        <para>put some text here.  put some text here.  put some text here.  
put some text 
here.  </para>
</article>

TRANSFORM.XSL
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 
Transitional//EN"/>

<xsl:template match="/">
        <html>
        <head><title>VOICE Newsletter - Date <xsl:value-of 
select="article/title" 
/></title></head>
        <body>
        <div id="header">
                <h1><xsl:value-of select="article/title" /></h1>
                <p class="authorname">by <a><xsl:attribute 
name="href">mailto:DESPAM-<xsl:value-of select="article/author/@email" 
/></xsl:attribute><xsl:value-of select="article/author" /></a></p><!--need to 
insert 
HREF="" into <A> tag for mailto to function.-->
                <p><xsl:value-of select="article/summary" /></p></div>
        <div id="mainContent">
        <xsl:apply-templates select="article/section" />
        <xsl:apply-templates select="article/para"/>

                <div id="references">
                <h2>References and Links</h2>
                <ul>
                        <xsl:apply-templates select="article/para/link"/>
                </ul>
                </div><!--end references-->

        </div><!--end main content-->
                <div id="authorInfo"><p><strong><xsl:value-of 
select="article/author"/>'s</strong>&#160;&#160;<xsl:value-of 
select="article/aboutAuthor"/></p></div>
        </body>
        </html>
</xsl:template>

<!-- ====================== -->
<xsl:template name="section">
<h2>
<xsl:value-of select="." />
</h2>
</xsl:template>

<!-- ====================== -->
<xsl:template match="article/para">
        <p><xsl:value-of select="."/></p><!--templates for links, images, 
emphasis, 
etc. launched from this template?-->
</xsl:template>

<!-- ====================== -->
<xsl:template match="article/para/link">
<li><a><xsl:attribute name="href"><xsl:value-of 
select="./@destination"/></xsl:attribute><xsl:value-of 
select="./@name"/></a></li>
</xsl:template>

</xsl:transform>
Matt Bear
email:
mfbear(_at_)earthlink(_dot_)net
WWW:
http://home.earthlink.net/~mfbear/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>