Solved

xslt interacting with other languages

Posted on 2009-07-02
2
191 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

777 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