Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: conflicting operators

From: Sharon Steringa <esdeees@-------.--->
To: NULL
Date: 6/7/2004 1:04:00 AM
Okay, here goes: 
XML (snippet)goes by the name of "test.xml"
<?xml version="1.0" encoding="utf-8" ?>
<general>
	<data>
		<cols>
<fclient caption="Client" type="number" visible="True" />
<fid caption="Sleutelveld" type="number" visible="True" />
<fusername caption="Username" type="number" visible="True"/>
<fname caption="Naam" type="text" visible="True" />
<fcity caption="Woonplaats" type="text" visible="True" />
<fdebno caption="debiteurnr" type="number" visible="True" />
		</cols>
		<rows>
<row>
	<id value="226" />
	<fclient value="0" />
	<fid value="226" />
	<fusername value="153" />
	<fname value="KLMV B.V." />
	<fcity value="St. Annaparochie" />
	<fdebno value="153" />
</row>
<row>
	<id value="108" />
	<fclient value="0" />
	<fid value="108" />
	<fusername value="6" />
	<fname value="Afbouw Groep Groningen B.V." />
	<fcity value="Groningen" />
	<fdebno value="6" />
</row>
<row>
	<id value="230" />
	<fclient value="0" />
	<fid value="230" />
	<fusername value="155" />
	<fname value="De Boer Delft Transport B.V." />
	<fcity value="Delft" />
	<fdebno value="155" />
</row>
<row>
	<id value="231" />
	<fclient value="0" />
	<fid value="231" />
	<fusername value="156" />
        <fname value="Vriesoord B.V." />
	<fcity value="'s-Hertogenbosch" />
	<fdebno value="156" />
</row>
<row>
	<id value="235" />
	<fclient value="0" />
	<fid value="235" />
	<fusername value="154" />
	<fname value="Jac.Molenaar &amp; Zn B.V." />
	<fcity value="Broek op Langedijk" />
	<fdebno value="154" />
</row>
<row>
	<id value="236" />
	<fclient value="0" />
	<fid value="236" />
	<fusername value="157" />
	<fname value="Transportbedrijf van Straalen" />
	<fcity value="Hoogkarspel" />
	<fdebno value="157" />
</row>
<row>
	<id value="239" />
	<fclient value="0" />
	<fid value="239" />
	<fusername value="158" />
	<fname value="Bok B.V." />
	<fcity value="Goor" />
	<fdebno value="158" />
</row>
<row>
	<id value="110" />
	<fclient value="0" />
	<fid value="110" />
	<fusername value="9" />
	<fname value="NVO Transport B.V." />
	<fcity value="Groningen" />
	<fdebno value="9" />
</row>
		</rows>
	</data>
</general>

XSL: (based on an example by RDCPro)called "render.xsl"

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        xmlns:dates="urn:rdcpro-com:dates">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:param name="username" select="general/data/rows/row"/>
<xsl:param name="field1" select="'fclient'"/>
<xsl:param name="filter1"select="$username/fclient/@value"/>
<xsl:param name="field2" select="'fcity'"/>
<xsl:param name="filter2" select="$username/fcity/@value"/>
<xsl:param name="direction">ascending</xsl:param>
<xsl:param name="sortBy">fusername</xsl:param>

