I have written an XSLT transformation on an ASP.NET page. The resulting HTML
is primarily a table of links. I have found that when the resulting HTML is
less than or equal to 16040 bytes, the output display is normal, but when the
resulting HTML exceeds 16040 bytes, the output does not display correctly.
When I look at View Source, I see that the final </html> tag gets moved to
another spot in the output, byte by byte as I increase the size, that is, at
16041 bytes, the final > gets moved, at 16042 bytes the final l> get moved,
etc. And as the output size increases, more and more of the "final"
characters get moved to another spot in the output.
Can anyone else replicate this problem? Is there a workaround?
I am running .NET Framework 1.1 and Windows XP Professional.
Here's the code I am running:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<script runat="server" >
void Page_Load(Object Sender, EventArgs E)
{
XslTransform xslDoc = new XslTransform();
StringBuilder sb = new StringBuilder(40000);
StringWriter sw = new StringWriter(sb);
lblMessage1.Text = sb.Capacity.ToString() + ' ' + sb.Length.ToString();
try
{
XPathDocument xmlDoc = new
XPathDocument(Server.MapPath("/GenDat/Moors.xml"));
xslDoc.Load(Server.MapPath("/GenDat/GenDat.xsl"));
xslDoc.Transform(xmlDoc,null,sw);
lblMessage1.Text = lblMessage1.Text + ' ' + sb.Capacity.ToString() + '
' + sb.Length.ToString();
}
catch(Exception ex)
{
lblMessage1.Text = ex.Message;
}
finally
{
sw.Close();
}
lblMessage2.Text = sb.ToString();
}
</script>
<html><body>
<asp:Label id="lblMessage1" runat="server" />
<asp:Label id="lblMessage2" runat="server" />
</body></html>
I have the same problem with the display of the output when I use the
following alternate code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<html>
<body>
<asp:Xml id="xslTransform" runat="server"
DocumentSource="/Gendat/Moors.xml"
TransformSource="/Gendat/GenDat.xsl" />
</body>
</html
Oleg Tkachenko [MVP] - 06 Sep 2004 09:25 GMT
> I have written an XSLT transformation on an ASP.NET page. The resulting HTML
> is primarily a table of links. I have found that when the resulting HTML is
[quoted text clipped - 5 lines]
> etc. And as the output size increases, more and more of the "final"
> characters get moved to another spot in the output.
That sounds weird. Can you provide some repro? Show us your XML and
stylesheet.

