473,569 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL: parameter checking

Hi,
Is it possible to check parameters against other parameters, as in:

<xsl:variable name="tableData ">
<xsl:apply-templates
select="general/data/rows/row/fvalues[$FIELD1=$FILTER 1][$FIELD2=$FILTER 2]"
mode="tableData " />
</xsl:variable>

(The parts I'm referring to are in capitals). Because this gives me no
output where I'm expecting 6 node elements. Is this because it's not
possible to use parameters this way or is it just me making some other
mistake in my Xpath? I hope the second is true so I don't have to come
up with another solution... Thanks! Sharon
Jul 20 '05 #1
7 2155
Sharon wrote:
Hi,
Is it possible to check parameters against other parameters, as in:

<xsl:variable name="tableData ">
<xsl:apply-templates
select="general/data/rows/row/fvalues[$FIELD1=$FILTER 1][$FIELD2=$FILTER 2]"
mode="tableData " />
</xsl:variable>


select="general/data/rows/row/fvalues[$FIELD1=$FILTER 1 and
$FIELD2=$FILTER 2]"
JW

Jul 20 '05 #2
es*****@hotmail .com (Sharon) writes:
Is it possible to check parameters against other parameters, as in:

<xsl:variable name="tableData ">
<xsl:apply-templates
select="general/data/rows/row/fvalues[$FIELD1=$FILTER 1][$FIELD2=$FILTER 2]"
mode="tableData " />
</xsl:variable>

