[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

passing vars xsl

Posted on 2009-04-23
3
Medium Priority
?
294 Views
Last Modified: 2013-11-18
hi guys
could you help please, i cannot find the answer...

im making a FO invoice template for some crm web-site (so i cannot really control whats inside)
and i almost completed doing that.. however i cannot pass some variable to a template::

so i want to pass @currency to <xsl:apply-templates select="LineItems/LineItem"/>
<xsl:stylesheet version="1.0" extension-element-prefixes="saxon" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ITypeFormat="java:salesorder.util.ITypeFormat" xmlns:saxon="http://icl.com/saxon">
	<xsl:param name="OBJECT"/>
	<xsl:variable name="DT" select="saxon:node-set($OBJECT)"/>
	  
	  <xsl:template match="/*">
          <!-- i can see @currency here if i display it like that -->
          <fo:block><xsl:value-of select="@currency"/></fo:block>
                    
                      <xsl:apply-templates select="LineItems/LineItem"/>             
 
         </xsl:template>
 
<!-- below is template that i want to display the variable @currency that can be displayed in above template-->
 
<xsl:template match="LineItems/LineItem"  xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
         <fo:block><xsl:value-of select="@currency"/></fo:block>
 
</xsl:template>

Open in new window

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

Expert Comment

by:Geert Bormans
ID: 24222168
Here is how you can pass a parameter, if that really is what you need
<xsl:stylesheet version="1.0" extension-element-prefixes="saxon" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ITypeFormat="java:salesorder.util.ITypeFormat" xmlns:saxon="http://icl.com/saxon">
	<xsl:param name="OBJECT"/>
	<xsl:variable name="DT" select="saxon:node-set($OBJECT)"/>
	  
	  <xsl:template match="/*">
          <!-- i can see @currency here if i display it like that -->
          <fo:block><xsl:value-of select="@currency"/></fo:block>
                    
                      <xsl:apply-templates select="LineItems/LineItem"/>             
 
         </xsl:template>
 
<!-- below is template that i want to display the variable @currency that can be displayed in above template-->
 
<xsl:template match="LineItems/LineItem"  xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
         <fo:block><xsl:value-of select="@currency"/></fo:block>
 
</xsl:template>

Open in new window

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 24222187
But you could easily look higher up the tree

the xpath expression /* sends you back to the root element
using /@currency, you get the currency attribute of that element

There are many axes in XPath, so you could go looking for data in all sorts of directions,
the only reason why you want to pass this as a parameter, is when you thing that looking-up-the-tree is going to be very expensive


    <xsl:template match="LineItems/LineItem"  xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <xsl:param name="currency"></xsl:param>
        
        <fo:block><xsl:value-of select="/*/@currency"/></fo:block>
        
    </xsl:template>

Open in new window

0
 
LVL 4

Author Closing Comment

by:nzrubin
ID: 31574740

this is work just fine! of course! /*/@currency"
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
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)
Suggested Courses

834 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