OutOfMemoryException was thrown in XSL Transformation

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
Exception of type System.OutOfMemoryException was thrown.<br/>
at System.Xml. <span style="text-decoration:underline XmlEventCache.NewEvent() <br/>
<span style="text-decoration:underline <span style="text-decoration:underline at System.Xml. <span style="text-decoration:underline XmlEventCache.AddEvent (XmlEventType eventType)<br/>
at System.Xml.XmlEventCache.WriteEndAttribute()<br/>
at System.Xml.Xsl.Runtime.XmlAttributeCache.FlushAttributes()<br/>
at System.Xml.Xsl.Runtime.XmlAttributeCache.StartElementContent()<br/>
at System.Xml.Xsl.Runtime.XmlQueryOutput.StartElementContentUnchecked()<br/>
at System.Xml.Xsl.Runtime.XmlQueryOutput.ConstructWithinContent(XPathNodeType rootType)<br/>
at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartElement(String prefix, String localName, String ns)<br/>
at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartElementLocalName(String localName)<br/>
at <span style="text-decoration:underline <xsl:template name="QuickTable (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, IList`1 source,
XPathNavigator id, XPathNavigator print, IList`1 prefName, XPathNavigator class, XPathNavigator tableFrameClass, XPathNavigator classOdd, XPathNavigator classSelection, XPathNavigator classHighlight, XPathNavigator useAltRowColor, XPathNavigator childClass,
XPathNavigator tableWidth, XPathNavigator cellpadding, XPathNavigator cellspacing, XPathNavigator useWordWrap, XPathNavigator emptyListText, XPathNavigator showTitle, XPathNavigator headerControls, IList`1 title, XPathNavigator showColHeaders, IList`1 canClose,
IList`1 isClosed, XPathNavigator showChildren, XPathNavigator hide1stCol, XPathNavigator columns, String sortCol, String sortDir, XPathNavigator iconSortUp, XPathNavigator iconSortDown, XPathNavigator maxRows, XPathNavigator rowsPerPage, XPathNavigator rowHeightPx,
XPathNavigator isPageable, XPathNavigator initialPage, XPathNavigator startRecord, XPathNavigator classPageNav, XPathNavigator classPageNavMouseOver, XPathNavigator pageNavInHeader, XPathNavigator sortable, String onmouseover, String onmouseout, XPathNavigator
onclick, String ondblclick, XPathNavigator menu, IList`1 onExpandChildren, XPathNavigator expandAllChildren, XPathNavigator iconExpand, XPathNavigator iconCollapse, XPathNavigator iconFirst, XPathNavigator iconPrev, XPathNavigator iconNext, XPathNavigator
iconLast, XPathNavigator useTemplates, XPathNavigator useClassAdditionTemplate, XPathNavigator copySourceXML, IList`1 portletId, XPathNavigator isThisTheChild, String showChildColHeaders, IList`1 stopChildLevel)<br/>
at <xsl:template match="/ (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)<br/>
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)<br/>
at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)<br/>
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)<br/>
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)<br/>
at System.Xml.Xsl.XmlILCommand.Execute(XmlReader contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)<br/>
at System.Xml.Xsl. <span style="text-decoration:underline XslCompiledTransform.Transform (XmlReader input, XsltArgumentList arguments, XmlWriter results)<br/>
at XCMapper.TransformDoc(String name, XmlDocument pXMLParent, String pSource)
I got this exception when tried to transform an XML file, here is the piece of code im using to transform
<span style="font-size:medium <a> <span style="font-size:medium <span style="font-size:medium
public XmlDocument TransformDoc(string name, XmlDocument pXMLParent, string pSource)<br/>
{<br/>
XslCompiledTransform objXslCompiled = new XslCompiledTransform();<br/>
objXslCompiled.Load("c:\test\sample.xsl");<br/>
XmlDocument objXMLoutput = new XmlDocument();<br/>
using ( MemoryStream objOutStream = new MemoryStream()) <br/>
{<br/>

XmlTextWriter writer = new XmlTextWriter(objOutStream,Encoding.UTF8); <br/>
objXslCompiled.Transform(new XmlNodeReader(pXMLParent), null, writer);
// exception thrown here<br/>
objOutStream.Seek(0, SeekOrigin.Begin);<br/>
if (objOutStream.Length > 0)<br/>
{<br/>
try { objXMLoutput.Load(objOutStream); }<br/>
catch {//..doing something here}<br/>
}<br/>
}<br/>
//------ doing something here
return objXMLoutput;
}
is this exception because of this code or because of this <span style="text-decoration:underline <xsl:template name="QuickTable
xsl..?
<span style="text-decoration:underline is there any alternative code for this..?
Could anyone please xplain why is this happening...?
Thanks in advance,
Madhu Mahesh

View the full article
 
Back
Top