Re: [xsl] Re:Re:How to simplify the xslt expression for multiple conditions.

Subject: Re: [xsl] Re:Re:How to simplify the xslt expression for multiple conditions.
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 28 May 2001 21:57:43 +0100
Hi Sun-fu,

> As your suggestion, I use two step approach to render the xml file,
> the frist one is to filter out the data based on a set of multiple
> condition and stored in a RTF. Then Using the RTF to diplay the
> content. Because there are couple of hundred lines, I apply Chris
> Bayes paging example to get the paging capability. During each
> paging process, I try to repeat using RTF, not the original xml file
> to process the output. However I can not get any further and hope
> you can provide some direction from here.

OK, for each page, you want to be transforming the same (filtered) set
of XML.  To pass the XML that you're using from one page to the next,
you need to serialise it and use it as the source of the
transformation to get the next page.

The changePage function takes an XML string as the second argument
(ignore the fact that it's called "xmlfile" - it's used as an XML
string, loaded with loadXML() rather than load()). In the function,
this XML is loaded into a document to create a DOM, and then
transformed:

   function changePage(number, xmlfile, xslfile){
      XMLDOM = new ActiveXObject('Msxml2.FreeThreadedDOMDocument');
      XMLDOM.async = false;
      XMLDOM.loadXML(xmlfile);
      ...
      XSLTProcessor.input = XMLDOM;
      ...
   }

So you can call it with something like:

  changePage(2, '<foo>...</foo>', 'style.xsl')

and it will show you page 2 of the source XML you're passing as the
second argument.

So, in the call to changePage(), you need to pass the serialised XML
that you want to transform as the second argument.  You don't show the
part where you do it; it needs to looks something like:

  changePage(<xsl:value-of select="$pagenumber + 1" />,
             '<xsl:call-template name="js-escape">
                <xsl:with-param name="string">
                   <xsl:call-template name="serialiseXML">
                      <xsl:with-param name="originalDoc"
                                      select="/" />
                   </xsl:call-template>
                </xsl:with-param>
              </xsl:call-template>',
             'style.xsl');

Note that the serialised XML has to be escaped so that it's correctly
parsed as a Javascript string.

In fact, since you *always* want the second argument to be this
particular set of XML, you could hardcode it into the definition of
the Javascript function rather than pass it as a variable.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread