Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 16th, 2006, 05:23 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default attribute

Hello, I have a problem in showing my attribute value in the node "periode". I want to show the atributes "aankomst" and "vertrek". The result only gives me the value of "naam".


<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="boekingen.xsl"?>
<boekingen>
  <boeking>
    <naam>gast 3</naam>
    <periode aankomst="12-06-2006"/>
    <periode vertrek="15-06-2006"/>
  </boeking>
  <boeking>
    <naam>gast 1</naam>
    <periode aankomst="18-06-2006"/>
    <periode vertrek="23-06-2006"/>
  </boeking>
  <boeking>
    <naam>gast 2</naam>
    <periode aankomst="10-06-2006"/>
    <periode vertrek="12-06-2006"/>
  </boeking>
</boekingen>

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
  <body>
    <h2>Gasten Overzicht</h2>
      <xsl:for-each select="boekingen/boeking">
      <p>
        <xsl:value-of select="naam"/>
        <xsl:value-of select="periode[@aankomst]"/>
        <xsl:value-of select="periode[@vertrek]"/>
      </p>
      </xsl:for-each>
  </body>
</html>
</xsl:template>
</xsl:stylesheet>

This is the result:

Gasten Overzicht

gast 3

gast 1

gast 2

Where are my "aankomst" en "vertrek" values??

Thank you for your help.

Reply With Quote
  #2 (permalink)  
Old June 16th, 2006, 05:42 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

periode[@aankomst] means the periode element that has an aankomst attribute. You need periode/@aankomst and similarly periode/@vertrek.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old June 16th, 2006, 06:05 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.
I couldn't find this info anywhere.

Reply With Quote
  #4 (permalink)  
Old June 16th, 2006, 06:11 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Change <xsl:value-of select="periode[@aankomst]"/>

to <xsl:value-of select="periode/@aankomst"/>

In XPath, read "a[b]" as "select a where b is true". So you are selecting periode if there is an @aankomst, and the value of the periode element is gast 3.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #5 (permalink)  
Old June 16th, 2006, 06:14 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I couldn't find this info anywhere.

as a matter of interest, where did you look?

Most XPath introductions that I know of cover this right at the start, for example

http://www.w3schools.com/xpath/xpath_syntax.asp

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #6 (permalink)  
Old June 16th, 2006, 07:12 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help.

Well I did also look at w3schools, but I grasped the info also as I should use nodename[@attributename];

they also speak about //title[@lang], and not title/@lang.



Reply With Quote
Reply


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
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
all attribute kfir XML 1 May 8th, 2006 09:34 AM
attribute problem muki XSLT 1 November 13th, 2005 12:26 PM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
get attribute value... clayman58 XSLT 1 August 9th, 2005 04:33 AM



All times are GMT -4. The time now is 04:03 PM.


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