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 27th, 2007, 12:03 PM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default using javascript with xslt

Hi

I want to use javascript in my stylesheet, I have tried it using
xml spy but does not work. Any suggestions or example.

thanks.

 
Old February 27th, 2007, 12:13 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Usual rules: tell us what your input is, tell us what output you want; if you tried something and it didn't work, tell us what you tried and tell us how if failed.

I tried to plaster the ceiling yesterday and it didn't work. Can you tell me what I did wrong?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 27th, 2007, 01:47 PM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:format="format" extension-element-prefixes="format" version="1.0">

     <lxslt:component prefix="format" functions="printDate">
      <lxslt:script lang="javascript">

        function printDate(date) {
            if (custID == "2007-01-01") {
        return "Effective Date";
             } else {
        return "Fee Payment Date";
             }
          }

    </lxslt:script>
     </lxslt:component>

    <xsl:template match="/">
        <xsl:value-of select="format:printDate(Dates/effectiveDate)" />
    </xsl:template>

</xsl:stylesheet>

Error -----
Function not in namespace


Any suggestions, Thanks in advance



 
Old February 27th, 2007, 02:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You might be better off asking this on a Xalan-specific list, as that seems to the the processor you are using.

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
XSLT and JavaScript Variable kwilliams XSLT 5 April 21st, 2008 12:05 PM
JavaScript in XSLT madanshah16 XSLT 8 July 31st, 2007 06:10 PM
javascript 'for' loop in xslt mummra1 XSLT 22 February 6th, 2007 04:26 PM
javascript function in xslt swapnilp1983 XSLT 16 November 7th, 2006 12:39 AM
XSLT + Javascript errors braindog_43 XSLT 0 February 3rd, 2005 09:04 AM





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