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 June 16th, 2006, 05:23 AM
Registered User
 
Join Date: Jun 2006
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.

 
Old June 16th, 2006, 05:42 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)
 
Old June 16th, 2006, 06:05 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old June 16th, 2006, 06:11 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
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
 
Old June 16th, 2006, 06:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
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
 
Old June 16th, 2006, 07:12 AM
Registered User
 
Join Date: Jun 2006
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.








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





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