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 October 9th, 2003, 01:20 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vetrikam
Default XSL calls java function - prob

hi ,

i am trying to call a java function from my xsl, this throws me an error, plz help me out
here is the code, and the error

iam using xml spy 5

error:(from xsl)
   This file is not valid:
    Function not in namespaceError in XPath expression,Function not in name space.

Xsl: (source)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:look="C:/j2sdk1.4.0/jre/bin/Test" extension-element-prefixes="look">
<lxslt:component prefix="look" elements="timelapse" functions="flash"> <lxslt:script lang="javaclass"/> </lxslt:component>

    <xsl:variable name="ret">
      <xsl:call-template name="contract">
      <xsl:with-param name="nadu" select="country"/>
      </xsl:call-template>
    </xsl:variable>



    <xsl:template name="contract">
    <xsl:param name="nadu"/>

      <xsl:value-of select=" look:flash() "/>


Java code:

public class Test
{

    public static String flash()
    {
        return "Baba";
    }
}


plz give me a brief answer as i am new to xslt

thanx in advance.



 
Old October 9th, 2003, 10:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Hi,

I've noted several points which I would like to mention here:

1) First of all, the internal XSLT processor of XML Spy 5 is not Xalan, whereas the code you used is intended for Xalan. Therefore, try to run the transformation using Xalan 2.5, for instance.

2) Try to replace the respective code-snippet with this one(you'll find what parts I mean). Note the namespace declaration for "lxslt": your declaration was wrong.

Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:lxslt="http://xml.apache.org/xalan"
                xmlns:look="Test"
                extension-element-prefixes="look">

  <lxslt:component prefix="look"
                   elements="timelapse" functions="flash">
    <xalan:script lang="javaclass" src="xalan://Test"/>
  </lxslt:component>
3) It will be safer to surround extension function calls by xsl:if like this:
Code:
<xsl:if test="function-available('look:flash')">
   <xsl:value-of select="look:flash()"/>
</xsl:if>
4) And finally put the class Test on the classpath

I hope these will be sufficient to perform the transformation successfully.
If not, let me know, and we'll discuss untill the final solution.

Regards,
Armen
 
Old October 9th, 2003, 10:33 PM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vetrikam
Default

Thanx armmarthi, for ur reply,

i will try it and get back to u






Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Java function in XSL jilly XML 1 July 6th, 2007 07:50 AM
Calling Java function from XSL jilly J2EE 0 July 6th, 2007 12:52 AM
XSL and href calls ... asearle XSLT 2 September 21st, 2006 11:02 AM
calling java function from xsl pandian XSLT 1 December 21st, 2005 12:59 PM
function calls ricmar Access VBA 3 September 24th, 2004 09:15 AM





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