[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 onthe fly
From: Eric van der Vlist <vdv@xxxxxxxxxxxx>
Date: 23 Jul 2003 23:36:11 +0200
name measuring by length
Dimitre,

On Wed, 2003-07-23 at 23:24, Dimitre Novatchev wrote:
> This transformation:
.../...
> when applied on this source.xml:

.../...

> produces the wanted result:
> 
>    Length of output is: 51

Depends what you call length :-)

Shouldn't it be 175?

vdv@delleric:~/repros/libxslt$ wc -c length.xml
    175 length.xml

In the case of a WML deck, I think that you'll want to count the markup
too and to do so, you'd need to simulate a formating, for instance (not
dealing with attributes and namespaces):

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

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

  <xsl:template match="@*">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="*">
    <xsl:text>&lt;</xsl:text>
    <xsl:value-of select="name()"/>
    <xsl:text>></xsl:text>
    <xsl:apply-templates select="@* | node()"/>
    <xsl:text>&lt;</xsl:text>
    <xsl:value-of select="name()"/>
    <xsl:text>/></xsl:text>
    
  </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>

Which gives:
   Length of output is: 174
&lt;nums&gt;
  &lt;num&gt;01&lt;num/&gt;
  &lt;num&gt;02&lt;num/&gt;
  &lt;num&gt;03&lt;num/&gt;
  &lt;num&gt;04&lt;num/&gt;
  &lt;num&gt;05&lt;num/&gt;
  &lt;num&gt;06&lt;num/&gt;
  &lt;num&gt;07&lt;num/&gt;
  &lt;num&gt;08&lt;num/&gt;
  &lt;num&gt;09&lt;num/&gt;
  &lt;num&gt;10&lt;num/&gt;
&lt;nums/&gt;

I don't think you can get a very accurate estimation except if you can
know exactly how the output method will behave.

I had the same problem for http://wap.xmlfr.org and have solved this by
writing an extension function (for XT) which estimates the output. I
realize now that I could have used an adaptation of your stylesheet to
get a close result!

Eric
-- 
Read me on XMLhack.
                                      http://xmlhack.com/author.php?id=8
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------


 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.