Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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 January 19th, 2010, 07:06 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question Add an iframe dependant on a certain object's value

Good day,

I would like to add an iframe dependant on a certain Object's value.

[code]
<!-- First do all the ungrouped objects -->
<
xsl:for-eachselect="Activity/ObjectGroup[@type='default']/Object">
<
xsl:sortselect="@index"data-type="number" />
<
xsl:variablename="index"select="@index" />
<
xsl:variablename="nextNode"select="../Object[ @index > $index ][1]" />
<
xsl:variablename="nextCol"select="$nextNode/@columnNo" />
<
xsl:variablename="vis"select="string(Attributes/Attribute[ @name='visible'])" />
<
xsl:variablename="visNextCol"select="string($nextNode/Attributes/Attribute[ @name='visible'])" />
<
xsl:iftest="($vis != 'False') or ($nextCol = '2' and ($vis != 'False' or $visNextCol != 'False'))">
<
xsl:iftest="(@columnNo != '2')">
<
trclass="rowDetail">
<xsl:choose>
<
xsl:whentest="Attributes/Attribute[ @name='visible'] != 'False'">
<
td><xsl:value-ofselect="Description"disable-output-escaping="yes" />
<
xsl:call-templatename="CreateObject">
<xsl:with-paramname="Object"select="." />
</
xsl:call-template>

</
xsl:when>
</tr>
</
xsl:if>

If Object ID ''VE1085NewVSite' = 'TESTING'
THEN
<
br/>
<
xsl:elementname="div">
<
xsl:attributename='id'>DV_SSRSVenBank</xsl:attribute>
<
xsl:attributename='style'>display:none;position:absolute;border-style: solid;border-width:2px;</xsl:attribute>
<
xsl:elementname="IFRAME">
<
xsl:attributename='id'>IF_SSRSVenBank</xsl:attribute>
<
xsl:attributename='name'>IF_SSRSVenBank</xsl:attribute>
<
xsl:attributename='width'>700</xsl:attribute>
<
xsl:attributename='height'>550</xsl:attribute>
<
xsl:attributename='frameborder'>no</xsl:attribute>
<
xsl:attributename='src'></xsl:attribute></xsl:element>
</
xsl:element>
<!--
</xsl:if> -->


</
xsl:if>
</
xsl:for-each>
 
Old January 19th, 2010, 07:31 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Firstly, I don't know why but your code seems to be removing a lot of spaces between your XML attributes. This makes it very hard to read your code samples, and impossible to cut and paste to test.

Secondly, we can't advice you on how to test some XML elements content or attributes if you don't show us what your XML looks like and what you want the output to look like.

I don't see what your problem is however. You simply put whatever you want inside an <xsl:if> instruction:

Code:
<xsl:if test="@value='test'">
  <iframe frameborder="no" name="iframe1" src="http://test.com"/>
</xsl:if>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 19th, 2010, 07:45 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question

Thank for helping.

I'm not to sure about the output, the xlt loads an aspx page.
I only want to add an iframe when an object has a certain value.

if my object's id is 'VE1085NewVSite' then how would i check for the value.
Code:
<xsl:if test="@id='VE1085NewVSite'">
  <xsl:if test="@value='test'">

2. In my src of iframe contains "&" does not work

 
Old January 19th, 2010, 07:53 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Define what you mean by 'value'. You still haven't posted any sample XML, so we don't know what we are looking at.

If you want to do two conditions simply put them in the same <xsl:if> statement with "and" between them:

<xsl:if test="@id='A' and @value='B'">
...
</xsl:if>

If your 'src' attribute contains ampersands then encode them just like you would in standard XML (as that is what you problem is likely). &amp;
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 19th, 2010, 08:15 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question

Hi, not winning - i only have the xlt file code. Not winning
Output? - it loads an aspx page & i want add an iframe based on an object value?

Code:
<xsl:for-eachselect="Activity/ObjectGroup[@type='default']/Object">
<xsl:sortselect="@index"data-type="number" />
<xsl:variablename="index"select="@index" />
<xsl:variablename="nextNode"select="../Object[ @index > $index ][1]" />
<xsl:variablename="nextCol"select="$nextNode/@columnNo" />
<xsl:variablename="vis"select="string(Attributes/Attribute[ @name='visible'])" />
<xsl:variablename="visNextCol"select="string($nextNode/Attributes/Attribute[ @name='visible'])" />
<xsl:iftest="($vis != 'False') or ($nextCol = '2' and ($vis != 'False' or $visNextCol != 'False'))"> 
<xsl:iftest="(@columnNo != '2')">
<trclass="rowDetail">
 
