Fwd: [xsl] XSLT question on xsl:variable and/or xsl:param usage with user inputs

Subject: Fwd: [xsl] XSLT question on xsl:variable and/or xsl:param usage with user inputs
From: Alp <alptkn@xxxxxxxxx>
Date: Fri, 10 Mar 2006 07:40:38 -0500
Hi,

I was able to resolve the variable issue with some tweaking in one of
the .js components of the form. Thanks for the tips anyway.

Alp

---------- Forwarded message ----------
From: Alp <alptkn@xxxxxxxxx>
Date: Mar 9, 2006 5:51 PM
Subject: Re: [xsl] XSLT question on xsl:variable and/or xsl:param
usage with user inputs
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx


Hi David, et al.

Yes, user picks a value on a "Select Value" form as a pop-up window in
a web page.

(You can see the sections of the .xsl file and the associated .xml
file at the bottom.)

Below is what the user is supposed to be doing and what's expected
(pretty straightforward)

1. User picks a building name using the Select Value form. Every
building is assigned an e-mail address back in the database, under
bl.wr_email

2. BAsed on the selected building, the "Send email to:" space
($toEmailAddress) on the main form is auto-populated by the
corresponding e-mail address of the building.

As seen in the .xsl, $toEmailAddress is included in the SelectValue
template to be able to pass a different value everytime the template
is called, and the XPath (called from within
temp_selectvalueform...xml) is
//dataSource/data/records/record[@bl.wr_email]/@bl.wr_email)

What actually happens is even more straightforward: Nothing. The
$toEmailAddress param is not populated at all.

So, if someone could tell me (hopefully) specifically, what I may be
missing, that'd be great...

Thanks a lot..

Alp

...
<xsl:variable name="sBuilding">
<xsl:value-of select="/*/preferences/@em_bl_id"/>
</xsl:variable>
<input class="inputField"
maxlength="{$wr_tgrp/dataSource/data/fields/field[@name='bl_id']/@size}"
type="text" name="wr.bl_id" value="{$sBuilding}"
onchange='validationInputs("{$fmInputsForm}", "wr.bl_id")'
onblur='validationInputs("{$fmInputsForm}", "wr.bl_id")'/>
<xsl:call-template name="SelectValue">
<xsl:with-param name="fmTableGroup" select="$wr_tgrp"/>
<xsl:with-param name="formName" select="$fmInputsForm"/>
<xsl:with-param name="recordName" select="'wr.bl_id'"/>
<xsl:with-param name="toEmailAddress"
select="//dataSource/data/records/record[@bl.wr_email]/@bl.wr_email"/>
<xsl:with-param name="actionTitle" select="'...'"/>
</xsl:call-template>
...

...
<td class="inputFieldLabel" align="left">
<input type="checkbox" checked="checked" disabled="disabled"
name="bSendEmail"/>
<span translatable="true">Send email to:</span>
</td>
<td colspan="3" class="inputFieldLabel">
<input type="hidden" name="toEmailAddress" value="{$toEmailAddress}"/>
<xsl:copy-of select="$toEmailAddress"/>
</td>
...

Here's the template:
<xsl:template name="SelectValue">
<xsl:param name="fmTableGroup"/>
<xsl:param name="formName"/>
<xsl:param name="recordName"/>
<xsl:param name="actionTitle"/>
<xsl:param name="toEmailAddress"/>
<xsl:variable name="fmAction"
select="$fmTableGroup/forFields/field/fmAction[@type='selectValue']"/>
<xsl:if test="count($fmAction) &gt; 0">
<input class="selectValue_AbActionButtonFormStdWidth" type="button"
title="{$fmAction/tip}" value="{$actionTitle}"
onclick='onSelectV("{$fmAction/@serialized}","{$recordName}","{$formName}");
selectedValueInputFormName="{$formName}" ;
selectValueInputFieldID="{$recordName}" ;'/>
</xsl:if>
</xsl:template>

Here's the XPath portion of the associated .xml file:

<dataSource>
<database>
<tables>
<table name="bl" role="main"/>
</tables>
</database>
<data><fields>
<field name="bl_id" table="bl" foreignKey="false" primaryKey="true"
size="8" decimals="0" fmType="2050" displaySizeHeading="8"
displaySizeNoHeading="8" singleLineHeading="Building Code"
type="java.lang.String" format="Upper"
required="true"><multiLineHeadings language="en"><multiLineHeading
multiLineHeading="Building"/><multiLineHeading
multiLineHeading="Code"/></multiLineHeadings></field>
<field name="wr_email" table="bl" foreignKey="false"
primaryKey="false" size="50" decimals="0" fmType="2050"
displaySizeHeading="20" displaySizeNoHeading="50"
singleLineHeading="WR Email" type="java.lang.String"
format="AnyChar"><multiLineHeadings language="en"><multiLineHeading
multiLineHeading="WR"/><multiLineHeading
multiLineHeading="Email"/></multiLineHeadings></field>
</fields><records selectedPosition="0"><record bl.bl_id="ADMC"
bl.wr_email="ADMC_workreq@xxxxxxx"><keys bl.bl_id="ADMC"
bl.wr_email="ADMC_workreq@xxxxxxx"/></record></records></data><data/></dataSo
urce>




On 3/9/06, David Carlisle <davidc@xxxxxxxxx> wrote:
>
>
> > I am trying to assign a user-input value to a variable. I know that
> > variable values can not be changed within a given template, but I am
> > still not sure if what I am trying to do is possible or not? If it is
> > not, can xsl:param be an alternative, and how or is there another
> > alternative at all? Can this be done by templates?
>
> what do you mean by "user-input value" ?
> I am not at all sure, but I suspect that you mean a form on a web page?
> If so you need to remember that XSLT just generates an HTML document, it
> doesn't itself know anything about HTML. Once the HTML document is
> created the XSLT process is _finished_ and the form is then passed to a
> browser which interprets it as HTML and displays a form and accepts user
> input. The prowser can then send the form data to whatever process is
> handling the form, this may be another XSLT stylesheet but it's an
> entirely different process from the one that generated the form
> (although it could use the same stylesheet of course). If you want to
> pass in values to a stylesheet then declare xsl:param at the top level
> of the stylesheet and pass in the values when the stylesheet is
> executed. There is a parallel thread on this list this week that
> discusses various server and client side frameworks that allow such
> parameters to be passed in.
>
> David
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________

Current Thread