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 January 24th, 2012, 09:27 AM
Authorized User
 
Join Date: Nov 2007
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Default Double Slash Needed?

Hi all, very quick and basic question coming up..

I have been using double slash (//) in XPath definitions on occasion for a while now, but realised today that omitting the double slash has the same effect, i.e. all nodes of the specified name are selected just the same.

Is this down to the transformer engine (saxon) being clever?

My understanding of XPath is being shaken to it's core!!

Thanks,
__________________
Neil Belch
Technical Officer
CDL

The views opinions and judgements expressed in this message are solely those of the author. The message contents have not been reviewed or approved by CDL.
 
Old January 24th, 2012, 09:36 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It depends where you are using the "//" and what you are trying to do.

If you are talking about <xsl:template match="//element"> then you do not need the "//" at all, and this is part of the XSLT spec.

If you are finding something works without the "//" then I suspect you have been using it incorrectly - Saxon is a standards based XSLT processor - it doesn't read minds.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
Belch (January 24th, 2012)
 
Old January 24th, 2012, 09:48 AM
Authorized User
 
Join Date: Nov 2007
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Yes, I was using it as part of the xsl:template match attribute.

Thanks for the info!
__________________
Neil Belch
Technical Officer
CDL

The views opinions and judgements expressed in this message are solely those of the author. The message contents have not been reviewed or approved by CDL.
 
Old January 24th, 2012, 10:43 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

match="//title" means almost the same as match="title", but not quite. The first matches any title element in a document (a tree rooted at a document node), while the second matches any title anywhere. Of course, many stylesheets never process elements that aren't part of a document, and in this case both are equivalent, except for two little details: (a) match="title" is faster, because it doesn't have to check what's at the root of the tree, and (b) match="title" has lower default priority, which only matters if you have several template rules that match the same node.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
Belch (January 24th, 2012)
 
Old January 24th, 2012, 02:06 PM
Authorized User
 
Join Date: Nov 2007
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Thanks Michael, good to know the differences - although we don't process elements outside of a stylesheet as you said.
The lower priority is something to consider though, cheers.
__________________
Neil Belch
Technical Officer
CDL

The views opinions and judgements expressed in this message are solely those of the author. The message contents have not been reviewed or approved by CDL.





Similar Threads
Thread Thread Starter Forum Replies Last Post
replace forward slash (/) bonekrusher XSLT 2 March 18th, 2010 12:19 PM
value-of with forward slash in attribute value BassmanNL XSLT 2 February 23rd, 2010 06:37 AM
not able to add forward slash in regex eruditionist Perl 2 May 14th, 2009 10:15 AM
SQL Double Booking System URGENT help needed! chris_smith_51 SQL Language 0 December 11th, 2004 04:27 PM
Slash Sign "\" in Server Name??? omermalik BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 10th, 2003 05:14 PM





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