Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2004, 02:41 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default xslt problem: values not displayed in table

Hi all, I am a total newbie to xml/xslt :(, so I guess my question is easy to answer, but I didn't find anything on the net to make this work, so I'm hoping for an answer here.

I am creating an xslt to view an existing xml in html. Here's an example of what I am basically trying to do (I know it's not a very good example, but I can't post the original one)

Xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="C:\source\Richtlinien\test.xsl"?>
<nda:books xmlns:nda="http://www.nda.de">
<book>
<author name="King" firstname="Stephen">
<title name="the shining" language="english"/>
<title name="Carrie" language="german"/>
</author>
</book>
<book>
<author name="Rowlings" firstname="JK">
<title name="Socerer Stone" language="english"/>
<title name="Prisoner of Azkaban" language="english"/>
</author>
</book>
</nda:books>
and here's the xslt I am trying to create:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:nda="http://www.nda.de">
<xsl:template match="/">
<html>
<body>
<table border="1">
<tr>
<th>name</th>
<th>firstname</th>
<th>title</th>
</tr>
<xsl:for-each select="nda:books/book/author">
<tr>
<td>
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:value-of select="@firstname"/>
</td>
<td>
<table border="1">
<tr>
<th>name</th>
<th>language</th>
</tr>
<xsl:for-each select="nda:books/book/author/title">
<tr>
<td>
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:value-of select="@language"/>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
So I am trying to create a table which contains the values of the xml. Now, the values of the outer table are displayed fine, but not the values of the inner table. How can I make this work? I am thankful for any help!!

Thx a lot!

 
Old December 1st, 2004, 04:08 AM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to xxdneu
Default

The inner select expression is not correct,
you should write it like this

<xsl:for-each select="./title">

the dot symbol represents the context node.
:D

 
Old December 1st, 2004, 05:05 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi xxdneu,

thanx a lot for your answer, it works!!:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Formating the data Table values in XSLT vimalpatel2u XSLT 5 October 5th, 2007 04:41 AM
Problem with the numbar of rows displayed per page akjoshi Reporting Services 0 July 4th, 2007 06:38 AM
XSLT table problem tulip2006 XSLT 0 December 28th, 2006 05:27 PM
generating a table w. xslt, newbie problem themuffinman_swe XSLT 5 November 26th, 2005 01:05 PM
Listbox Selected values to be displayed on Submit dom1975 C# 0 September 17th, 2005 04:29 AM





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