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 October 1st, 2008, 09:57 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default xsl clarification...

Hi,

XML:


<richtext xmlns:sgx="http://www.lotus.com/dxl">
  <pardef id="2" leftmargin="1in" rightmargin="100%" keeptogether="true" />
  <par def="2">Name of director : Chan Siew Key Steven</par>
  <par def="2" />
  <par def="2">Date of notice to company : 23 September 1997</par>
  <par def="2" />
  <par def="2">Date of change of shareholding : 21 August 1997</par>
  <par def="2" />
  <par def="2">Name of registered holder : Chan Siew Key Steven</par>
  <par def="2" />
  <par def="2">Circumstance given rise to the change : Share option granted.</par>
  <par def="2" />
  <par def="2">No. of options of the change : 40,000</par>

</richtext>


xsl one :

<xsl:for-each select="par[@def='2']>
<xsl:value-of select="."></xsl:value-of>
<br />
</xsl:for-each>

xsl two:

<xsl:for-each select="par[@def='2']">
<xsl:value-of select="par[@def='2']"></xsl:value-of>
<br />
</xsl:for-each>

whats the difference between these two xsl's..
why xsl two doesnt give any out put ..i mean same like xsl one.


Thanks in advance..
Raj

 
Old October 2nd, 2008, 01:56 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need to look up context node in a good XSLT reference. Inside the xsl:for-each you are already positioned on the par element so to access it you use the XPath '.' as in your first example. Your second version looks for par elements that are children of the already selected par element.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap5 collections clarification taternuggets BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 March 26th, 2008 12:22 PM
STL's clarification sspr C++ Programming 1 February 23rd, 2006 04:43 AM
Clarification require on use - xsl:for-each-group ROCXY XSLT 1 January 2nd, 2006 05:33 AM
clarification in xslt rameshnarayan XSLT 0 August 23rd, 2005 02:28 AM
Clarification on Namespace sathya.n XML 1 March 2nd, 2005 10:24 AM





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