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

Home Posts Topics Members FAQ

param in for-each select statement doesnt seem to work

stuff.XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:param name="uid"/>
<xsl:template match="/">
parameter UID=<xsl:value-of select="$uid"/>
<table border="1">
<tr>
<xsl:for-each select="row[data[3]/value=20]">
<td>
<xsl:value-of select="data[1]/value"/>
<xsl:value-of select="data[2]/value"/>
</td>
</xsl:for-each>
</tr></table>
</xsl:template></xsl:stylesheet>

stuff.XML:
<row>
<data>
<value>NAME</value>
</data>
<data>
<value>DATA</value>
</data>
<data>
<value>20</value>
</data>

stuff.asp:
<%@LANGUAGE="VB SCRIPT" CODEPAGE="1252" %>
<!--#include
file="includes/MM_XSLTransform/MM_XSLTransform .classVB.asp"
--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>XML</title>
</head>

<body>
<%
Dim mm_xsl: Set mm_xsl = new MM_XSLTransform
mm_xsl.setXML "stuff.xml"
mm_xsl.setXSL "stuff.xsl"
mm_xsl.addParam eter "uid", request.QuerySt ring("uid")
Response.write mm_xsl.Transfor m()
%>
</body>
</html>

=========

theres obviously lots of records and this is simplified to just display
the jist of what i'm doing... which is trying to pull out all the row
elements from the XML file where the 3rd data element's value in a row
element is 20

if i call the page on an asp file with stuff.asp?uid=2 0
then:
parameter UID=<xsl:value-of select="$uid"/>
will output "parameter UID=20"

if i change:
<xsl:for-each select="row[data[3]/value=20]">
to
<xsl:for-each select="row[data[3]/value=$uid]">
then i get nothing returned from the for-each. with the hardcoded 20
though, it will output what it is supposed to. i assume my syntax for
including the param in the for-each wrong, but i can't figure out how
to fix it...

Oct 18 '06 #1
9 2530

xmlhelp wrote:
stuff.XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:param name="uid"/>
<xsl:template match="/">
parameter UID=<xsl:value-of select="$uid"/>
<table border="1">
<tr>
<xsl:for-each select="row[data[3]/value=20]">
for-each! Renounce your evil ways! Use templates!

Seriously, for-each *is* evil. For one thing, its name is
misleading. It's really just an inline template together
with the template application.

<xsl:for-each select="...">
foo
</xsl:for-each>

....is virtually the same as:

<xsl:apply-templates select="..."
mode="absolutel y-unique-mode"/>
....
<xsl:template match="..." mode="absolutel y-unique-mode">
foo
</xsl:template>

....the difference being that the real template is readily
reusable. And for-each is not. And for-each gives XSLT
neophytes the illusion that they're still doing good ole
imperative programming. Evil.
<td>
<xsl:value-of select="data[1]/value"/>
<xsl:value-of select="data[2]/value"/>
</td>
</xsl:for-each>
</tr></table>
</xsl:template></xsl:stylesheet>
The output is not well-formed. Either use <output
method="text"/or make sure your transformation outputs
actual XML.
stuff.XML:
<row>
<data>
<value>NAME</value>
</data>
<data>
<value>DATA</value>
</data>
<data>
<value>20</value>
</data>
It's not well-formed. If you want help, you'd better post
something that makes it easier for people to help you.
stuff.asp:
[ASP]
theres obviously lots of records and this is simplified
to just display the jist of what i'm doing... which is
trying to pull out all the row elements from the XML file
where the 3rd data element's value in a row element is 20
[...]
if i change:
<xsl:for-each select="row[data[3]/value=20]">
to
<xsl:for-each select="row[data[3]/value=$uid]">
then i get nothing returned from the for-each. with the
hardcoded 20 though, it will output what it is supposed
to. i assume my syntax for including the param in the
for-each wrong, but i can't figure out how to fix it...
Works nicely for me (libxslt/PHP5 XSL module). I'd
recommend asking for help on Microsoft's newsgroups, this
is probably related to something in MSXML/ASP, not in XSLT.
Just fix your XML & XSLT before posting there.

--
Pavel Lepin

Oct 19 '06 #2
In article <11************ **********@i42g 2000cwa.googleg roups.com>,
xmlhelp <xc**@yahoo.com wrote:
[...]

