XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + get the current position as pa... (2)
-> - unable to get Parameter from x... (1)
-> + get key value from xslt to jav... (2)
-> + Xpath insensitive search? (3)
-> + relative path 2 (10)
-> + sum and group attrs, list only... (3)
-> - Simple multiplication.... but ... (1)
-> + .NET issue (2)
-> + Grouping items (9)
-> + Group Move (4)
-> + Problem with DateTime manipula... (2)
-> + xls fo positioning in block (2)
-> - Filtering with XSLT not workin... (3)
-> ->Filtering with XSLT not w...
-> ->Filtering with XSLT not w...
-> + Petri net to BPEL model transf... (3)
-> + Selecting specific child eleme... (2)
-> + Grouping and summing ... (3)
-> + XSL-FO question: can't get ext... (2)
-> + for each with a parallel nodel... (3)
-> + unable to load schmea with tar... (5)
-> + Translating svg path data to x... (5)
-- Previous [1321-1340] [1341-1360] [1361-1380] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Sharon SteringaSubject: Filtering with XSLT not working anymore
Author: Sharon Steringa
Date: 04 Sep 2006 10:23 AM
Hi everyone!
I have a problem with my XSLT-filtering function: it has stopped working as perfectly as it did a couple of weeks ago and now only returns a blank screen!

The situation:
A context menu in a table on my website gives options to apply a.o. negative and positive filtering on the value of the item clicked. For instance, you right-click the cell displaying the value 'Pig', choose 'Filter on 'Pig'' and the javascript below is activated (modified version of the Bayes tutorial).

Then the transform should take place, as it has done perfectly so many times before... but then a couple of weeks ago I noticed that it didn't work anymore. Since I didn't change a thing in either my javascript, XML or XSL, my guess was that some IE update causes this problem...(on some computers, there is no problem) But then more people should have this problem, yet I couldn't find anything about it on the web. If anyone knows if there's something wrong with my code, or if I can do anything to solve the problem, I would like to hear! Thanks a lot, Debbie.
--------------------------------------------------------------------
function renderData(filterField, filterValue, mode) {
try{
var x = document.XMLDocument;
if (x==null)
{x = navivator.XMLDocument};
var s=loadsheet(mode);
var tem = new ActiveXObject("MSXML2.XSLTemplate.3.0");
tem.stylesheet = s;
var proc = tem.createProcessor();
proc.addParameter('field1',filterField);
proc.addParameter('filter1',filterValue);
proc.input = x;
proc.transform();
var str = proc.output;
var newDoc = document.open("text/html");
newDoc.write(str);
navigator.XMLDocument = x;
navigator.XSLDocument = s;
newDoc.close();
}catch(exception){
}
}
--------------------------------------------------------------------
(loadsheet is a function choosing the appropriate XSL depending on the filter mode (pos, neg) and loading it in a FreeThreadedDOMDocument.3.0)

Here's an example of an XML to be transformed (even the simplest one-column table like this one leaves a blank screen):
--------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<?xml:stylesheet type="text/xsl" href="/lib/xtable/xTable.xsl"?>
<general>
<Appname value=""/>
<data>
<global>
<orderby value=""/>
<clientno value="/lib/xtable/css/0.css"/>
<created value="4-9-2006 11:18:50"/>
</global>
<cols><fdescription caption="Description" color="" width="100" type="text" visible="True"/></cols>
<rows>
<row>
<id value="68"/>
<fdescription value="Clients from Art Systems"/>
<fdatasetname value="CLIENT"/>
<fid value="68"/>
<fdataset value="68"/>
</row>
<row>
<id value="10"/>
<fdescription value="Datasets"/>
<fdatasetname value="DATASET"/>
<fid value="10"/>
<fdataset value="10"/>
</row>
<row>
<id value="12"/>
<fdescription value="Datatypes"/>
<fdatasetname value="DATATYPE"/>
<fid value="12"/>
<fdataset value="12"/>
</row>
<row>
<id value="11"/>
<fdescription value="Fields"/>
<fdatasetname value="FIELDS"/>
<fid value="11"/>
<fdataset value="11"/>
</row>
<row>
<id value="4"/>
<fdescription value="Fieldsettings"/>
<fdatasetname value="FIELDSETTINGS"/>
<fid value="4"/>
<fdataset value="4"/>
</row>
<row>
<id value="5"/>
<fdescription value="Users"/>
<fdatasetname value="USERS"/>
<fid value="5"/>
<fdataset value="5"/>
</row>
</rows>
</data>
<literal_xhtml_footer>
</literal_xhtml_footer>
</general>
--------------------------------------------------------------------

and here's the XSL I use to filter positively (field1 and filter1 are where the parameters are added):

