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 February 9th, 2005, 12:43 PM
Authorized User
 
Join Date: Mar 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Namespace does not contain any functions

Hello,

I am trying to implement a simple example from Michael Kay's XSLT 2.0 3rd edition book in a xslt I have. It's the comment example from page 240, where the comment should output file generation properties.

I call a template similar to the following from the book:
Code:
    <xsl:template name="file-properties">
        <xsl:comment>
            <xsl:text> Generated on: </xsl:text>
            <xsl:value-of select="format-dateTime(
                    current-dateTime(), '[D]  [MNn]  [Y]  at  [H]:[m01]:[s01]')" />
            <xsl:text> using </xsl:text>
            <xsl:value-of select="system-property('xsl:product-name')" />
            <xsl:text> version </xsl:text>
            <xsl:value-of select="system-property('xsl:product-version')" />
        </xsl:comment>
    </xsl:template>
At first I get errors stating the date functions are not valid XSLT or XPATH functions. I have the following namespaces declared at the top:
Code:
<xsl:stylesheet version="2.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:fn="http://www.w3.org/2004/07/xpath-functions" 
        xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes">
Next I try to prepend the functions with either xs: or fn: (I've tried both) and get a complaint that "Namespace whichever does not contain any functions.

Any suggestions on how to implement this? I don't know if its an error from the book example, or something I am doing wrong.

Thanks in advance for your help,
Dan
 
Old February 9th, 2005, 01:09 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The problem is that the namespace for the standard function library keeps changing with each new draft, so you need to check what it is for the particular Saxon version you are using.

However, there's an easier solution: don't use a prefix for standard functions like format-dateTime and current-dateTime. Whatever the namespace is, it's the default.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 9th, 2005, 01:12 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I should have checked: you are using an XSLT 2.0 processor, I assume?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 9th, 2005, 03:14 PM
Authorized User
 
Join Date: Mar 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael. I am using the MSXML 4.0 processor. OK, so after checking msdn (I am in a MS development tools shop) I see that MSXML 4.0 and later are only XSLT 1.0, so perhaps that is the root of my problem here.

That issue aside, and referring to your first reply, to use the default function library, should I then remove the fn namespace (or others) from my declarations?

Thanks again, guess I'll look into XSLT processor alternatives that I can use here at work.

Dan

 
Old February 9th, 2005, 03:42 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you're using a 1.0 processor (as you are) then you not only need to remove the prefix from these functions, you need to rewrite your stylesheet so it doesn't need these functions. The 2.0 function library is vastly richer than the 1.0 library.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 22nd, 2009, 06:21 AM
Registered User
 
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to change my xslt processor?

I need to use the xslt version 2.0 but the posts suggest that I need to have an xslt processor of 2.0 to be able to use the functionalities of version 2.0

how can I upgrade my xslt processor then?!
 
Old June 22nd, 2009, 06:29 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I know of four XSLT and XPath 2.0 implementations, there is Saxon 9 from http://saxon.sourceforge.net/, there is AltovaXML tools from http://www.altova.com/, there is Gestalt from http://gestalt.sourceforge.net/ and I think IBM has a beta release of its own implementation.
You can't really "upgrade" your XSLT processor unless you consider replacing a Java Trax/JAXP XSLT 1.0 processor like Xalan or like Saxon 6 with Saxon 9 an upgrade.
So choose an XSLT 2.0 processor for your platform and use that.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Namespace help CamosunStudent BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 6th, 2006 04:12 PM
Namespace CamosunStudent ASP.NET 2.0 Basics 0 October 4th, 2006 06:57 PM
namespace Ibn_Aziz C# 2 December 25th, 2003 05:41 AM
Namespace flute Pro VB.NET 2002/2003 2 October 21st, 2003 09:15 AM
Namespace Help vavre ADO.NET 0 August 24th, 2003 11:39 AM





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