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 December 20th, 2012, 06:03 AM
Authorized User
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default Remote functions!

Hello (again).

Is this even possible? I would like to create an <xsl:function> and store its definition and implementation on a remote server so I do not need to include the code in the template but still be able to use within my XSLT when I have my debug flag set.

So my template would look like this:
Code:
<xsl:template ...>
    ...
    <xsl:if test="$debug">
        <xsl:value-of select="myNS:Dump($Buffer)"/>
    </xsl:if>
</xsl:template>
With the actual code being called from the server.

--
William
 
Old December 20th, 2012, 06:54 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't know of an implementation that provides this feature, but there's nothing in the language to preclude it.
__________________
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:
WilliamYou (December 20th, 2012)
 
Old December 20th, 2012, 07:01 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

The only current solution I can think of is providing a stylesheet module on the server and then importing or including it e.g. you put the module on the server or have a page generating it so that it is accessible via HTTP and then in the code you use

Code:
<xsl:import href="http://example.com/modules/funfoo.xsl"/>
See http://www.w3.org/TR/xslt#section-Combining-Stylesheets. Of course you then will need to make sure the code returns is a stylesheet with the function code and not a single function.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
WilliamYou (December 20th, 2012)
 
Old December 20th, 2012, 07:04 AM
Authorized User
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Thank you both.

I was looking in to Michael's reply and ended up with Martin's answer. So I'm very happy with that, maybe I should have given it a bit more thought before posting!

--
William
 
Old December 20th, 2012, 07:28 AM
Authorized User
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

As noted earlier this does work but when the function is not available (simulated by excluding the xsl:include) then I can't compile the stylesheet.

I have tried use-when
Code:
<xsl:if test="$debug">
            <xsl:value-of select="myNS:Dump($Buffer)" use-when="not(function-available('myNS:Dump'))"/>
        </xsl:if>
and
Code:
<xsl:if test="$debug" use-when="not(function-available('myNS:Dump'))">
            <xsl:value-of select="myNS:Dump($Buffer)"/>
        </xsl:if>
to no avail, is there anything I can do here? As I have to take into consideration the fact that the system where this is used may be working offline, so I would appreciate your thoughts.

--
William





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the remote screen from a remote computer in vb.does it related to winsock helloworld BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 July 8th, 2011 06:45 AM
C functions...??? ethantinder C# 2 April 25th, 2008 02:25 AM
Functions czambran BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 13 July 11th, 2006 06:33 PM
Functions Meg Intro Programming 1 January 23rd, 2006 01:03 PM
Help with Functions megabytes C# 1 August 7th, 2003 12:48 PM





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