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 November 1st, 2004, 10:35 AM
Authorized User
 
Join Date: Nov 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default ZVON Tutorial Page 56 id() function

Hi,
I was studying XSLT from ZVON.org tutorials. In page 56
http://zvon.org/xxl/XSLTutorial/Outp...le68_ch13.html
they show an example of id() function usage, which I'm lost after . I tried it in IE and it really works. In the for-each loop of //ref, apply-templates is supposed to work for sub elements of ref tags (which is none other than text nodes), but somehow it parses note tags. If anyone can explain me how, I'd be relieved. Thanks in advance.

EDIT: I might have an answer to my question:
If you look at the DTD at the top of document, you'll see that id attribute in ref is not defined as ID but IDREF. Therefore id selection in apply-template call does not parse ref tags themselves but looks tags with real id attributes defined as ID in DTD (in this case note tags).
Still one thing I can't understand is that note tags are not children of ref tags or even doc tag. How come apply-templates can call for tags that are supposed to be out of their call range (in this case I assume it is for-each call of ref tags). I still need to be clarified on that. Thanks.
 
Old November 1st, 2004, 12:37 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The id function returns the node with the supplied id. To qualify as an id an attribute can have any name but must be defined as type ID in an accompanying DTD. It doesn't matter where the node is in relation to where the id function was called. It would have been a clearer example if the ref elements had an atrribute called something other than "id", "idref" for example. The XPath expressions are also poor in the example. The times you see paths preceded by // when it is completely unnecessary...
This
Code:
<xsl:apply-templates select="//doc"/>
should be
Code:
<xsl:apply-templates select="/doc"/>
and this
Code:
<xsl:for-each select="//ref">
should be
Code:
<xsl:for-each select="/ref">


--

Joe (Co-author Beginning XML, 3rd edition)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2003 VBA PG 55-56 KellyR Access VBA 3 June 9th, 2007 08:32 AM
help an oldman (56) daviddisman C++ Programming 0 February 16th, 2007 11:53 AM
ID column used to redirect page rdove84 ASP.NET 1.0 and 1.1 Basics 11 November 14th, 2006 05:10 PM
Passing a variable into the id() function EstherMStrom XSLT 5 January 19th, 2005 02:32 PM
id() Function pallone XSLT 4 December 7th, 2004 01:27 PM





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