Solved

xslt interacting with other languages

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

861 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