Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2010, 09:31 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not able to refer variable values in xsl stylesheet

Hi All,

We are trying to refer and parse few variables values in the xsl-fo stylesheet.

When we view the XML output, the variables are getting the value, but in the final rtf report, we are not getting the variables printed in the report.

We are using the below tag for referencing the variables and their values:

<!-- User Variables: Vishal modified for templates -->
<xsl:template match="var[@type='U']">
<!-- This provides the default value for the user defined variable. Change according to the requirement.-->
<xsl:variable name="defaultTemplateUserValue">[@ <xsl:value-of select="current()/@meaning"/> @]</xsl:variable>
<xsl:variable name="defaultUserValue">_________</xsl:variable>
<!--xsl:variable name="defaultUserValue"><xsl:value-of select="$ContractsRoot/ParametersVO/ParametersVORow/DefaultUserVarValue/text()"/></xsl:variable-->
<!-- Fix for bug# 5913694. Changed the ../../ expression to ancestor node -->
<xsl:variable name="currentCatId" select="ancestor::SectionsArticlesToPrintVORow/CatId"/>
<xsl:variable name="uservariable" select="$ContractsRoot/VariablesMetadataVO/VariablesMetadataVORow[VariableType='U' and VariableCode=current()/@name and CatId=$currentCatId]/Value"/>
<xsl:choose>
<xsl:when test="/ContractTermsAM">
<!-- If it is a template, use the variable meaning as the default -->
<xsl:if test="$uservariable">
<xsl:value-of select="$uservariable"/>
</xsl:if>
<xsl:if test="not($uservariable)">
<xsl:value-of select="$defaultTemplateUserValue"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$uservariable">
<xsl:if test="$OkcTermsMode='WML'">
<xsl:call-template name="VariableTag"/>
<xsl:text disable-output-escaping="yes">&lt;Value&gt;</xsl:text>
</xsl:if>
<xsl:value-of select="$uservariable"/>
<xsl:if test="$OkcTermsMode='WML'">
<xsl:text disable-output-escaping="yes">&lt;/Value&gt;</xsl:text>
<xsl:text disable-output-escaping="yes">&lt;/VarStartTag&gt;</xsl:text>
</xsl:if>
<!--xsl:value-of select="$uservariable"/-->
</xsl:if>
<xsl:if test="not($uservariable)">
<xsl:if test="$OkcTermsMode='WML'">
<!--Marking the User variables-->
<xsl:call-template name="VariableTag"/>
<xsl:text disable-output-escaping="yes">&lt;Value&gt;</xsl:text>
</xsl:if>
<xsl:value-of select="$defaultUserValue"/>
<xsl:if test="$OkcTermsMode='WML'">
<xsl:text disable-output-escaping="yes">&lt;/Value&gt;</xsl:text>
<xsl:text disable-output-escaping="yes">&lt;/VarStartTag&gt;</xsl:text>
</xsl:if>
<!--xsl:value-of select="$defaultUserValue"/-->
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Thanks in advance,
Sridevi
 
Old August 16th, 2010, 10:38 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't shown any input XML, and you haven't explained the relationship of the "XML output" to the "final rtf report". And where does XSL-FO fit into the picture?

Your code is highly non-portable because of its extravagant use of disable-output-escaping. This looks, on the surface, to be completely unnecessary. Use of disable-output-escaping without good reason is usually a sign that the stylesheet author has not properly mastered basic XSLT concepts.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old August 16th, 2010, 01:56 PM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, Thanks for the reply.

Yes, Actually, this code was not written by me and I don't have much idea about XSL-FO.

The flow is, we have an rtf which refers to this xsl style sheet for printing information.

The rtf refers to this style sheet using the command <?call-template:TermsTemplate?>

The terms template is defined in the XSL as

<xsl:template name="TermsTemplate">
<xsl:call-template name="PrintContractTerms"/>
</xsl:template>

which inturn refers to another XSL sheet. The code in this particular sheet is very big to paste here.

I can mail u all the files if you can provide me with your mail id.

Thanks and Regards,
Sridevi.
 
Old August 16th, 2010, 02:19 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>The rtf refers to this style sheet using the command <?call-template:TermsTemplate?>


Sorry, I've never come across the idea of an rtf containing a processing instruction that refers to a named template in an XSLT stylesheet. You're using some technology I know nothing about, so I don't think I'll be able to help you.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Store Javascript return values in XSL variable jramesh79 XSLT 4 July 29th, 2009 06:12 AM
refer to subform values stepdev Access VBA 2 December 7th, 2006 12:13 PM
display Xml ( which refer XSL ) By Servlet pandian XSLT 0 December 24th, 2005 06:33 AM
scx to html, using a xsl stylesheet bluetorch XSLT 0 October 18th, 2005 11:38 AM
XSL Stylesheet Problem Ben Horne XSLT 4 March 6th, 2004 05:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.