Signature
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Joseph A Romeo - 07 Sep 2004 02:57 GMT
> That sounds weird. Can you provide some repro? Show us your XML and
> stylesheet.
The original XML file was 2M, a bit large to include here. I have made an
abbreviated XML file and an abbreviated XSLT file which produce the same
problem as I reported. When the XML file contains the records with
type="test", the problem is noticeable; without them, it displays fine.
Moors.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE GenDat SYSTEM "GenDat.dtd" >
<GenDat>
<Family type="principal">Argo</Family>
<Family type="principal">Beckett</Family>
<Family type="principal">Cambridge</Family>
<Family type="principal">Carney</Family>
<Family type="principal">Carter</Family>
<Family type="principal">Clark</Family>
<Family type="principal">Coker</Family>
<Family type="principal">Cork</Family>
<Family type="principal">Cott</Family>
<Family type="principal">Counselor</Family>
<Family type="principal">Dean</Family>
<Family type="principal">Drain</Family>
<Family type="principal">Driggus</Family>
<Family type="principal">Durham</Family>
<Family type="principal">Farmer</Family>
<Family type="principal">Green</Family>
<Family type="principal">Greenage</Family>
<Family type="principal">Hansor</Family>
<Family type="principal">Hargrove</Family>
<Family type="principal">Harmon</Family>
<Family type="principal">Hughes</Family>
<Family type="principal">Johnson</Family>
<Family type="principal">Keys</Family>
<Family type="principal">LeCount</Family>
<Family type="principal">Loatman</Family>
<Family type="principal">Miller</Family>
<Family type="principal">Morgan</Family>
<Family type="principal">Morris</Family>
<Family type="principal">Mosley</Family>
<Family type="principal">Munce</Family>
<Family type="principal">Norwood</Family>
<Family type="principal">Oney</Family>
<Family type="principal">Perkins</Family>
<Family type="principal">Pickerem</Family>
<Family type="principal">Ridgeway</Family>
<Family type="principal">Sammons</Family>
<Family type="principal">Sanders</Family>
<Family type="principal">Seeney</Family>
<Family type="principal">Sisco</Family>
<Family type="principal">Sockum</Family>
<Family type="principal">Songo</Family>
<Family type="principal">Street</Family>
<Family type="principal">Wilson</Family>
<Family type="principal">Wright</Family>
<Family type="principal">(-----)</Family>
<Family type="related">Aldrich</Family>
<Family type="related">Anderson</Family>
<Family type="related">Appo</Family>
<Family type="related">Baker</Family>
<Family type="related">Ball</Family>
<Family type="related">Bannister</Family>
<Family type="related">Barr</Family>
<Family type="related">Berkheiser</Family>
<Family type="related">Blair</Family>
<Family type="related">Blunt</Family>
<Family type="related">Bolivar</Family>
<Family type="related">Bordley</Family>
<Family type="related">Borteles</Family>
<Family type="related">Bowers</Family>
<Family type="related">Bowles</Family>
<Family type="related">Briant</Family>
<Family type="related">Bridge</Family>
<Family type="related">Brooks</Family>
<Family type="related">Brown</Family>
<Family type="related">Buckley</Family>
<Family type="related">Burr</Family>
<Family type="related">Burrell</Family>
<Family type="related">Chambers</Family>
<Family type="related">Cook</Family>
<Family type="related">Coombs</Family>
<Family type="related">Cooper</Family>
<Family type="related">Coward</Family>
<Family type="related">Cuff</Family>
<Family type="related">Custis</Family>
<Family type="related">Davis</Family>
<Family type="related">Dawson</Family>
<Family type="related">Derry</Family>
<Family type="related">Dorsey</Family>
<Family type="related">Downs</Family>
<Family type="related">Ensign</Family>
<Family type="related">Fargo</Family>
<Family type="related">Faulkner</Family>
<Family type="related">Ferguson</Family>
<Family type="related">Fetters</Family>
<Family type="related">Finley</Family>
<Family type="related">Flowers</Family>
<Family type="related">French</Family>
<Family type="related">Galloway</Family>
<Family type="related">Garrettson</Family>
<Family type="related">Gates</Family>
<Family type="related">Gibbons</Family>
<Family type="related">Giboo</Family>
<Family type="related">Gibson</Family>
<Family type="related">Giffen</Family>
<Family type="related">Gilbert</Family>
<Family type="related">Gould</Family>
<Family type="related">Gray</Family>
<Family type="related">Gross</Family>
<Family type="related">Gullin</Family>
<Family type="related">Hale</Family>
<Family type="related">Hall</Family>
<Family type="related">Haskins</Family>
<Family type="related">Heard</Family>
<Family type="related">Hembsley</Family>
<Family type="related">Heywood</Family>
<Family type="related">Hider</Family>
<Family type="related">Highgate</Family>
<Family type="related">Hobart</Family>
<Family type="related">Hoffman</Family>
<Family type="related">Hogans</Family>
<Family type="related">Holmes</Family>
<Family type="related">Holston</Family>
<Family type="related">Horn</Family>
<Family type="related">Horton</Family>
<Family type="related">Hutchison</Family>
<Family type="related">Jacklin</Family>
<Family type="related">Jackson</Family>
<Family type="related">Jamison</Family>
<Family type="related">Jennifer</Family>
<Family type="related">Jones</Family>
<Family type="related">Kelly</Family>
<Family type="related">Kern</Family>
<Family type="related">Kelson</Family>
<Family type="related">King</Family>
<Family type="related">Kitridge</Family>
<Family type="related">Klick</Family>
<Family type="related">Krouse</Family>
<Family type="related">Linderman</Family>
<Family type="related">Lulham</Family>
<Family type="related">McCreary</Family>
<Family type="related">Mann</Family>
<Family type="related">Martin</Family>
<Family type="related">Maslin</Family>
<Family type="related">Mette</Family>
<Family type="related">Norfolk</Family>
<Family type="related">Okonski</Family>
<Family type="related">Omans</Family>
<Family type="related">Osterhout</Family>
<Family type="related">Owens</Family>
<Family type="related">Parelli</Family>
<Family type="related">Parrish</Family>
<Family type="related">Patterson</Family>
<Family type="related">Payne</Family>
<Family type="related">Phelps</Family>
<Family type="related">Pierce</Family>
<Family type="related">Pounder</Family>
<Family type="related">Pritchett</Family>
<Family type="related">Proctor</Family>
<Family type="related">Reddick</Family>
<Family type="related">Reed</Family>
<Family type="related">Renton</Family>
<Family type="related">Reynolds</Family>
<Family type="related">Ricks</Family>
<Family type="related">Robbins</Family>
<Family type="related">Rodgers</Family>
<Family type="related">Ross</Family>
<Family type="related">Rothermel</Family>
<Family type="related">Rush</Family>
<Family type="related">Russell</Family>
<Family type="related">Schaefer</Family>
<Family type="related">Schramm</Family>
<Family type="related">Schultz</Family>
<Family type="related">Shaw</Family>
<Family type="related">Smith</Family>
<Family type="related">Spaulding</Family>
<Family type="related">Spotts</Family>
<Family type="related">Stith</Family>
<Family type="related">Stone</Family>
<Family type="related">Thomas</Family>
<Family type="related">Thompson</Family>
<Family type="related">Valentino</Family>
<Family type="related">Voshell</Family>
<Family type="related">Wapker</Family>
<Family type="related">Waples</Family>
<Family type="related">Way</Family>
<Family type="related">Webb</Family>
<Family type="related">Westcott</Family>
<Family type="related">Whitcraft</Family>
<Family type="related">Wielandt</Family>
<Family type="related">Williams</Family>
<Family type="related">Wood</Family>
<Family type="related">Young</Family>
<Family type="test">Test1</Family>
<Family type="test">Test2</Family>
<Family type="test">Test3</Family>
<Family type="test">Test4</Family>
<Family type="test">Test5</Family>
<Family type="test">Test6</Family>
<Family type="test">Test7</Family>
<Family type="test">Test8</Family>
<Family type="test">Test9</Family>
<Family type="test">Test10</Family>
<Family type="test">Test11</Family>
<Family type="test">Test12</Family>
<Family type="test">Test13</Family>
<Family type="test">Test14</Family>
<Family type="test">Test15</Family>
<Family type="test">Test16</Family>
</GenDat>
Gendat.xsl
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:variable name="Family" select="/GenDat/Family" />
<xsl:template match="/" >
<xsl:call-template name="FamilyTable" >
<xsl:with-param name="Type" select="'principal'" />
</xsl:call-template>
<xsl:call-template name="FamilyTable" >
<xsl:with-param name="Type" select="'related'" />
</xsl:call-template>
</xsl:template>
<xsl:template name="FamilyTable" >
<xsl:param name="Type" select="'None'" />
<xsl:variable name="Count" select="count($Family[@type=$Type])" />
<xsl:if test="$Count > 0" >
<h3>
<xsl:choose>
<xsl:when test="$Type = 'principal'">Principal </xsl:when>
<xsl:when test="$Type = 'related'">Related </xsl:when>
</xsl:choose>
<xsl:text>Families</xsl:text>
</h3>
<table width="100%">
<colgroup width="20%" valign="top" align="left"></colgroup>
<colgroup width="80%" valign="top" align="left"></colgroup>
<xsl:apply-templates select="$Family" />
</table>
</xsl:if>
</xsl:template>
<xsl:template match="Family" >
<tr>
<td>
<xsl:value-of select="@type" />
</td>
<td>
<xsl:value-of select="." />
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
GenDat.dtd
<!ELEMENT GenDat (Family*) >
<!ELEMENT Family (#PCDATA) >
<!ATTLIST Family
type CDATA #IMPLIED
Joseph A Romeo - 07 Sep 2004 20:39 GMT
After upgrading to .NET Framework 1.1 Service Pack 1, the transformation
works correctly.