[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
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><</xsl:text> <xsl:value-of select="name()"/> <xsl:text>></xsl:text> <xsl:apply-templates select="@* | node()"/> <xsl:text><</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), '
')"/> <xsl:if test="string-length($vResult) <= 1800"> <xsl:copy-of select="$vResult"/> </xsl:if> </xsl:template> </xsl:stylesheet> Which gives: Length of output is: 174 <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/> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|