Re: Re: [xsl] Multiple select listbox as parameter

Subject: Re: Re: [xsl] Multiple select listbox as parameter
From: <mfreeman@xxxxxxxxxxxx>
Date: Fri, 10 Mar 2006 12:43:36 -0500
Thanks for the reply Joe.  You have certainly maxed out my XSLT abilities.

Anyway, I added your code to my HTML file and for all your functions that set a new ActiveXObject, I get the following error:

'Automation server can't create object'

Originally I had all the ActiveXObjects set to MSXML2.FreeThreadedDOMDocument, so I tried that, but it crashed when I tried to set oParams.loadXML.

It sounds like I have some other problems here than just passing the parameter, huh?

> 
> From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
> Date: 2006/03/10 Fri AM 11:10:42 EST
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Subject: Re: [xsl] Multiple select listbox as parameter
> 
> ----- Original Message ----- 
> From: <mfreeman@xxxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Friday, March 10, 2006 1:11 PM
> Subject: [xsl] Multiple select listbox as parameter
> 
> 
> > Hi all.  I could really use some help...
> >
> > My XML looks like this:<?xml version='1.0'?>
> > <Data>
> >     <Indicator KEY='001'>
> >           <Group Key='001'/>
> >           <Group Key='005/>
> >     </Indicator>
> >     <Indicator KEY='002'>
> >          <Group KEY='003'/>
> >          <Group KEY='002'/>
> >     </Indicator>
> >     <Indicator KEY='003'>
> >          <Group KEY='004'/>
> >          <Group KEY='003'/>
> >     </Indicator>
> > </Data>
> >
> >
> > I have a list box, where you can select multiple Groups.  If I select
> > groups 002 and 001, it should return Indicators 001 and 002.  The
> > paramater that I pass is 001,002,.  So from my XSL, I tried two things.
> > First was to see if the parameter contained the key:
> >
> >
> > <xsl:for-each select="Indicator">
> > <xsl:when test="contains($lstGroup,Group/@KEY)">
> >  ...do something...
> > </xsl:when>
> > <xsl:for-each>
> >
> >
> > This worked great, but only if the first group matched the criteria.
> > So it returns just indicator 001.
> >
> >
> > Then I tried this:
> >
> >
> > <xsl:for-each select="Indicator">
> > <xsl:when test="Group[@KEY=$lstGroup]">
> >  ...do something...
> > </xsl:when>
> > <xsl:for-each>
> >
> >
> > And this works great, except it will not accept a multiple list from
> > the list box.  Only when I pass one choice to the paramater.
> >
> >
> > I tried this:
> >
> >
> > <xsl:for-each select="Indicator">
> > <xsl:when test="contains($lstGroup,Group[@KEY])">
> >  ...do something...
> > </xsl:when>
> > <xsl:for-each>
> >
> >
> > But this returned all indicators.
> >
> >
> > Is there a way to combine the two working bits of code to do what I
> > want to do?  It may be in the way I call the parameter, or it may be in
> > the output code.  Here's how I call the parameter from a multiselect
> > list box:
> >
> >
> > (This is on my HTML page)
> > var as Values = New Array();
> > var oSel = document.sel.lstGroup;
> > var strGroup1 = ""
> > for (var i-0; i<oSel.length;i++)[
> >     if (oSel.options[i].selected){
> >          asValues[asValues.length]=oSel.options[i].value;
> >          strGroup1=strGroup1 + oSel.options[i].value + ",";
> >     }
> >
> >
> > }
> >
> >
> > xslproc.addparameter("lstGroup",strGroup1,"");
> >
> > This passes '001,002,' to my xsl page.
> >
> > Here is the full version of all of the code.
> >
> > http://www.comptrex.com/eed/EED.htm
> >
> >
> > I also noticed since I put it up, that it's unbearably slow.  Any
> > suggestions for that?
> >
> >
> >
> >
> > Any help is greatly appreciated.
> > Thanks,
> >
> >
> >
> >
> >
> You should pass a nodelist to the addParameter method.
> Something like:
> **********GetGroups.xml************
> <Data>
> <Indicator KEY='001'>
> <Group KEY='001'/>
> <Group KEY='005'/>
> </Indicator>
> <Indicator KEY='002'>
> <Group KEY='003'/>
> <Group KEY='002'/>
> </Indicator>
> <Indicator KEY='003'>
> <Group KEY='004'/>
> <Group KEY='003'/>
> </Indicator>
> </Data>
> 
> ******************************
> ***********GetGroups1.xslt*******
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:param name="lstGroup"/>
> <xsl:template match="/Data">
> <Indicators>
> <xsl:apply-templates select="Indicator[Group/@KEY = $lstGroup]"/>
> </Indicators>
> </xsl:template>
> <xsl:template match="Indicator">
> <xsl:copy-of select="."/>
> </xsl:template>
> </xsl:stylesheet>
> ******************************
> var _oFTDom = null;
> function getSyncFTDom()
> {
> if(!_oFTDom)
> {
> _oFTDom = new ActiveXObject("Msxml2.FreeThreadedDomDocument.4.0");
> }
> return _oFTDom.cloneNode(false);
> }
> var _oDom = null;
> function getSyncDom()
> {
> if(!_oDom)
> {
> _oDom = new ActiveXObject("Msxml2.DomDocument.4.0");
> }
> return _oDom.cloneNode(false);
> }
> 
> var _oFTTemplate = null;
> function getFTTemplate()
> {
> if (!_oFTTemplate)
> {
> _oFTTemplate = new ActiveXObject("Msxml2.XSLTemplate.4.0");
> }
> return _oFTTemplate;
> }
> function main()
> {
> var oSource = getSyncDom();
> oSource.load("GetGroups.xml");
> var oStyle = getSyncFTDom();
> oStyle.load("GetGroups1.xslt");
> var oTemplate = getFTTemplate();
> oTemplate.stylesheet = oStyle;
> var oProc = oTemplate.createProcessor();
> oProc.input = oSource;
> var arrGroupKeys = ["001", "002"];
> var oParams = getSyncDom();
> oParams.loadXML("<KEYS/>");
> for (var i = 0; i < arrGroupKeys.length; i++)
> {
> (oParams.documentElement.appendChild(oParams.createElement("KEY"))).text = 
> arrGroupKeys[i];
> }
> oProc.addParameter("lstGroup", oParams.documentElement.selectNodes("KEY"));
> oProc.transform();
> alert(oProc.output);
> }
> main();
> 
> -- 
> 
> 
> Joe 

Current Thread