<xsl:choose>
<xsl:whentest="Attributes/Attribute[ @name='visible'] != 'False'">
<tdwidth='20%'align='right'height="30px"class='rowDet'>
<xsl:value-ofselect="Description"disable-output-escaping="yes" />
<xsl:iftest="DisplayMask[. = 'True']">
<xsl:iftest="Mask[. != '']">
(<xsl:value-ofselect="Mask" />)
</xsl:if>
</xsl:if>
<!-- <xsl:if test=" @required[. = 'true']">*</xsl:if> -->
</td>
<tdvalign="middle"height="35px"class='rowDetNew'>
<xsl:iftest="($nextCol != '2') or (count(following-sibling::*) = 0) or ($nextCol = '2' and $visNextCol = 'False')">
<xsl:attributename='colspan'>4</xsl:attribute>
<xsl:attributename='width'>70%</xsl:attribute>
</xsl:if>
<xsl:call-templatename="CreateObject">
<xsl:with-paramname="Object"select="." />
</xsl:call-template>
<xsl:iftest="Tooltip != ''"><xsl:value-ofselect="Tooltip" /></xsl:if>
<!--xsl:if test="@id='VE1060NewSupplier' and @value='No'"> -->
<xsl:if test="@name='VE1060NewSupplier' and @value='No'"> 
<iframeframeborder="no"name="iframe1"src="http://www.supersport.com"/>
</xsl:if> 
</td>
</xsl:when>
 
</td>
</xsl:if> 
</tr>
</xsl:if> 
</xsl:if>
</xsl:for-each>
 
Old January 19th, 2010, 08:31 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I'm sorry, but without seeing what your INPUT XML looks like I really can't help any further.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 19th, 2010, 09:08 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question

Thanks for helping - Where would i find the input xml

i found that i can't find the value of the objects syntax because

if i test like below then it works
Code:
<xsl:iftest="@name='VE1060NewSupplier'">
<xsl:iftest="Tooltip != ''">
but when i try to filter on value
Code:
<xsl:iftest="@name='VE1060NewSupplier'">
<xsl:if test="@value='No'">  <!-- <xsl:if test="value='No'"> -->
Code:
<xsl:call-templatename="CreateObject">
<xsl:with-paramname="Object"select="." />
</xsl:call-template>
 
<xsl:iftest="@name='VE1060NewSupplier'">
<!--<xsl:if test="@value='No'"> -->
<xsl:iftest="Tooltip != ''"><xsl:value-ofselect="Tooltip" />
<iframeframeborder="no"name="iframe1"src="http://www.supersport.com"/>
</xsl:if> 
</xsl:if>
drop down object
Code:
<!-- Drop downs, lookups, etc -->
<xsl:templatename="ListValueType">
<xsl:paramname="Name" />
<xsl:paramname="Attributes" />
<xsl:paramname="Options" />
<xsl:paramname="Value" />
<xsl:elementname="asp:dropdownlist">
<xsl:attributename='id'><xsl:value-ofselect='$Name' /></xsl:attribute> 
<xsl:attributename='runat'>server</xsl:attribute> 
<xsl:for-eachselect="$Attributes/Attribute">
<xsl:attributename='{@name}'><xsl:value-ofselect='.' /></xsl:attribute>
</xsl:for-each>
<xsl:for-eachselect='$Value/Options/Option'>
<xsl:elementname="asp:ListItem">
<xsl:attributename='Value'><xsl:value-ofselect='.' /></xsl:attribute>
<xsl:iftest="@selected[. = 'true']"><xsl:attributename='selected'>true</xsl:attribute></xsl:if>
<xsl:value-ofselect='.' />
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>

Last edited by ismailc; January 19th, 2010 at 09:10 AM..
 
Old January 19th, 2010, 10:03 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Where would you find the input xml? How on earth would I know. I'm talking about the XML you are transforming - the XML that contains the <Object> element etc.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Row Colours dependant on a field- FIXED Andrew.Berry ASP.NET 2.0 Basics 6 December 13th, 2007 05:59 AM
Dependant Dropdown Help phoenix211984 Dreamweaver (all versions) 0 October 11th, 2006 02:47 PM
New problem with Romting object's SecurityExcept emojg .NET Web Services 0 August 24th, 2004 12:37 PM
Dependant Child Classes owain Pro VB 6 7 April 28th, 2004 02:33 PM





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