Jump to content


Photo

Embedding Scripts In Xslt


  • Please log in to reply
3 replies to this topic

#1 falik

falik

    Newbie

  • Members
  • Pip
  • 10 posts

Posted 19 October 2011 - 03:15 PM

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...nsion-functions) The question is how to actually use it ? I'm using AHFormatter 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 something like that. 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. In AHFormatter the msxml is integrated and I'm not supposed to use any other. What languages are supported by him ? I looked through the internet and found some microsoft references(http://msdn.microsof...xsx(vs.71).aspx) but the problem is that I don't want to process the xml outside AHFormatter 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.

#2 Martin Honnen

Martin Honnen

    Member

  • Members
  • PipPip
  • 324 posts

Posted 19 October 2011 - 03:27 PM

Well the document you cite is a working draft that was abandoned in 2001 so don't expect your favourite XSLT processor in 2011 to support features outlined there. The current version of XSLT is XSLT 2.0, instead of allowing you to write functions in scripting languages it allows you to write functions in XSLT itself. XSLT 2.0 processors are Saxon 9, AltovaXML, XQSharp and Intel and IBM also offer one as part of their application server products like WebSphere.
As for MSXML, it supports a proprietary ms: script extension element that allows you to implement functions in JScript or VBScript so if your tool uses MSXML you might be able to use that approach. http://msdn.microsof...y/ms256042.aspx has an example with sample code using JScript that should work with MSXML (as long as you ignore other parts of the documents like an assembly element that are specific to .NET).

#3 falik

falik

    Newbie

  • Members
  • Pip
  • 10 posts

Posted 19 October 2011 - 03:36 PM

So you say that if I'd like to stay with my old MSXML I can only write some scripts in javascript or in visualbasicscript am I right ?

#4 Martin Honnen

Martin Honnen

    Member

  • Members
  • PipPip
  • 324 posts

Posted 19 October 2011 - 04:03 PM

Yes, the official names are JScript and VBScript, as documented on http://msdn.microsof...c(v=VS.85).aspx, that is what is available with MSXML and its proprietary ms: script element. If you want to pass in nodes to script or pass back nodes from script to XSLT you need to make yourself familiar with the MSXML object model http://msdn.microsof...(v=VS.85).aspx. And if you want to use script with MSXML 6 you need to be aware that MSXML 6 by default has tighter security settings than earlier versions http://msdn.microsof...1(v=VS.85).aspx, so script in XSLT is disabled by default.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users