XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Tinga BakumbaSubject: XML Stylesheet help
Author: Tinga Bakumba
Date: 25 May 2006 08:44 PM
Hi,

beginner here. Need some help!

Im trying to create a stylesheet to show a 'mailbox' xml file (a xml file with a series of email messages) with a table accomodating each email address. below is what i have but its not working:

the xml file:

<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="email.xsl" ?>
<mailbox>
<email>
<from><name>Les Carr</name> <address>lac@ecs.soton.ac.uk</address></from>
<to><name>Hugh Davis</name> <address>hcd@multicosm.com</address></to>
<subject>Teaching Duties</subject>
<content>
Using Java to teach Programming Principles seems to have worked very
well. The standard of software engineering seems to have increased.
</content>
</email>

<email>
<from><name>Wendy Hall</name> <address>wh@ecs.soton.ac.uk</address></from>
<to><name>Les Carr</name> <address>lac@ecs.soton.ac.uk</address></to>
<subject>XML Course</subject>
<content>
Please make sure that you use the new IAM logo on all our
course material.
</content>
</email>

<email>
<from><name>Les Carr</name> <address>lac@ecs.soton.ac.uk</address></from>
<to><name>Wendy Hall</name> <address>wh@ecs.soton.ac.uk</address></to>
<subject>Re: XML Course</subject>
<content>
Have you looked at the content?
</content>
</email>

</mailbox>

the .xsl file

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" >

<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="/">
<H1>Email Listing</H1>
<xsl:for-each select="mailbox/email">
<table>
<xsl:apply-templates/>
</table>
</xsl:for-each>
</xsl:template>


<xsl:template match="//from">
<tr><td>From:</td><td><xsl:value-of select="name"/> (<xsl:value-of select="address"/>)</td></tr>
</xsl:template>

<xsl:template match="//to">
<tr><td>To:</td><td><xsl:value-of select="name"/> (<xsl:value-of select="address"/>)</td></tr>
</xsl:template>

<xsl:template match="//subject">
<tr><td>Subject:</td><td><xsl:value-of select="."/> </td></tr>
</xsl:template>

<xsl:template match="//content">
<tr><td colspan="2"><xsl:value-of select="."/></td></tr>
</xsl:template>

</xsl:stylesheet>

Can someone kindly let me know where im being stupid?

Thanks a lot

Postnext
Ivan PedruzziSubject: XML Stylesheet help
Author: Ivan Pedruzzi
Date: 25 May 2006 09:13 PM

Hi Tinga,

What you have posted is not XSLT but rather its ancient predecessor a proprietary language invented by Microsoft before XSLT became the standard.

Please see the attached file as example of migration.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


Documentmails.xsl

Postnext
Tinga BakumbaSubject: XML Stylesheet help
Author: Tinga Bakumba
Date: 25 May 2006 09:40 PM
thanks a lot for the reply.

When I try to run it with your example, it tells me:

Required attribute 'version' is missing.

Postnext
Ivan PedruzziSubject: XML Stylesheet help
Author: Ivan Pedruzzi
Date: 25 May 2006 09:45 PM

Yep I forgot the attribute version

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">



Ivan Pedruzzi
Stylus Studio Team

Postnext
Tinga BakumbaSubject: XML Stylesheet help
Author: Tinga Bakumba
Date: 25 May 2006 09:53 PM
hi,

I got something, but not sure if its the right layout.

From: Les Carr(lac@ecs.soton.ac.uk)
To: Hugh Davis(hcd@multicosm.com)
Subject: Teaching Duties
Using Java to teach Programming Principles seems to have worked very well. The standard of software engineering seems to have increased.
From: Wendy Hall(wh@ecs.soton.ac.uk)
To: Les Carr(lac@ecs.soton.ac.uk)
Subject: XML Course
Please make sure that you use the new IAM logo on all our course material.
From: Les Carr(lac@ecs.soton.ac.uk)
To: Wendy Hall(wh@ecs.soton.ac.uk)
Subject: Re: XML Course
Have you looked at the content?

The top email element has the values for its children elements (from, to and subject) far away and it gets closer as u go down to the last 'email' element. As you can see above

Do you know why it does that?

Thanks

Postnext
Tinga BakumbaSubject: XML Stylesheet help
Author: Tinga Bakumba
Date: 25 May 2006 09:55 PM
>hi,
>
>I got something, but not sure
>if its the right layout.
>
>From: Les
>Carr(lac@ecs.soton.ac.uk)
>To: Hugh
>Davis(hcd@multicosm.com)
>Subject: Teaching
>Duties
>Using Java to teach
>Programming Principles seems
>to have worked very well. The
>standard of software
>engineering seems to have
>increased.
>From: Wendy
>Hall(wh@ecs.soton.ac.uk)
>To: Les
>Carr(lac@ecs.soton.ac.uk)
>Subject: XML Course
>Please make sure that you use
>the new IAM logo on all our
>course material.
>From: Les
>Carr(lac@ecs.soton.ac.uk)
>To: Wendy
>Hall(wh@ecs.soton.ac.uk)
>Subject: Re: XML Course
>Have you looked at the
>content?
>
>The top email element has the
>values for its children
>elements (from, to and
>subject) far away and it gets
>closer as u go down to the
>last 'email' element. As you
>can see above
>
>Do you know why it does that?
>
>Thanks

The formatting didnt seem to show on the post.
Basically the top 'From, To, and Subject have their entries farthest away and it gets close as you go down to the last 'email' element. Hope it makes sense.

Postnext
Ivan PedruzziSubject: XML Stylesheet help
Author: Ivan Pedruzzi
Date: 25 May 2006 10:08 PM
Hi Tinga,

Your original code was creating a separate table for each email,
you may want to change the main template to create a single table like the following

<xsl:template match="/">
<H1>Email Listing</H1>
<table border="1">
<xsl:for-each select="mailbox/email">
<xsl:apply-templates/>
</xsl:for-each>
</table>
</xsl:template>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
Tinga BakumbaSubject: XML Stylesheet help
Author: Tinga Bakumba
Date: 25 May 2006 10:25 PM
Hi Ivan,

Thats what I'm trying to; create a seperate table for each email.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.