Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2006, 09:22 AM
Registered User
Join Date: Mar 2006
Location: , , Canada.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Beginner Issues

Hello to all,

I have been trying to learn about the formation of XSLT online, but have come across a wide variety of individual tutorials, comment and opinions as to how to form an XSLT document to translate ax XML to xHTML.

I understand the basics, but when it comes to coding I can not get any results. Below is the a brief breakdown of the XML code (and below is my XSLT code from what info I have gathered on the net):

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="final.xsl"?>
    <name>My Web Page</name>
        <link title="Home">index.html</link>
        <link title="View all our products">products.html</link>
        <link title="About our company">about.html</link>
        <link title="Contact Us">contact.html</link>
        <head1>Welcome to our company site</head1>
        <head2>Shepherd Neame Master Brewers</head2>
            <item>Our traditions can be traced back to the foundation of our brewery in 1698 - with strong links to the town of Faversham and the local community many years before - and our commercial expertise is enhanced by 21st century production and distribution facilities.</item>
        <foot>Thanks to Shepherd Neame Master Brewers for the content for this assignment.</foot>

XSLT code:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"?>
<xsl:output method="html" />
<xsl:template match="/">
<title><xsl:value-of select="head1"/></title>
<div id="container"><xsl:value-of select="myPage"/></div>
    <div id="header"><xsl:value-of select="name"/></div>
        <div id="navBar"><xsl:value-of select="navLinks"/>

             <a href="index.html"><xsl:value-of select="link"/>Home</a><br/>
            <a href="products.html">View all our products</a><br/>
            <a href="about.html">About our company</a><br/>
            <a href="contact.html">Contact Us</a><br/>
        <div id="mainContent"><xsl:value-of select="content"/>
            <h1><xsl:value-of select="head1"/></h1>
            <h2><xsl:value-of select="head1"/></h2>
                <div id="paraGraphs"><xsl:value-of select="data"/>
                <p><xsl:value-of select="item"/></p>

Message continued:
 Am I missing something? Am I way off base? The one section I am unclear about mainly is the creation a link from using the variables used in the XML doc.

Any help would be greatly appreciated.

Thanks, eh?

Reply With Quote
  #2 (permalink)  
Old March 16th, 2006, 10:12 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

This site isn't provided in order to sell books, but it is provided to offer follow-up help to people who buy books. Personally, when learning a new programming language the first thing I always do is to find a good book on the subject and read it cover to cover.

The main concept you seem to have missed is that of context. A path expression such as "title" selects nodes relative to a context node, and it won't select anything unless it's used in the correct context.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old March 21st, 2006, 02:22 PM
Registered User
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts


What Michael is telling you: Your XPATHs are all wrong.

When you did: <xsl:template match="/"> your value-of select="xxx" statements have to use an XPATH relative to "/" where an XPATH is placed in xxx.

For example, when you did:

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


<title><xsl:value-of select="/myPage/content/head1"/></title>

Also, write your XSL in stages, in your XSL, I would comment everything from "<div" to the last "</div>" and check that at-least your title is getting populated.

I appreciate that when given a task with tight time constraints we are not always given the luxury of reading a book from cover to cover. Having referred to Michael's book as a reference, I can tell you that the Holy Bible is less verbose.

For quick answers check-out:

Good luck,


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
xslt beginner question cfflexguy XSLT 4 October 16th, 2007 09:11 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
beginner xslt processor question randallxski XSLT 3 March 24th, 2005 09:41 AM
XSLT Help for a beginner MattQweb XSLT 0 April 12th, 2004 07:20 AM

All times are GMT -4. The time now is 01:28 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.