(The parts I'm referring to are in capitals). Because this gives me no
output where I'm expecting 6 node elements. Is this because it's not
possible to use parameters this way or is it just me making some other
mistake in my Xpath? I hope the second is true so I don't have to come
up with another solution... Thanks! Sharon


Give the expression

"general/data/rows/row/fvalues[$FIELD1=$FILTER 1 and $FIELD2=$FILTER 2]"

a try and see if it helps. If not then post again with a bigger
example (eg. some XML input and an idea of the output you want).

Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #3
Thanks, you guys, but that wasn't the problem. My XSL works fine when I
change the line to:
select="general/data/rows/row/fvalues[fclient=$filter 1][fcity=$filter2]"
mode="tableData "
that is when I change the first parameter into a specific node. But

that's exactly what I'm trying to avoid: I want to create a filter that
is not predefined and takes table values that are selected by the user
as its parameters(colu mn name would be $field and filtervalue would be
$filter). The parameter $field could then take any of the existing
column names (such as fclient, fcity etc.) as its value and the
parameter $filter would contain the value to be filtered on. Obviously
it can't be done this way, can anyone tell me how I might work around
this problem? Thanks! Sharon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Sharon Steringa <es*****@hotmai l.com> writes:
Thanks, you guys, but that wasn't the problem. My XSL works fine when I
change the line to:
select="general/data/rows/row/fvalues[fclient=$filter 1][fcity=$filter2]"
mode="tableData "
that is when I change the first parameter into a specific node. But

that's exactly what I'm trying to avoid: I want to create a filter that
is not predefined and takes table values that are selected by the user
as its parameters(colu mn name would be $field and filtervalue would be
$filter). The parameter $field could then take any of the existing
column names (such as fclient, fcity etc.) as its value and the
parameter $filter would contain the value to be filtered on. Obviously
it can't be done this way, can anyone tell me how I might work around
this problem? Thanks! Sharon


It's kind of hard to understand the problem without the example code I
suggested you post, so it's no surprise that the answers are off-beam.

Anyway, I hope I've managed to decipher what you want from the
somewhat obscure description above. Try this:

select="general/data/rows/row/fvalues/
*[name()=$field and node()=$filter1]/../
*[name()=$filter and node()=$filter2]/.."

[Note, I've split the line to avoid wrapping: just join it all up]

Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #5
Hmmm, that's a good lesson for me because I was trying to be as clear as
possible about my problem and thought I had succeeded :-)...Maybe it's
time I improve my communication skills. Anyway, the reason I was
reluctant to post my XML and XSL is because when I did that before,
nobody answered so I thought: "Maybe it scares people...So if I want
answers I will have to ask small questions and not provide too much code
at once." Here's my XML anyway:

<?xml version="1.0" encoding="utf-8" ?>
<general>
<data>
<header></header>
<global>
<orderby />
<created />
</global>
<cols>
<fclient caption="Client " type="number" visible="True" />
<fid caption="Sleute lveld" type="number" visible="True" />
<fusername caption="Userna me" type="number" visible="True"/>
<fname caption="Naam" type="text" visible="True" />
<fcity caption="Woonpl aats" type="text" visible="True" />
<factive caption="Active " type="text" visible="False" />
<fdebno caption="Debite urnr" type="number" visible="True" />
<fpassword caption="passwo rd" type="text" visible="False" />
</cols>
<rows>
<row>
<id value="32" />
<fvalues>
<fclient>1</fclient>
<fid>13</fid>
<fusername>Piet je</fusername>
<fname>Pieter s Autotransport B.V.</fname>
<fcity>Meppel </fcity>
<factive>True </factive>
<fdebno>5</fdebno>
<flanguage>NL </flanguage>
<fpassword>Flup </fpassword>
</fvalues>
</row>
<row>
<id value="43" />
<fvalues>
<fclient>2</fclient>
<fid>43</fid>
<fusername>Will ie</fusername>
<fname>Willie Bruining</fname>
<fcity>Blijha m</fcity>
<factive>True </factive>
<fdebno>9</fdebno>
<flanguage>NL </flanguage>
<fpassword>Kwik </fpassword>
</fvalues>
</row>
<row>
<id value="21" />
<fvalues>
<fclient>3</fclient>
<fid>83</fid>
<fusername>Bert je</fusername>
<fname>Bertje Autotransport B.V.</fname>
<fcity>Meppel </fcity>
<factive>True </factive>
<fdebno>9</fdebno>
<flanguage>NL </flanguage>
<fpassword>Kwek </fpassword>
</fvalues>
</row>
<row>
<id value="64" />
<fvalues>
<fclient>0</fclient>
<fid>73</fid>
<fusername>Bill ie</fusername>
<fname>Billie Bruining</fname>
<fcity>Billieha m</fcity>
<factive>True </factive>
<fdebno>3</fdebno>
<flanguage>NL </flanguage>
<fpassword>Kwak </fpassword>
</fvalues>
</row>
<row>
<id value="25" />
<fvalues>
<fclient>5</fclient>
<fid>23</fid>
<fusername>Piet je</fusername>
<fname>Bob Autotransport B.V.</fname>
<fcity>Zaanda m</fcity>
<factive>True </factive>
<fdebno>9</fdebno>
<flanguage>NL </flanguage>
<fpassword>Kwuk </fpassword>
</fvalues>
</row>
<row>
<id value="68" />
<fvalues>
<fclient>4</fclient>
<fid>10</fid>
<fusername>Sjoe rd</fusername>
<fname>Sjoerd de Vries</fname>
<fcity>Billieha m</fcity>
<factive>True </factive>
<fdebno>5</fdebno>
<flanguage>NL </flanguage>
<fpassword>Kwok </fpassword>
</fvalues>
</row>
</rows>
</data>
<footer></footer>
</general>

And here's the XSL (based on an example by RDC Pro):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="ur n:schemas-microsoft-com:xslt"
xmlns:dates="ur n:rdcpro-com:dates">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:param name="username" select="general/data/rows/row"/>
<xsl:param name="field1" select="'fclien t'"/>
<xsl:param name="filter1" select="$userna me/fvalues/fclient"/>
<xsl:param name="field2" select="'fcity' "/>
<xsl:param name="filter2" select="$userna me/fvalues/fcity"/>
<xsl:param name="direction ">ascending </xsl:param>
<xsl:param name="sortBy">f username</xsl:param>
<xsl:variable name="tableData ">
<xsl:apply-templates
select="general/data/rows/row/fvalues[name()=$field1 and
node()=$filter1][name()=$field2 and node()=$filter2] " mode="tableData "
/>
</xsl:variable>
<xsl:template match="general/data">
<div align="left">
<div class="content" align="right" style="padding-bottom:4px;">
Sort Direction:
<xsl:value-of select="$direct ion"/><br/>
Sort Column:
<xsl:value-of select="$sortBy "/>
</div>
<table border="1" class="results" align="center" cellpadding="5"
cellspacing="0" >
<tr>
<th>
<a class="clickanc hor" onclick="render Data('fclient') ;">
<xsl:value-of select="cols/fclient/@caption"/>
</a>
</th>
<th>
<a class="clickanc hor" onclick="render Data('fid');">
<xsl:value-of select="cols/fid/@caption"/>
</a>
</th>
<th>
<a class="clickanc hor" onclick="render Data('fusername ');">
<xsl:value-of select="cols/fusername/@caption"/>
</a>
</th>
<th>
<a class="clickanc hor" onclick="render Data('fname');" >
<xsl:value-of select="cols/fname/@caption"/>
</a>
</th>
<th>
<a class="clickanc hor" onclick="render Data('fcity');" >
<xsl:value-of select="cols/fcity/@caption"/>
</a>
</th>
<th>
<a class="clickanc hor" onclick="render Data('fdebno'); ">
<xsl:value-of select="cols/fdebno/@caption"/>
</a>
</th>
</tr>
<xsl:apply-templates select="msxsl:n ode-set($tableData)/fvalues">
<xsl:sort select="*[name()=$sortBy]" order="{$direct ion}"/>
</xsl:apply-templates>
</table>
</div>
</xsl:template>
<xsl:template match="fvalues" >
<tr>
<xsl:for-each select="*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="fvalues" mode="tableData ">
<xsl:copy>
<xsl:for-each select="*">
<xsl:if
test="/general/data/cols/*[name()=name(cur rent())]/@visible='True' ">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Now I want the data to display properly, just like it does with the
select statement of the apply-templates in the variable that I mentioned
in my last post. I filled in what I thought you meant in my XSL but it
still won't show any data, maybe you meant something else. Anyway thanks
a lot for your comments, hope you can help me some more with this
example code. Thanks! Sharon
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #6
Sharon Steringa <es*****@hotmai l.com> writes:
Hmmm, that's a good lesson for me because I was trying to be as clear as
possible about my problem and thought I had succeeded :-)...Maybe it's
time I improve my communication skills. Anyway, the reason I was
reluctant to post my XML and XSL is because when I did that before,
nobody answered so I thought: "Maybe it scares people...So if I want
answers I will have to ask small questions and not provide too much code
at once." Here's my XML anyway:
It's much quicker for anyone trying to work on a problem if an example
is given - preferably a small abstract that encapsulates the problem -
including the code, input data and the output you expect.

