473,804 Members | 3,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't change variables so how do I work around it.

I want to depending on a parameter in the XML change wether the div should
display or not. Do I have to repeat the whole block in two if containers
with the style display:none and one with display:block but then whenever I
have to make a change to the block I have to update in two places? Any help
would be appreciated.

My example:

<xsl:if test="Requireme ntGroup/@ReqMet = &quot;Y&quot ;">

<div style="display: none;margin-left:1em;" id="Area_Info{$ intArea_Info}">

<xsl:if test="string-length(Code) &gt; 0">

<br />Code:<xsl:fo r-each select="Code">

<xsl:apply-templates />

</xsl:for-each>

</xsl:if>

<br />

<span style="backgrou nd-color:#336633; color:#FFFFFF; width:100%;
">Requireme nt Group:</span>

<xsl:apply-templates select="Require mentGroup" />

<br />Course Group:<xsl:appl y-templates select="CourseG roup" />

<xsl:if test="string-length(Review) &gt; 0">

<br />Review: <xsl:apply-templates select="Review" />

</xsl:if>

<br />Summary: <xsl:apply-templates select="Summary " />

<br />

</div>

</xsl:if>

<xsl:if test="Requireme ntGroup/@ReqMet = &quot;N&quot ;">

<div style="display: block;margin-left:1em;" id="Area_Info{$ intArea_Info}">

<xsl:if test="string-length(Code) &gt; 0">

<br />Code:<xsl:fo r-each select="Code">

<xsl:apply-templates />

</xsl:for-each>

</xsl:if>

<br />

<span style="backgrou nd-color:#336633; color:#FFFFFF; width:100%;
">Requireme nt Group:</span>

<xsl:apply-templates select="Require mentGroup" />

<br />Course Group:<xsl:appl y-templates select="CourseG roup" />

<xsl:if test="string-length(Review) &gt; 0">

<br />Review: <xsl:apply-templates select="Review" />

</xsl:if>

<br />Summary: <xsl:apply-templates select="Summary " />

<br />

</div>

</xsl:if>
Jul 20 '05 #1
3 1952

Your question isn't very clear, however the answer to

I want to depending on a parameter in the XML change wether the div should
display or not. Do I have to repeat the whole block in two if containers
with the style display:none and one with display:block but then whenever I
have to make a change to the block I have to update in two places?

Is probably no.

If you only want to make the attriibute depend on the parameter just
place the conditional at that point.

<div id="Area_Info{$ intArea_Info}">
<xsl:attribut e name="style">
<xsl:text>displ ay:</xsl:text>
<xsl:choose>
<xsl:when test="something ">none</xsl:when>
<xsl:otherwise> block</xsl:otherwise>
</xsl:choose>
<xsl:text>;marg in-left:1em;</xsl:text>
</xsl:attribute>
....

<xsl:if test="string-length(Code) &gt; 0">
incidentally, probably better to do
<xsl:if test="string(Co de)">
(which is equivalent)
or
<xsl:if test="Code">
which isn't equivalent (it's true even if the first code is empty, unlike the first two)
David
Jul 20 '05 #2
I tried your example but it is not working for me. My test that I have in
my original example doesn't work in your example even though it is in the
same template block.

My Code:
<xsl:template match="Area">

<xsl:if test="Requireme ntGroup/@ReqMet = &quot;Y&quot ;">

<span style="color:#F FCC00; font-size:15px; " id="Requirement _Met">

<div id="Area_Info_p lus{$intArea_In fo}"
style="width=1e m;display:inlin e;">+</div><div
id="Area_Info_m inus{$intArea_I nfo}" style="width=1e m;display:none; ">-</div>
Yes</span>

</xsl:if>

</xsl:template>

But if I put the test above in your code it doesn't change the attribute.

"David Carlisle" <da****@nag.co. uk> wrote in message
news:yg******** *****@penguin.n ag.co.uk...

Your question isn't very clear, however the answer to

I want to depending on a parameter in the XML change wether the div should display or not. Do I have to repeat the whole block in two if containers with the style display:none and one with display:block but then whenever I have to make a change to the block I have to update in two places?

Is probably no.

If you only want to make the attriibute depend on the parameter just
place the conditional at that point.