<!--HERE'S THE PART I'M WORKING ON  -->
<xsl:variable name="tableData">
<xsl:apply-templates select="general/data/rows/row/*[name()=$field1 and
(@value=$filter1 or starts-with(@value,$filter1))]/../*[name()=$field2
and (@value!=$filter2 or not(starts-with(@value,$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="$direction"/>
    <br/>
Sort Column: 
<xsl:value-of select="$sortBy"/>
</div>
<table border="1" class="results" align="center" cellpadding="5"
cellspacing="0">
<tr><th>
<a class="clickanchor" onclick="renderData('fclient');">
<xsl:value-of select="cols/fclient/@caption"/>
</a></th><th>
<a class="clickanchor" onclick="renderData('fid');">
<xsl:value-of select="cols/fid/@caption"/>
</a></th><th>
<a class="clickanchor" onclick="renderData('fusername');">
<xsl:value-of select="cols/fusername/@caption"/>
</a></th><th>
<a class="clickanchor" onclick="renderData('fname');">
<xsl:value-of select="cols/fname/@caption"/>
</a></th><th>
<a class="clickanchor" onclick="renderData('fcity');">
<xsl:value-of select="cols/fcity/@caption"/>
</a></th><th>
<a class="clickanchor" onclick="renderData('fdebno');">
<xsl:value-of select="cols/fdebno/@caption"/>
</a></th></tr>

<xsl:apply-templates select="msxsl:node-set($tableData)/row">
<xsl:sort select="*[name()=$sortBy]" order="{$direction}"/>
</xsl:apply-templates>
</table></div>
</xsl:template>
<xsl:template match="row">
<tr>
<xsl:for-each select="*">
<td>
<xsl:value-of select="./@value"/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="row" mode="tableData">
<xsl:copy>
<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:stylesheet>

And I have an HTMLpage which displays this data in a table. The page
also contains two select boxes to select a column to filter on, and two
textboxes to fill in the filtervalue. Here's the code (also based on
RDCPro example): 
<html><head>
<script language="JavaScript">
//Global variables
	var strXSLFileName,strXMLFileName;
	var objXMLDoc, objXSLDoc, objXSLTemplate;
	var currentSortDirection = "ascending";
	var currentSortCol = "";

//HARDCODED VALUES-------------------
  	   strXMLFileName="test.xml";	// XML Data
	   strXSLFileName="Render.xsl"; // XSL to build table
	//---------------------------------

function DoInit()
{
	objXMLDoc = new ActiveXObject("MSXML2.DomDocument");
	objXMLDoc.async = false;
	objXMLDoc.setProperty("SelectionLanguage", "XPath");
	objXMLDoc.resolveExternals = false;
	objXMLDoc.validateOnParse = false;
	objXMLDoc.load(strXMLFileName);

	objXSLDoc = new ActiveXObject
("MSXML2.FreeThreadedDomDocument");
	objXSLDoc.async = false;
	objXSLDoc.resolveExternals = false;
	objXMLDoc.validateOnParse = false;
	objXSLDoc.load(strXSLFileName);
    objXSLTemplate = new ActiveXObject("MSXML2.XSLTemplate");
	objXSLTemplate.stylesheet = objXSLDoc;

	renderData('fusername');
}


function renderData(strSort)
{
	var objXSLProcessor;
	objXSLProcessor = objXSLTemplate.createProcessor();
	objXSLProcessor.input = objXMLDoc;


	// Toggle the sort direction only if necessary
	if (strSort == currentSortCol)
	{
		//strSort is CurrentSortCol
		if (currentSortDirection =="descending")
		{
			currentSortDirection = "ascending";
		}
		else
		{
			currentSortDirection = "descending";
		}
	}
	else
	{
		//strSort is NOT CurrentSortCol
		currentSortCol = strSort;
		currentSortDirection = currentSortDirection;
	}

	//Process Params

	// Pass the values to the XSL 
if (frmMain.filter1txt.value != "All")
    {
    	if (frmMain.seFilter1.value !="")
        {
	var text1 = frmMain.filter1txt.value;
        var sel1 = frmMain.seFilter1.value;
	objXSLProcessor.addParameter("filter1", text1);
	objXSLProcessor.addParameter("field1", sel1)
		}
    }

        if (frmMain.filter2txt.value != "All")
	{
    	if (frmMain.seFilter2.value !="")
        {
	var text2 = frmMain.filter2txt.value;
	var sel2 = frmMain.seFilter2.value;
        objXSLProcessor.addParameter("filter2", text2);
	objXSLProcessor.addParameter("field2", sel2)
        }
	}
	objXSLProcessor.addParameter("sortBy",strSort);
	objXSLProcessor.addParameter("direction",currentSortDirection);
	objXSLProcessor.transform();
	Results.innerHTML = objXSLProcessor.output;
}

function toggleDirection(strSort)
{
	if (strSort == currentSortCol)
	{
		//alert("strSort is CurrentSortCol");
		if (currentSortDirection =="descending")
		{
			currentSortDirection = "ascending";
		}
		else
		{
			currentSortDirection = "descending";
		}
	}
	else
	{
		//alert("strSort is NOT CurrentSortCol");
		currentSortCol = strSort;
		currentSortDirection = currentSortDirection;
	}
}

window.onload=DoInit;
</script>
</head>
<body marginheight="0" leftmargin="0" marginwidth="0" topmargin="0" >
<form name="frmMain">
<table align="center" id="Table1" width="600px"">
<tr>
<td align="left" colspan="2">Filter de data op (case-sensitive,
beginletter(s) of hele woord):
<table>
<tr><td>Kolom 1:</td><td>
<SELECT NAME="seFilter1">
<OPTION VALUE=""></OPTION>
<OPTION VALUE="fclient">client</OPTION>
<OPTION VALUE="fid">sleutelveld</OPTION>
<OPTION VALUE="fusername">username</OPTION>
<OPTION VALUE="fname">naam</OPTION>
<OPTION VALUE="fcity">woonplaats</OPTION>
<OPTION VALUE="fdebno">debiteurnr</OPTION>
</SELECT>
</td><td>Waarde is:</td><td>
<input type="text" name="filter1txt" value="All"><br>
</td></tr><tr><td>Kolom 2:</td><td>
<SELECT NAME="seFilter2">
<OPTION VALUE=""></OPTION>
<OPTION VALUE="fclient">client</OPTION>
<OPTION VALUE="fid">sleutelveld</OPTION>
<OPTION VALUE="fusername">username</OPTION>
<OPTION VALUE="fname">naam</OPTION>
<OPTION VALUE="fcity">woonplaats</OPTION>
<OPTION VALUE="fdebno">debiteurnr</OPTION>
</SELECT>
</td><td>Waarde is NIET:</td><td>
<input type="text" name="filter2txt" value="All"><br>
</td></tr></table>
<input type="button" name="Filter" value="Filter" onclick="var sTemp =
currentSortCol;currentSortCol='';renderData(sTemp)">
<input type="button" name="Reset" value="Reset"
onclick="frmMain.filter1txt.value='All';frmMain.filter2txt.value='All';f
rmMain.seFilter1.value='';frmMain.seFilter2.value=''; var sTemp =
currentSortCol;currentSortCol='';renderData(sTemp)">
</td></tr><tr><td colspan="2" id="Results"></td>
</tr><tr><td colspan="2"></td></tr></table></form>
</body></html>

So I want the second selectbox and textbox to be a negative filter. The
negative filtering works, but the starts-with() function does not. I
want to be able to fill in only part of the filtervalue, so for example
when I select 'woonplaats' and fill in 'G' in the textbox, I get the two
records with woonplaats "Groningen" and the one with woonplaats "Goor".
This works for the first filter, but not for the negative one. Hope you
can help me, thanks in advance! Sharon

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent