[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Re: Measuring the (byte) size of an XSL output cha

Subject: RE: Re: Measuring the (byte) size of an XSL output chain on the fly
From: "Koes, Derrick" <Derrick.Koes@xxxxxxxxxxxxxxxx>
Date: Wed, 23 Jul 2003 17:26:15 -0400
byte in xsl
This counts characters which would be good for a single byte character
encoding.

-----Original Message-----
From: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx] 
Sent: Wednesday, July 23, 2003 5:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: Measuring the (byte) size of an XSL output chain on the
fly

This transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:output omit-xml-declaration="yes"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

 <xsl:template match="/">
   <xsl:variable name="vResult">
     <xsl:apply-templates/>
   </xsl:variable>

   Length of output is: <xsl:text/>
   <xsl:value-of select="concat(string-length($vResult), '&#xA;')"/>

   <xsl:if test="string-length($vResult) &lt;= 1800">
     <xsl:copy-of select="$vResult"/>
   </xsl:if>
 </xsl:template>

</xsl:stylesheet>


when applied on this source.xml:

<nums>
  <num>01</num>
  <num>02</num>
  <num>03</num>
  <num>04</num>
  <num>05</num>
  <num>06</num>
  <num>07</num>
  <num>08</num>
  <num>09</num>
  <num>10</num>
</nums>

produces the wanted result:

   Length of output is: 51
<nums>
  <num>01</num>
  <num>02</num>
  <num>03</num>
  <num>04</num>
  <num>05</num>
  <num>06</num>
  <num>07</num>
  <num>08</num>
  <num>09</num>
  <num>10</num>
</nums>



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Neil Smith" <neil@xxxxxxxxxxxxxxx> wrote in message
news:5.2.0.9.0.20030723215624.00ac32a8@xxxxxxxxxxxxxxxxxxxx
> Hi all -
>
> Run into an interesting problem which I hope somebody might have a few
> ideas about. I don't remember anything like this being discussed or
> documented. I'll be checking the wapforum and related sites in the
meantime.
>
> I am planning to transform some existing content into WML (wireless
markup)
> from a sequential XML source using XSLT (rather than DOM). The WML browser
> targets have limitations on the size of content which can be delivered,
> about 1500-1800 bytes uncompressed.
>
> I would like to retain the simplicity of doing this transformation using
an
> XSL stylesheet. However, I am not aware of any functions which can
> determine the output result size, in bytes, of a set of nodes. This is not
> a question about counting the input bytes, rather I want to determine if I
> can count the number of bytes in a result set as it is transformed.
>
> I envisage using a simple for-each loop, and checking before each
iteration
> if the result size exceeds the limiting value I put into a param in the
> stylesheet. If the result size is within a certain range of the limit, I
> would close the WML 'deck' and exit the stylesheet.
>
> So - has anybody got a good idea how I could do this ?
>
> Thanks in advance -
> Regards - Neil Smith.
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
This electronic transmission is strictly confidential to Smith & Nephew and
intended solely for the addressee.  It may contain information which is
covered by legal, professional or other privilege.  If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy or take any action in reliance on this
transmission.  If you have received this transmission in error, please
notify the sender as soon as possible and destroy this message.

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.