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: Wed, 30 May 2001 10:47:06 +0100
Hi Sun-fu,

> 1 The js-escape template seems to omit the xml-declaration while
> producing the serialised XML. Since a part of xml is related to BIG5
> , I must have this PI built in, such as <?xml version="1.0"
> encoding="big5"?> What is remedy to js-escape template?

This is to do with the serialiseXML template (whose results are sent
as a parameter to the js-escape template).  I'm afraid that I'm at a
bit of a loss when it comes to how you should be using the XML
declaration at this point, as the XML string that you're creating is a
JavaScript string, and the encoding that you declare in the XML
declaration within it shouldn't (I think) make much of a difference.
If you do need to add one, you could try adding the template:

<xsl:template match="/" mode="serialise">
   <xsl:text>&lt;xml version="1.0" encoding="big5"?></xsl:text>
   <xsl:apply-templates mode="serialise" />
</xsl:template>

It's more likely that the problem is that the simple serialisation
templates won't escape any characters using character entities, which
is something you might need to do. You could try looking at the
serialisation templates that Evan Lenz announced recently
(http://xmlportfolio.com/xml-to-string/) - I haven't looked at them,
but they may be more sophisticated and able to handle escaping.

Otherwise, unless someone else can come up with a better idea, you're
probably going to have to rework your approach.  Rather than having a
serialised string in the output, you could have an XML 'data island'
in the HTML page that you access and transform when you need to.
Chris Bayes will be able to help you with that...

> 2. It seems to me there is size limitation when using serialized XML
> as javascript augument. To prove this point, I keep adding **line**
> element into xml file. At certain point, the page change function
> becomes unfunctional and look like to be locked. Could you see what
> is caused. xml, xsl are listed below for fyi.

Could well be - might be a limit on the JavaScript string size.  I'm
afraid I don't see a way around that.

Actually I'm tempted to say that you should modify your application on
a wider scale.  Rather than having some large piece of XML that you
filter, and then trying to pass the filtered XML around, retrieve and
use the filtered piece of XML all the time - have it as a file on your
file system, or have a server-side script that generates it rather
than trying to do everything on the client.

>>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 have a hard time to understand what is the phrase saying: ** you
> could the hardcode it into the definition of .... *** Are you
> suggesting that once I loadXML xml doc., and saved it as a global
> variable, then when doing the sequent paging, only I have to do is
> to use .addparam for new page number and display the output.

Yes. The point of functions taking arguments is that the arguments
change each time they're called. When you use the changePageXML
function, you are always passing the same value for the second
argument (the XML string) and the third argument (the XSLT
stylesheet). Rather than having them as arguments, you could fix them
as global variables or within the function definition. So rather than:

   function changePageXML(number,xmlfile,xslfile,pageParam,space) {
      ...
   }

You could have:

   xmlfile = '...';
   xslfile = '...';

   function changePageXML(number, pageParam, space) {
      ...
   }

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