Solved

xslt interacting with other languages

Posted on 2009-07-02
2
190 Views
Last Modified: 2013-11-18
Hello experts!
just a little intro question!

our company is using online software. obviously i dont have an access to any program code.
all i can script how i want is a XSLT code for pdf invoices templates.

the question is can i use some how parts of another script language within xslt.
like PHP or SQL to connect to DB.

i was thinking if i can use some external data at XSLT script (like images) may be it is possible to use something else?

below is part of code where i use external gaphic



<fo:table-cell padding="0pt 0pt 0pt 15pt" border="0" number-rows-spanned="8" vertical-align="top">

<fo:block><!-- list LOGO--><!-- list LOGO--><!-- list LOGO--><!-- list LOGO-->

		<xsl:choose>

		<xsl:when test="@currency='GBP'">

		<fo:external-graphic content-width="136pt" src="url(http://www.mysite/images/logo.gif)"/>

											</xsl:when>

.

.

.

.

.

etc

Open in new window

0
Comment
Question by:nzrubin
  • 2
2 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 250 total points
ID: 24779921
Hey, you can build extensions to XSLT, inside XSLT
I have an example here of using javascript inside XSLT, using microsoft xml

Each processor has its own extension features
microsft has javascript (and C# in .net)
xalan and saxon have java

so, we need to know which processor you are using
you can find that using:
        <xsl:value-of select="system-property('xsl:vendor')"/>

this would work server based, you can't inlude extension code in browser xslt,
since the extension language and approach is XSLT processor dependent, and you can't control the browser xslt processor

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24779923
forgot the example
<?xml version='1.0'?>

<xsl:stylesheet version="1.0" 

	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 

	xmlns:msxsl="urn:schemas-microsoft-com:xslt"

	xmlns:myjs="urn:internal:my-javascript">

	<msxsl:script language="JavaScript" implements-prefix="myjs">

	<![CDATA[

		function GetCurrentDateTime()

		{

		var currentTime = new Date();

		var month = currentTime.getMonth() + 1;

		var day = currentTime.getDate();

		var year = currentTime.getFullYear();

		return(month + "/" + day + "/" + year);

		}

	]]>

	</msxsl:script>
 

<xsl:template match="/">

	<xsl:value-of select="myjs:GetCurrentDateTime()"/>

</xsl:template>
 

</xsl:stylesheet>

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now