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
Thread Tools Display Modes
  #1 (permalink)  
Old November 1st, 2004, 09:35 AM
Authorized User
Join Date: Nov 2004
Location: , , Turkey.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default ZVON Tutorial Page 56 id() function

I was studying XSLT from ZVON.org tutorials. In page 56
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.
Reply With Quote
  #2 (permalink)  
Old November 1st, 2004, 11:37 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

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...
<xsl:apply-templates select="//doc"/>
should be
<xsl:apply-templates select="/doc"/>
and this
<xsl:for-each select="//ref">
should be
<xsl:for-each select="/ref">


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

Thread Tools
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
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 10:53 AM
ID column used to redirect page rdove84 ASP.NET 1.0 and 1.1 Basics 11 November 14th, 2006 04:10 PM
Passing a variable into the id() function EstherMStrom XSLT 5 January 19th, 2005 01:32 PM
id() Function pallone XSLT 4 December 7th, 2004 12:27 PM

All times are GMT -4. The time now is 01:30 PM.

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