473,394 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

XSLT adding your own functions

Is this normal use of XSLT? At the top of our XSL file we have:

<xsl:stylesheet ...
xmlns:nl="http://www.jclark.com/xt/java/com.company.package.ProcessXML">
....

Then within the XSL itself we call:

<xsl:value-of select="nl:generate-url('x', 'y', 'z')" />

Where generate-url is actually defined in ProcessXML.java:

public static String generateUrl (String x, String y, String z) {
...
}

This works just fine when I'm performing the XSL transformation within
my own Java app that has access to the ProcessXML class. However, it
completely ruins my ability to use an XSL editor or do any type of
external transformation which aborts with an exception about not being
able to find the generate-url function.

So my question, since I didn't write this code :), is this standard
procedure for extending XSL to do what you want? If so, is there
something that I'm missing which would enable a standalone XSL
transformation engine (such as might be found in an IDE) to recognize
the functions I added? Is there a way that I could write some sort of
stub/dummy plugin for generateUrl that would do nothing, but at least
keep the transform from failing?

This approach has served us fine in a world where the Java guys also
did all the XSL coding and so always worked within the scope of a Java
app, but we're getting to a point where we'll have dedicated content
people and I'd like them to be able to use an XSL editor of their
choice. Right now the only option is "Edit XSL, check in to source
control, request a rebuild (since they cannot build the product on
their workstations), look at results, repeat."

Thanks!
Jul 20 '05 #1
3 2705
Ok, with a little extra reading let me followup my own question with
some more intelligent ones. Now that I discovered that this trick
is called an "extension function" it was much easier to find info :).

* Is the way we're doing it specific to JClark's parser, such that
switching over to another one might still break me even if I was doing
everything else right?

* Where exactly do I *put* my extension functions so that the XSLT
parser can find them? That's the part I can't seem to locate.
Obviously they are not at www.jclark.com. They're not at any
http resolvable location, actually - but I dont think they have
to be. When the class in question exists in the same jar as the
app doing a transform, then it works fine.

Hope those are better questions :). Thanks!

Duane

In article <55**************************@posting.google.com >,
Duane Morin <dm****@morinfamily.com> wrote:
Is this normal use of XSLT? At the top of our XSL file we have:

<xsl:stylesheet ...
xmlns:nl="http://www.jclark.com/xt/java/com.company.package.ProcessXML">
...

Then within the XSL itself we call:

<xsl:value-of select="nl:generate-url('x', 'y', 'z')" />

Where generate-url is actually defined in ProcessXML.java:

public static String generateUrl (String x, String y, String z) {
...
}

This works just fine when I'm performing the XSL transformation within
my own Java app that has access to the ProcessXML class. However, it
completely ruins my ability to use an XSL editor or do any type of
external transformation which aborts with an exception about not being
able to find the generate-url function.

So my question, since I didn't write this code :), is this standard
procedure for extending XSL to do what you want? If so, is there
something that I'm missing which would enable a standalone XSL
transformation engine (such as might be found in an IDE) to recognize
the functions I added? Is there a way that I could write some sort of
stub/dummy plugin for generateUrl that would do nothing, but at least
keep the transform from failing?

This approach has served us fine in a world where the Java guys also
did all the XSL coding and so always worked within the scope of a Java
app, but we're getting to a point where we'll have dedicated content
people and I'd like them to be able to use an XSL editor of their
choice. Right now the only option is "Edit XSL, check in to source
control, request a rebuild (since they cannot build the product on
their workstations), look at results, repeat."

Thanks!

Jul 20 '05 #2
In article <yv8Ub.177920$nt4.776706@attbi_s51>,
Duane Morin <dm****@morinfamily.com> wrote:

% * Is the way we're doing it specific to JClark's parser, such that
% switching over to another one might still break me even if I was doing
% everything else right?

It seems like it. As a rule, if you need to use extension functions,
I suggest using the ones from http://exslt.org where applicable,
since they're the most widely supported. What gets supported and how
to add new extensions is completely dependent on the xslt processor
you're using, though.

You can use the function-available() to test for the availability of
an extension function

<xsl:choose>
<xsl:when test='function-available("nl:generate-url")'>
<xsl:value-of select="nl:generate-url('x', 'y', 'z')" />
</xsl:when>
<xsl:otherwise>
** url made up of x, y, and z **
</xsl:otherwise>
</xsl:choose>

--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #3
pt**@interlog.com (Patrick TJ McPhee) wrote in message news:<bv**********@news.eusc.inter.net>...
You can use the function-available() to test for the availability of
an extension function


Awesome - that's exactly what I needed! Thanks!!

Duane
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
7
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet...
6
by: Prashanth Ellina | last post by:
Hi, I am an XSLT newbie. I need to solve something which I will express in pseudo-code. function f1() { xmltree = <emptydom> addnamevaluepair(xmltree, "size","100")...
1
by: Peran | last post by:
If I create a simple xslt stylesheet I can quickly test this in VS2005 by pressing the "Show XSLT Output" button rather than running the whole solution. If I then create a xslt stylesheet with...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
3
by: shaun roe | last post by:
mild rant follows Working now for a couple of years with xslt and now xslt 2.0, does anyone else get the impression that xslt 2.0 somehow missed the point? Yes its got a fancy new data model...
12
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
11
by: Ebenezer | last post by:
Let's suppose I have some nodes in an XML file, with an URL attribute: <node url="mypage.php?name1=value1&foo=bar&foo2=bar2&name2=value0" /> <node...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.