Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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 September 30th, 2006, 08:01 AM
Authorized User
 
Join Date: May 2006
Location: Plovdiv, , Bulgaria.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to boen_robot
Default Backwards compatable XSLT 2.0

Hello. I don't yet have an XSLT 2.0 processor (I don't have ASP.NET nor JSP for Saxon and I don't know any PHP XSLT 2.0 processors) but I'm currently making and using XSLT 1.0 stylesheets. When support for XSLT 2.0 arrives in a language at my disposal (PHP or Cold Fusion) I would like to use it's functionality.

For this reason, I would like to know about how XPath 2.0 functions are used.
  • Can XPath 2.0 functions be used in XSLT 1.0 stylesheets?
  • Do XSLT 2.0 stylesheets need to declare a namespace for the XPath 2.0 functions?
  • Looking at the specification for XPath functions and operators I noticed the XPath 1.0 functions are also present. If a namespace is required in XSLT 2.0 stylesheets, wouldn't that cause incompatibility with XSLT 1.0 processors?
Any additional notes on XPath 2.0 related to XSLT 1.0 are also welcomed.

------
<xsl:for-each select="problem"><xsl:value-of select="solution"></xsl:for-each>
__________________
------
&lt;xsl:for-each select=\"problem\"&gt;&lt;xsl:value-of select=\"solution\"&gt;&lt;/xsl:for-each&gt;
 
Old October 1st, 2006, 02:54 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
Default

Quote:
quote:Originally posted by boen_robot
 For this reason, I would like to know about how XPath 2.0 functions are used.
  • Can XPath 2.0 functions be used in XSLT 1.0 stylesheets? No
  • Do XSLT 2.0 stylesheets need to declare a namespace for the XPath 2.0 functions? No
  • Looking at the specification for XPath functions and operators I noticed the XPath 1.0 functions are also present. If a namespace is required in XSLT 2.0 stylesheets, wouldn't that cause incompatibility with XSLT 1.0 processors? See above
Basically what happens depends on the version declared in the xsl:stylesheet element. If you declare version 2.0 in a version 2.0 enabled processor then you have access to the newer functions and elements such as xsl:sequence. It will also treat such things as xsl:value-of differently. If you specify version 1.0 in the same processor then you will get the same as a version 1.0 processor except in a few cases.
For a detailed explanation of these things, and how version 1.0 processors behave on encountering a version 2.0 stylesheet, you can do no better than Michael Kay's two Wrox books on the subject XPath 2.0 Programmer's Reference and XSLT 2.0 Programmer's Reference.


--

Joe (Microsoft MVP - XML)
 
Old October 1st, 2006, 05:22 AM
Authorized User
 
Join Date: May 2006
Location: Plovdiv, , Bulgaria.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to boen_robot
Default

So XPath 2.0 is never going to be available in XSLT 1.0 processors and XSLT 2.0 processors won't need a namespace for the new functions. Great. So I know what to do. Thanks.

------
<xsl:for-each select="problem"><xsl:value-of select="solution"></xsl:for-each>
 
Old October 4th, 2006, 02:34 PM
Authorized User
 
Join Date: May 2006
Location: Plovdiv, , Bulgaria.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to boen_robot
Default

Actually, I have one more question. How are the operator (prefixed with "op" in the specs) and the schema (prefixed with "xs") functions be used? Like the core functions? Or with some sort of symbolic equivalents? With namespace? Any samples would be greatly appreciated. I realize they will be completely incompatable with XSLT 1.0 though.

Ok. It's not exactly one question, but in it's core, it's one:D.

------
<xsl:for-each select="problem"><xsl:value-of select="solution"></xsl:for-each>
 
Old October 4th, 2006, 03:36 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The op: functions are not directly exposed to the user, they are a formal device for specifying the behaviour of operators such as "=", "+", "<<", "is" and so on.

The xs: functions perform casting between different schema data types, for example xs:date("2006-10-04") converts a string to a date. These functions are written with an explicit namespace prefix (you can use any prefix bound to the schema namespace).

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference




Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
Domain name validation - backwards?? rptasiuk Pro PHP 7 July 20th, 2004 04:52 AM
Chapter 6 Array's "Going backwards" mjennings VB.NET 2002/2003 Basics 2 November 19th, 2003 02:18 PM
Timer stops counting backwards at 00:01 larry Wrox Book Feedback 1 October 28th, 2003 10:42 AM





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