--------------------------------------------------------------------
<xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml" version="1.0" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:decimal-format name="european" decimal-separator="," grouping-separator="."/>
<xsl:param name="data" select="general/data/rows/row"/>
<xsl:param name="cols" select="general/data/cols/*" />
<xsl:param name="sortfield" select="$field1"/>
<xsl:param name="datatype" select="general/data/cols/*[name()=$sortfield]/@type"/>
<xsl:param name="field1" select="'fdescription'"/>
<xsl:param name="filter1" select="'Fields'"/>
<xsl:param name="sortorder" select="'ascending'"/>
<xsl:param name="selectedid" select="$filter1"/>
<xsl:param name="customcss" select="general/data/global/clientno/@value" />
<xsl:variable name="visible-cols" select="$cols[@visible = 'True']"/>
<xsl:variable name="filterData">
<xsl:copy-of select="/general/data/cols"/>
<xsl:apply-templates select="$data/*[name()=$field1 and (translate(@value,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=translate($filter1,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))] /.." mode="filterData"/>
</xsl:variable>

<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="{$customcss}"/>
<script src="/lib/js/as.js">
</script>
<script src="/lib/xtable/xTable.js">
</script>
</head>
<body onload_="rowClick({$selectedid});" onkeydown_="bodyKeyDown();">
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="data">
<div class="header">
<xsl:copy-of select="./literal_xhtml_header"/>
</div>
<!--top bar-->
<form method="post">
<table class="head">
<tr>
<!-- header, column titles-->
<xsl:call-template name="head"/>
</tr>
</table>
<div class="scroll">
<table>
<!--data, columns-->
<xsl:call-template name="cols"/>
<!--sorting-->
<xsl:choose>
<xsl:when test="$datatype = 'date'">
<!--date sorting-->
<xsl:apply-templates select="msxsl:node-set($filterData)/row">
<xsl:sort select="translate(*[name()=$sortfield]/@value,'T-:','')" order="{$sortorder}" data-type="number"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="msxsl:node-set($filterData)/row">
<xsl:sort select="*[name()=$sortfield]/@value" order="{$sortorder}" data-type="{$datatype}"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</table>
</div>
<div class="footer">
<xsl:copy-of select="../literal_xhtml_footer"/>
</div>
</form>
</xsl:template>

<xsl:template name="head">
<xsl:for-each select="$visible-cols">
<th style="width: {@width};">
<li class="nosort" onclick_="filterClick();" href="{name()}">
<xsl:if test="name()=$sortfield">
<xsl:attribute name="class">
<xsl:value-of select="$sortorder"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@caption"/>
</li>
</th>
</xsl:for-each>
</xsl:template>

<xsl:template name="cols">
<xsl:for-each select="$visible-cols">
<colgroup span="1" style="width: {@width}; background-color: {@color};"/>
</xsl:for-each>
</xsl:template>


<xsl:template match="row">
<tr onclick_="rowClick();" href="{count(/row)}" id="{id/@value}" ondblclick_="DoubleClick();" onkeydown_="bodyKeyDown();">
<xsl:for-each select="*">
<xsl:if test="/cols/*[name()=name(current())]/@visible='True'">
<xsl:choose>
<xsl:when test="/cols/*[name()=name(current())]/@type='date'">
<td onmousedown_="cellClick();" href1="{name()}" href2="{/cols/*[name()=name(current())]/@caption}" href3="{/cols/*[name()=name(current())]/@type}">
<xsl:if test="./@value!=''">
<xsl:value-of select="substring-after(substring-after(substring-before(./@value,'T'),'-'),'-')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring-before(substring-after(substring-before(./@value,'T'),'-'),'-')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring-before(./@value,'-')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(./@value,'T')"/>
</xsl:if>
</td>
</xsl:when>
<xsl:when test="/cols/*[name()=name(current())]/@type='text'">
<td onmousedown_="cellClick();" href1="{name()}" href2="{/cols/*[name()=name(current())]/@caption}" href3="{/cols/*[name()=name(current())]/@type}">
<xsl:value-of select="./@value"/>
</td>
</xsl:when>
<xsl:otherwise>
<td onmousedown_="cellClick();" href1="{name()}" href2="{/cols/*[name()=name(current())]/@caption}" href3="{/cols/*[name()=name(current())]/@type}" href4="{format-number(sum(/row/*[name()=name(current())]/@value[boolean(sum(.))]),'#.###.###,##','european')}">
<xsl:value-of select="./@value"/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="row" mode="filterData">
<xsl:copy>
<xsl:copy-of select="id"/>
<xsl:for-each select="*">
<xsl:if test="/general/data/cols/*[name()=name(current())]/@visible='True'">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template match="literal_xhtml_footer"/>
<xsl:template match="literal_xhtml_header"/>
</xsl:stylesheet>
--------------------------------------------------------------------

Postnext
Minollo I.Subject: Filtering with XSLT not working anymore
Author: Minollo I.
Date: 04 Sep 2006 03:27 PM
Sharon,
are you using Stylus Studio? What version? (Help > About) Under which name/email can we retrieve your registration?

Thanks.

Posttop
Sharon SteringaSubject: Filtering with XSLT not working anymore
Author: Sharon Steringa
Date: 06 Sep 2006 02:04 PM
Since I'll do anything to get some help I have ignored my initial reaction and have downloaded a trial version of the XML home edition 2006, edition 3. If you click on my name above my message, you'll see my email, unless this is a spam message of course which would make me look rather silly for replying... :-)
Thanks!

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.