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 16th, 2006, 02:19 PM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems passing XPATH as a paramater to for-all

I have the following javascript function that passes xpath information as a variable to my stylesheet. I get no error messages, but transformation only process everything above my for-all select="msxml:node-set($query)" entry. It's as if it's not processing the nodeset. Can anyone tell me why?

xslt stylesheet
-----------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:param name="querystring" select="opportunity/record"/>
<xsl:template match="/">
<html>
<body>
<table border="1">
<tr>
<th>ID</th>
<th>Customer</th>
<th>Lead</th>
<th>BUs</th>
<th>Offer Type</th>
<th>$ Current Year (1000's)</th>
<th>Estimated Value (1000's)</th>
<th>Stage</th>
<th>Prob %</th>
<th>Est Close</th>
<th>Sales Review Status</th>
</tr>
<xsl:for-each select="msxsl:node-set($querystring)">
<tr>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="weblink"/>
</xsl:attribute>
<xsl:value-of select="smsid"/>
</a>
</td>
<td><xsl:value-of select="companyname"/></td>
<td><xsl:value-of select="clientmanagerlit"/></td>
<td><xsl:value-of select="businessunit"/></td>
<td><xsl:value-of select="dealtypelit"/></td>
<td><xsl:value-of select="valuedolcytotal"/></td>
<td><xsl:value-of select="value"/></td>
<td><xsl:value-of select="statuslit"/></td>
<td><xsl:value-of select="probability"/></td>
<td><xsl:value-of select="closedate"/></td>
<td><xsl:value-of select="comments"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

xml File
------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>

- <opportunity>


- <record>


  <smsid>6J7LC3</smsid>

  <closedate time="02:35:39 PM">01/04/2006</closedate>

  <closeyr>2006</closeyr>

  <closeqtr>Q1</closeqtr>

  <statusnum>7</statusnum>

  <status>implement</status>

  <statuslit>Implemented</statuslit>

  <companyname>Icaro</companyname>

  <wipcadence>n</wipcadence>

  <dealtypelit>EMP</dealtypelit>

  <dealcategory>SrvSol</dealcategory>

  <enginefamily>JTRE8D</enginefamily>

  <cadenceofferdetail>EMP - 3438D-17A</cadenceofferdetail>

  <salesspecialist clocknum="eng" org="p&w">frank h Doe</salesspecialist>

  <salesspeclit>Albert</salesspeclit>

  <lead>Sales Spec</lead>

  <clientmanager clocknum="m304433" org="Q&S">John Tester</clientmanager>

  <clientmanagerlit>Tester</clientmanagerlit>

  <datedealstarted>12/15/2005</datedealstarted>

  <value>28</value>

  <valuedolcytotal>0</valuedolcytotal>

  <probability>100</probability>

  <businessunit>-</businessunit>

  <productsector />

  <comments>Agreement sent on 11/30/05 and awaiting signature.</comments>

  <region>Americas</region>

  <weblink>/folder1/techmarket.nsf/0/C3947FC24BE151E1852570BB0055D7DB?opendocument</weblink>

  </record>
</opportunity

Javascript
-----------------------
function passParameterToStylesheet(querystring){
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
var xslProc;
var result;

xslDoc.async = false;
xslDoc.resolveExternals = false;
xslDoc.load(xsl_page);
if(xslDoc.parseError.errorCode != 0) {showStyleError();}
xslt.stylesheet = xslDoc;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load(xml_page);
if(xmlDoc.parseError.errorCode != 0) {showSourceError();}
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.addParameter("querystring", querystring);
xslProc.transform();
document.all.item("resultset").innerHTML = xslProc.output;
}
 
Old January 16th, 2006, 02:51 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Some products have an xx:evaluate() function that takes an XPath expression in the form of a string, and evaluates it. But that's not what msxsl:node-set() does, as far as I am aware.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 16th, 2006, 03:38 PM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Excerpt from msdn.microsoft.com:

The node-set function enables you to convert a result tree fragment into a node set. The resulting node always contains a single node that is the root node of the tree. If you convert a result tree fragment to a node set, then you can use it anywhere a regular node set is used, such as in a for-each statement or in the value of a select attribute. The following line of code show the fragment being converted to a node set and used as a node set:

<xsl:for-each select="msxsl:node-set($node-fragment)">
 
Old January 19th, 2006, 03:40 PM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Since no one out there seemed to be able to help me. I was forced to try to come up with some sort of work-around. It is quite easy in fact. I tried grabbing a handle on the specicic parameter node I wanted, changed the parameters default value and transformed the xml document with the newly modified stylesheet WITHOUT passing in a parmater. This causes the processor to use the default value and voilla it works! I have posted the javascript below, because I know there are others out there who are looking to do the same type of thing.

javascript:

function ModifyStylesheetDefaultParamSetting(querystring){
var xslDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var result;
var xParam;

xslDoc.async = false;
xmlDoc.async = false;
xslDoc.load(xsl_page);
xmlDoc.load(xml_page);
xParam = xslDoc.selectSingleNode("/*/xsl:param[@name = \'querystring\']/@select");
xParam.value = querystring;
result = xmlDoc.transformNode(xslDoc);
document.all.item("resultset").innerHTML = result;
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with date paramater gregalb Reporting Services 1 January 15th, 2008 03:55 AM
Sum function and XPath problems tslag XSLT 2 June 26th, 2006 10:23 AM
problems with passing user input to a query boozin Classic ASP Databases 3 March 10th, 2004 05:59 PM
problems with xpath and matching templates Gero Meißner XSLT 3 August 16th, 2003 01:54 AM





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