XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Atif SarfrazSubject: XSL Template problem
Author: Atif Sarfraz
Date: 26 Nov 2001 08:45 PM
Hi,

I have created an XSL template to automatically check a radio button depending upon some value of XML. So if there is a group of 5 radio buttons, then depending upon the value of XML field, one of them would be checked.

The template works fine with one group of radio buttons. But if I start calling the same template from another group, with a different "name", then the first group and the second group of radio buttons behave as they belonged to the same group.

Here is the template code

{xsl:template name='radioButtonTemplate' }
{xsl:param name='arg1' select='/' /}
{xsl:param name='arg2' /}
{xsl:param name='arg3' /}

{xsl:if test="$arg1=$arg2"}
{input type="radio" checked="" name=""}
{xsl:attribute name="value"}$arg1{/xsl:attribute}

{xsl:attribute name="name"}$arg3{/xsl:attribute}
{/input}

{/xsl:if}
{xsl:if test="$arg1!=$arg2"}
{input type="radio" name=""}
{xsl:attribute name="value"}$arg1{/xsl:attribute}

{xsl:attribute name="name"}$arg3{/xsl:attribute}
{/input}
{/xsl:if}

{/xsl:template}


I am calling the template with the following code.

{xsl:call-template name='radioButtonTemplate' }
{xsl:with-param name='arg1' }Other{/xsl:with-param}
{xsl:with-param name='arg2' select='HSCROOT/MORTGAGEDATA/PRODUCT/@MortgageType' /}
{xsl:with-param name='arg3' }MortgageType{/xsl:with-param}
{/xsl:call-template}

What I feel is that arg2 behaves like a sort of a global variable, and on changing the group of radio buttons, the first one also gets effected.

Am I correct? Is there a way out of it? Or should I create separate templates for each group of radio buttons.

Postnext
Minollo I.Subject: Re: XSL Template problem
Author: Minollo I.
Date: 26 Nov 2001 09:23 PM
I would guess that your problems are caused by this and similar blocks:

>...
>{input type="radio" checked="" name=""}
>{xsl:attribute name="value"}$arg1{/xsl:attribute}
>{xsl:attribute name="name"}$arg3{/xsl:attribute}
>{/input}
>...

At least in the Stylus Studio processor, trying to re-define the value of
an attribute already defined in the parent element is a no-op (I searched
the specs trying to understand what the right behavior should be, but I
couldn't find this case covered...).
That means that the name of the radio buttons would end-up being always the
same (empty) explaining the behavior you are describing.
If that's the problem, the fix is very easy: just remove 'name=""' from
your {input} element creation.

>...
>What I feel is that arg2 behaves like a sort of a global variable, and on
>changing the group of radio buttons, the first one also gets effected.
>
>Am I correct? Is there a way out of it? Or should I create separate
>templates for each group of radio buttons.

No, template parameters are not global variables; you should expect the
named template to be called with a different set of parameter values every
time it's called.

Minollo

Postnext
Atif SarfrazSubject: XSL Template problem
Author: Atif Sarfraz
Date: 27 Nov 2001 10:01 AM
Hi,

I have checked the code again, and even if I remove the name attribute from the top element, the code still doesn't work. It only works only if I remove all the name attributes including the new ones.

{xsl:if test="$arg1=$arg2"}
{input type="radio" checked=""}
{xsl:attribute name="value"}$arg1{/xsl:attribute}
{/input}
{/xsl:if}

Now there is only one option selected in each group of radio buttons. However the problem, is that I can't now select any other radio button.

I have checked the HTML Code, and what I see is that the $arg1 doesn't assigns the value, but the string $arg1 itself. So the html shows

{input type="radio" checked value="$arg1" name="$arg3"}

What Tag should I use to assign the value of $arg1?

Posttop
Atif SarfrazSubject: XSL Template problem
Author: Atif Sarfraz
Date: 27 Nov 2001 10:17 AM
Oh I got it, the correct way to put the value was

{xsl:attribute name="name"}{xsl:value-of select='$arg3' /}{/xsl:attribute}

So its working fine now.

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.