<div id="Area_Info{$ intArea_Info}">
<xsl:attribut e name="style">
<xsl:text>displ ay:</xsl:text>
<xsl:choose>
<xsl:when test="something ">none</xsl:when>
<xsl:otherwise> block</xsl:otherwise>
</xsl:choose>
<xsl:text>;marg in-left:1em;</xsl:text>
</xsl:attribute>
...

<xsl:if test="string-length(Code) &gt; 0">
incidentally, probably better to do
<xsl:if test="string(Co de)">
(which is equivalent)
or
<xsl:if test="Code">
which isn't equivalent (it's true even if the first code is empty, unlike the first two)

David

Jul 20 '05 #3
Ignore this I realize my error now. I had my statements backwards and now
it is working correctly.

"Jason Lehman" <jl***********@ n0spm.admin.n0s pam.usf.edu> wrote in message
news:cu******** **@news1.usf.ed u...
I tried your example but it is not working for me. My test that I have in
my original example doesn't work in your example even though it is in the
same template block.

My Code:
<xsl:template match="Area">

<xsl:if test="Requireme ntGroup/@ReqMet = &quot;Y&quot ;">

<span style="color:#F FCC00; font-size:15px; " id="Requirement _Met">

<div id="Area_Info_p lus{$intArea_In fo}"
style="width=1e m;display:inlin e;">+</div><div
id="Area_Info_m inus{$intArea_I nfo}" style="width=1e m;display:none; ">-</div> Yes</span>

</xsl:if>

</xsl:template>

But if I put the test above in your code it doesn't change the attribute.

"David Carlisle" <da****@nag.co. uk> wrote in message
news:yg******** *****@penguin.n ag.co.uk...

Your question isn't very clear, however the answer to

I want to depending on a parameter in the XML change wether the div should
display or not. Do I have to repeat the whole block in two if

containers
with the style display:none and one with display:block but then

whenever I
have to make a change to the block I have to update in two places?

Is probably no.

If you only want to make the attriibute depend on the parameter just
place the conditional at that point.

<div id="Area_Info{$ intArea_Info}">
<xsl:attribut e name="style">
<xsl:text>displ ay:</xsl:text>
<xsl:choose>
<xsl:when test="something ">none</xsl:when>
<xsl:otherwise> block</xsl:otherwise>
</xsl:choose>
<xsl:text>;marg in-left:1em;</xsl:text>
</xsl:attribute>
...

<xsl:if test="string-length(Code) &gt; 0">
incidentally, probably better to do
<xsl:if test="string(Co de)">
(which is equivalent)
or
<xsl:if test="Code">
which isn't equivalent (it's true even if the first code is empty,
unlike the first two)


David


Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2961
by: vishal | last post by:
hi vishal here. can anyone help me that how can i store the global variables for my web site. suppose i want to store the no. of users visited my site then what strategy should i use ????? can i implement some lock mechanism so that this global variable is not accessed by more than one application at some time which may create some confusion.
12
2528
by: Dave Smithz | last post by:
Hi there, Users of my PHP DB application have complained that it seems to log them out every now and then. I actually assume this is when it has been idle for sometime as I use session variables to store a logged in token. With only basic knowledge of sessions I assumed there was some kind of default time before the session data is destroyed. Is this the case?
47
12350
by: Mountain Bikn' Guy | last post by:
Take some standard code such as shown below. It simply loops to add up a series of terms and it produces the correct result. // sum numbers with a loop public int DoSumLooping(int iterations) { int result = 0; for(int i = 1;i <=iterations;i++) { result += i;
2
7985
by: Paul Brady | last post by:
I have non-computer skilled users entering data into a form. There are certain ranges of values which, if they enter them, make no sense in the application, but I can't test them until they try to close out the form, in which case I can look at the entire set of values and see if they're OK. So, I have this code. for the "Before Update" event: if (their variables are inappropriate) then msgbox "You've entered bad variables (or some...
17
5636
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
6
4906
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
8
2679
by: bim_bom | last post by:
Hi, is there any tool to change naming convention in c++ sources? I mean something, that parses cpp and h files in my project, and it finds, what variables are there declared. I think, it should have a public "CALLBACK" function (which would be impemented by me), which would tell the program, how to rename variables and functions. It should work like that: I have sourcecode:
16
5191
by: mj.redfox.mj | last post by:
Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString Page.FindControl("tdInput").Controls.Add(txtTest) This successfully creates a textbox called "txtLeft1" in the table
4
4593
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.