Subject: Re: [xsl] Measure the length of an XML document in bytes From: "Joris Gillis" <roac@xxxxxxxxxx> Date: Thu, 04 Aug 2005 15:35:06 +0200 |
Hi, Tempore 14:49:54, die 08/04/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Khorasani, Houman <houman_khorasani@xxxxxxxxxxxxxx>:
Any ideas how to count the length of a document character by character?
You could obtain a roughly estimated value by performing a pseudo-serialization of the inut tree: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/"> <xsl:variable name="doc"> <xsl:apply-templates select="." mode="serialize"/> </xsl:variable> estimated size: <xsl:value-of select="string-length($doc)"/> </xsl:template>
<xsl:template match="comment" mode="serialize"> <xsl:text/><!--<xsl:apply-templates mode="serialize"/>--><xsl:text/> </xsl:template>
<xsl:template match="processing-instruction()" mode="serialize"> <xsl:text/><?<xsl:value-of select="name()"/> <xsl:text> </xsl:text><xsl:value-of select="."/>?><xsl:text/> </xsl:template>
<xsl:template match="*" mode="serialize"> <xsl:text/><<xsl:value-of select="name()"/> <xsl:apply-templates select="@*" mode="serialize"/>><xsl:text/> <xsl:apply-templates mode="serialize"/> <xsl:text/></<xsl:value-of select="name()"/>><xsl:text/> </xsl:template>
<xsl:template match="@*" mode="serialize"> <xsl:text> </xsl:text><xsl:value-of select="name()"/> <xsl:text/>="<xsl:value-of select="."/>"<xsl:text/> </xsl:template>
regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) Spread the wiki (http://www.wikipedia.org)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Measure the length of an , Khorasani, Houman | Thread | RE: [xsl] Measure the length of an , Michael Kay |
Re: [xsl] Using Saxon 8.5 and colle, David Carlisle | Date | RE: [xsl] RE: failure notice, Welch Andrew (ELS) |
Month |