Ecrion Software Inc. Homepage
Forum Home Forum Home > XF Rendering Server > XSL-FO
  New Posts New Posts RSS Feed: Embedded scripts
  FAQ FAQ  Forum Search   Register Register  Login Login

Embedded scripts

 Post Reply Post Reply
Author
Message / View First Unread Post
falik View Drop Down
Newbie
Newbie


Joined: 13 Oct 2011
Posts: 10
Post Options Post Options   Quote falik Quote  Post ReplyReply Direct Link To This Post Topic: Embedded scripts
    Posted: 19 Oct 2011 at 10:22am

Hi !


I have to call an external function in my xslt/xsl-fo stylesheet. I know that I can use <xsl:script> according to the recommendation (http://www.w3.org/TR/xslt11/#define-extension-functions) The question is how to actually use it ? I'm using formatter to transform my stylesheets and I have to add an external function written in a different language than xslt, preferably C++ or C#. Is that possible ? I mean I don't really understand the way that it works. Actually will it work just fine if I use a java code inside the <script> tags ? I don't understand how the code is interpreted or compiled. Can anyone lighten it up a but for me ? In the specification it's stated that my processor must support the language of the script. I'm supposed to use the integrated one. What languages are supported by him ? I looked through the internet and found some microsoft references(http://msdn.microsoft.com/en-us/library/533texsx(vs.71).aspx) but the problem is that I don't want to process the xml outside the formatter and If I understood that microsoft article clearly they tell me to write a program in C# that will do the transformation outside. It's not my goal 'cause I need something to be done in one step just using my formatter.


thanks in advance for any tips.

Back to Top
radup View Drop Down
Admin Group
Admin Group
Avatar
Adminstrator

Joined: 19 May 2008
Posts: 90
Post Options Post Options   Quote radup Quote  Post ReplyReply Direct Link To This Post Posted: 21 Oct 2011 at 10:57am
You can define your own script in XF Designer using the following dialog http://www.ecrion.com/Temp/HelpCache/XFDesigner/framed_hidd_managescriptsdlg.htm
The languages supported are JavaScript, C# and VB. Note that C# it will work only with .Net parser. The code is compiled and executed at XSLT transfromation.
Here an example:
1. In the home tab ( or in the review tab - depending what XF Designer version are you using), click Manage Scripts and paste the following: 
function formatPhoneNumber(text)
{
     return text.substring(1, 4) + " " + text.substring(5, 2) + " " + text.substring(7);
}

When you want to use this function, go to Insert Tab and click Field. 
The Edit Expression dialog will come up, and you can type something like this: 

js:formatPhoneNumber(string(/root/phone))

Where /root/phone is the path to your data. 
Note:
-  the xsl "string" function which will force the parser to evaluate the xpath when is passed to the javascript function.
-  formatPhoneNumber is now displayed under Functions in the Edit Expression dialog. 


Edited by radup - 21 Oct 2011 at 10:59am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz

This page was generated in 0.105 seconds.