473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Creating Xpath Dynamically

Hi All,
I want to build the xpath expression dynamically in the xsl for for-each.
Scenario is like this::
1. From javascript I am sending the parameters to xsl.
2. In xsl I am taking those parameters
Now I want to use this parameters to build the xpath, but I might
get some of the values as null, so in that case I must eliminate
the null values.

And now the solution for this, is, dynamically building the
xpath expression for "for-each".

Following is my javascript::

function LoadProjects(){
var name= window.parent.importParamone.sortBy.value;
var xslProc;
var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.load("..//Repository//testNew.xml");
var xsl = new ActiveXObject("MSXML2.FreeThreadedDomDocument.3.0" );
xsl.async = false;
xsl.load("loadData.xsl");
var template = new ActiveXObject("MSXML2.XSLTemplate");
template.stylesheet = xsl;
processor = template.createProcessor();
processor.input = xml;
processor.addParameter("sortBy", name);
processor.addParameter("filterNo", '12313'); processor.addParameter("filterName", '5.1'); processor.transform();
document.open();
document.write(processor.output);
document.close();
//document.write(xml.transformNode(xsl));
}


In the above we are sending filterNo and filterName to xsl

Now here is my xsl


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="sortBy"/>
<xsl:param name="filterNo"/>
<xsl:param name="filterName"/>
<xsl:param name="filterCondition"/>
<xsl:template match="/">
<html>
<head>
<link href="netAppsCss.css" rel="stylesheet" type="text/css" />
<link href="scroll_css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<xsl:for-each select="user/Employee[ProjectNumber=$filterNo]"> <xsl:sort select="*[name()=$sortBy]"/>
<tr>
<td class="tableData"><xsl:value-of select="ProjectNumber" /></td>
<td class="tableData"><xsl:value-of select="ProjectName"/></td>
<td class="tableData"><xsl:value-of select="TaskNumber" /></td>
<td class="tableData"><xsl:value-of select="TaskName" /></td>
<td class="tableData"><xsl:value-of select="Customer" /></td>
<td class="tableData"><xsl:value-of select="SoNumber" /></td>
<td class="tableData"><xsl:value-of select="SoLine" /></td>
<td class="tableData"><xsl:value-of select="TaskManager" /></td>
<td align="center" class="tableData" style="border-right:solid 1px #023183">
<input type="checkbox" name="checkbox" value="select" onclick="checkAlert(this)" /></td>
</tr>
</xsl:for-each>
</body>
</html>
</xsl:template></xsl:stylesheet>

and now in the above I am using only one filter condition, but when I
use multiple parameters like this.


<xsl:for-each select="user/Employee[ProjectNumber=$filterNo and ProjectNumber=$filterName]">

It is not working...................anyone please..................
Feb 20 '07 #1
2 2060
dorinbogdan
839 Expert 512MB
Did you mean:
<xsl:for-each select="user/Employee[ProjectNumber=$filterNo and ProjectName=$filterName]"> ?

instead of

<xsl:for-each select="user/Employee[ProjectNumber=$filterNo and ProjectNumber=$filterName]">

If yes, and if not working, try to use:
<xsl:for-each select="user/Employee[ProjectNumber=$filterNo] and user/Employee[ProjectName=$filterName]">
Feb 22 '07 #2
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Murtaza Tinwala | last post by:
Hi mates, I have the following problem in XSLT. I have following variables: ref-file = <path of XML document> eg "xmlDoc.xml" repeatpath = <a repeat path expressed in Xpath like /root/person >...
1
by: FaensenD | last post by:
Consider the following XML document <root> <PersonStreet>24 Miller Street</PersonStreet> <PersonZIP>12345</PersonZIP> <PersonCity>Munich</PersonCity> <CompanyStreet>24 Miller...
7
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
1
by: Chris Kennedy | last post by:
How do create a dataset from scratch based on an XML schema. This will not be filled by a dataadapter. It will be a dataset which I add rows to and then save as an XML file. All the example depend...
2
by: sprungli | last post by:
My goal is to select some XPath nodes based on whether their values (text) contain a string passed as argument. To achieve this I use the contains() function of XPath in an XpathExpression. For...
0
by: Mark Broadbent | last post by:
can someone help me? After creating an xml schema file in VS 2003, I drag and drop a table onto it to create its schema. However what I am getting is a document element encapsulating the actual...
0
by: Mark Broadbent | last post by:
(firstly sorry Ive cross posted this in C# forum also -I forgot to include this ng) can someone help me? After creating an xml schema file in VS 2003, I drag and drop a table onto it to create...
6
by: dotnetnoob | last post by:
i would like to know how i can build xpath expression dynamiclly. let's say i have a following xml file: <EventEnrollment InstanceNumber = "675"> <EventSource> <ObjectReference...
1
by: Yossi | last post by:
Nice tool! I am looking for something that will do the reverse. I have a whole bunch of XPath statements and I need to use them to generate and populate an XML document. I have mapping file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.