You stylesheet looks ok, but I don't know anything about ASP.
Assuming that the parameter gets passed in as a string, there will
be a small difference: when you have the 20 hard-coded, it's a number,
but in the parameter version it will be a string, so the comparison
will be a string comparison instead of a numeric one. Are you sure
there are no spaces around either the data in the XML file or the
parameter value you are setting? That would cause the string
comparison to fail.

-- Richard
Oct 19 '06 #3
In article <11************ *********@i42g2 000cwa.googlegr oups.com>,
<p.*****@ctncor p.comwrote:
>for-each! Renounce your evil ways! Use templates!
Nonsense.
>Seriously, for-each *is* evil. For one thing, its name is
misleading. It's really just an inline template together
with the template application.
Why is "for-each" a misleading name for that?
>...the difference being that the real template is readily
reusable. And for-each is not.
True.
>And for-each gives XSLT
neophytes the illusion that they're still doing good ole
imperative programming. Evil.
Why is that evil?
>The output is not well-formed. Either use <output
method="text "/or make sure your transformation outputs
actual XML.
The output with the XML output method is not required to be a well-formed
XML document, only a well-formed XML external parsed entity. So a mixture
of elements and text is perfectly legal.

-- Richard
Oct 19 '06 #4

Richard Tobin wrote:
In article
<11************ *********@i42g2 000cwa.googlegr oups.com>,
<p.*****@ctncor p.comwrote:
Seriously, for-each *is* evil. For one thing, its name
is misleading. It's really just an inline template
together with the template application.

Why is "for-each" a misleading name for that?
I suppose because in a number of modern popular languages
(for some values of 'modern' and 'popular') foreach refers
to a language construct describing iteration over an array
or a list. XSLT doesn't have arrays or lists and doesn't
really iterate. I find that misleading, and neophytes
talking about the 'for loops' on the group seem to support
my point, but YMMV.
And for-each gives XSLT neophytes the illusion that
they're still doing good ole imperative programming.
Evil.

Why is that evil?
It's evil -- in my opinion -- because the longer they delay
the transition to declarative mindset, the harder it seems
to become.

Overall, my 'for-each considered harmful' rants are only
about half-serious, and I'm sorry if that's not obvious
from reading them. I still believe it's a good advice to
drop them unless you have a very good reason not too, but
I'm not waging a holy war on blasphemous for-each-users,
not really.
The output is not well-formed. Either use <output
method="text"/or make sure your transformation outputs
actual XML.

The output with the XML output method is not required to
be a well-formed XML document, only a well-formed XML
external parsed entity. So a mixture of elements and
text is perfectly legal.
My bad. It's the fault of my homegrown toolkit for
experimenting with XSLT -- it expects well-formed XML
documents out of transformations with <output
method="xml"/>. I'd still say it would be a good practice
to post stylesheets producing well-formed documents -- if
at all possible -- when posting examples to a newsgroup.

--
Pavel Lepin

Oct 19 '06 #5
p.*****@ctncorp .com wrote:
Overall, my 'for-each considered harmful' rants are only
about half-serious, and I'm sorry if that's not obvious
from reading them. I still believe it's a good advice to
drop them unless you have a very good reason not too, but
I'm not waging a holy war on blasphemous for-each-users,
not really.
Like any rule, you may break it if you have good reasons and if you are
aware that you are breaking it.

There are situations where for-each is useful...

// Magnus
Oct 19 '06 #6
p.*****@ctncorp .com wrote:
Seriously, for-each *is* evil.
Overstated somewhat, as I'm sure you'll admit. There are times when
for-each is the clearest way to express something, especially when
context variables are involved in the solution.

The only real problem is that for-each is an "attractive nuisance"
(legal term used to describe things like swimming pools which may
present a danger to kids who haven't learned not to trespass or how to
use them safely). It draws the attention of newbies, encouraging them to
write imperative solutions... which are generally harder to code, harder
to maintain, and generally uglier than the functional (or at least
modular!) approaches.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Oct 19 '06 #7
thanks so much!

changed:
<xsl:for-each select="row[data[3]/value=$uid]">
to:
<xsl:for-each select="row[data[3]/value=number($u id)]">

and it works! i knew it had to be something rather simple.
interesting little debate over templates and for-each though here ;)

Richard Tobin wrote:
In article <11************ **********@i42g 2000cwa.googleg roups.com>,
xmlhelp <xc**@yahoo.com wrote:
[...]