Text descriptions of problems are rarely easy to follow. A snippet of
code is so much clearer.
Now I want the data to display properly, just like it does with the
select statement of the apply-templates in the variable that I mentioned
in my last post. I filled in what I thought you meant in my XSL but it
still won't show any data, maybe you meant something else. Anyway thanks
a lot for your comments, hope you can help me some more with this
example code. Thanks! Sharon
Your XSL has the following XPat expression general/data/rows/row/fvalues[name()=$field1 and
node()=$filter1][name()=$field2 and node()=$filter2]


which bears only a passing resemblence to what I wrote. If you do
actually put in what I wrote it works fine. The dots and stars
make all the difference:

<xsl:apply-templates
select="general/data/rows/row/fvalues/*[name()=$field1 and
node()=$filter1]/../*[name()=$field2 and node()=$filter2]/.."
mode="tableData "
/>

With your data and corrected template you get all the output
(because your parameter statements for filter1 and filter2 give
you all the fclient and fcity nodes.)

However, if you set
<xsl:param name="filter1" select="'5'"/>
<xsl:param name="filter2" select="'Zaanda m'"/>

then you get only the data for fclient=5 and fcity=Zaandam
which I'm still assuming is what you want.

Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #7
Wow, thanks, you are absolutely right! Great!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #8

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

Similar topics

5
8607
by: ipg | last post by:
I am running into issues passing a parameter (that is a XML string) into a stylesheet and using msxsl:node-set to parse the string. Can someone please explain why. my html: var xsl = new ActiveXObject("MSXML2.FreeThreadedDomDocument.3.0"); xsl.async = false; xsl.load("campaignHtml.xsl"); var template = new...
4
2426
by: Kevin Dean | last post by:
I'm trying to create an XSL transformation that will strip out development-specific attributes from deployment descriptors and other XML files. I have already successfully done so with web.xml but I'm at a complete loss as to what is wrong with the one below. This is a very abbreviated server-config.wsdd: <?xml version="1.0"...
0
1611
by: Mikael Petterson | last post by:
Hi, I am trying to produce the following in javacode; public void action<An actionName>(String value1, int value 2....,Coordinator c) throws Exception; The arguments to the actionXXX could be from only a Coordiantor and up to any number of int:s and Strings before ( however not to many in practice).
1
1585
by: Mario | last post by:
Hi all From the data-structure below I want to make a table with the following datas RNG@name theName1 RNG/PARAMETER/TEST@name Test1 Test2 RNG/PARAMETER@Para Para1 PASSED/FAILED PASSED/FAILED RNG/PARAMETER@Para Para2 PASSED/FAILED PASSED/FAILED
1
4542
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable name="Tim">ZXCVBNM</Variable> <Function id="1"> <Parameter type="String">Bob</Parameter> <Parameter type="String">Steve</Parameter>
2
4622
by: systemutvecklare | last post by:
Hi! I have an application that generates an html-form from an xml-file using an xsl-file. My problem is that I want the xsl to use some "unknown" parameters that I pass to the xslt processor before processing the xml. The parameters are not totally unknown but they are not static, they are built by an attribute in the xml and a constant...
6
14177
by: Jody Gelowitz | last post by:
I have run into an issue with variable scope within an XSLT document that is translated in VS.NET 2.0. Under VS.NET 1.1 (XslTransform), this code works fine. However, when using VS.NET 2.0 (XslCompiledTransform), the exact same XSLT transformation fails with the error: System.Xml.Xsl.XslLoadException: The variable or parameter...
1
2473
Dormilich
by: Dormilich | last post by:
Hi, I'm running into a problem with the <xsl:processing-instruction> element (Sablotron). purpose: I generate a xhtml fragment from a xml file via xslt. This is printed (echo) to the output (i.e. all xml/xsl processing is done on the server). This is fine, as long as the output contains only xhtml. problem: one special page uses AJAX,...
5
3486
by: Jason | last post by:
Hi all, Are you familiar with Safari? I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. When I test xsltProcessor, there is a error as following, I have dealt with this issue for several days, but there is no result. Could someone help me? <html> <head>
0
7698
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...
0
7612
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...
1
7673
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...
0
7970
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...
0
6284
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...
1
5513
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...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.