You stylesheet looks ok, but I don't know anything about ASP.
Assuming that the parameter gets passed in as a string, there will
be a small difference: when you have the 20 hard-coded, it's a number,
but in the parameter version it will be a string, so the comparison
will be a string comparison instead of a numeric one. Are you sure
there are no spaces around either the data in the XML file or the
parameter value you are setting? That would cause the string
comparison to fail.

-- Richard
Oct 19 '06 #8

Joe Kesselman wrote:
p.*****@ctncorp .com wrote:
Seriously, for-each *is* evil.

Overstated somewhat, as I'm sure you'll admit.
More than that, intentionally overstated. I hoped it would
be easier to swallow that way, but obviously people
thought I was seriously religious about that.
There are times when for-each is the clearest way to
express something, especially when context variables are
involved in the solution.
Can't argue with that.
The only real problem is that for-each is an "attractive
nuisance" (legal term used to describe things like
swimming pools which may present a danger to kids who
haven't learned not to trespass or how to use them
safely). It draws the attention of newbies, encouraging
them to write imperative solutions... which are generally
harder to code, harder to maintain, and generally uglier
than the functional (or at least modular!) approaches.
I suppose,
considered(X,ha rfmul) :- attractive(X), nuisance(X).

| ?- considered(X,ha rmful).

X = goto ? ;

X = xslforeach ? ;

X = swimmingpool ? ;

X = mywife

yes

--
Pavel Lepin

Oct 20 '06 #9
p.*****@ctncorp .com wrote:
More than that, intentionally overstated. I hoped it would
be easier to swallow that way, but obviously people
thought I was seriously religious about that.
Irony doesn't work very well in newsgroups; it's often hard to tell
whether folks are serious or not. (I often find that frustrating since
my own sense of humor leans strongly in that direction.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 20 '06 #10

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

Similar topics

1
3952
by: Carl Ogawa | last post by:
The following will stop to open test.pl due to using param('userid') and param('pwd'). Is there an alternative way to get data from HTML file to CGI file? I have to do this in the particular situation. -------- html file --------- <form name = "form3" action = "http://localhost/scripts/test.pl" method = post> Name: <INPUT TYPE = text NAME = "userid" size=25 value="OGAWA"><p> Password: <INPUT TYPE = password NAME = "pwd" size=12 ><p>...
5
2017
by: Keeko | last post by:
Actionscriptor needs help! I have a working javascript function (getVar()) that extracts a variable from a link and returns it. (tested with alert() works fine). But I am unsure of how to right the following line. document.write("<param name='flashVars' value=&{getVar(text)}>) This is a param from an object tag (embedding flash) and i'm trying to dynamically set the flashVars param, but this 1 line is killing me.
0
1863
by: Daimy | last post by:
I meet the same problem below, please help me! Thanks! //written by some one I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the
2
3931
by: VB Programmer | last post by:
I created a VB6 user control with a ActiveX Knob on it. Here's the simple code: Public Property Get Value() As Integer Value = CWKnob.Value End Property Public Property Let Value(Value As Integer) CWKnob.Value = Value lblValue.Caption = CWKnob.Value End Property
7
1935
by: Imre | last post by:
Hi Is it somehow possible to memorize / store a macro parameter so that we can reuse it in later macro expansions? For example, let's suppose we have a MACRO_A(param). I'd like to store param, so that when the user later invokes MACRO_B, they don't have to supply the same param again, instead MACRO_B would use the param stored by MACRO_A.
4
7661
by: Aussie Rules | last post by:
Hi, I have the Windows media object placed on a web page. Since its not a .net component (its a com object) I have placed the code in the html source of the page. The problem I am having is that I get the url of the video file i want to play in the asp.net code (form_load event). How do I pass this value into the html... Ie :
0
814
by: YousufHossain | last post by:
I HAVE AN OBJECT IN MY ASP.NET PAGE. IT IS NOT IN THE FORM TAGS. I WANT TO CHANGE THE VALUE OF THE MOVIE PARAM IN VB.NET <object ID="m" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/anHkwBYH-bY"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/anHkwBYH-bY" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> I AM TRYING...
3
1624
by: patelxxx | last post by:
Hi Guy's, Can you explain to me what is the 'Param Class' and what is it used for? I've just visited CPAN to find out what the Param Class however CPAN only shows the methods used by this class, such as: $value = $param->get($name); $param->set( $name => $value ); $param->add( $name => $value );
5
2933
by: mdshafi01 | last post by:
HI, I have problem in this code it is not working it is not going insdie param condition... please what will be the problem please help me
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9587
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,...
0
10588
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10324
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
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...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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
5662
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

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.