diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2006-11-30 08:35:45 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2006-11-30 08:35:45 +0300 |
commit | 679a1121b6fbe1ea4e6352f212238bec599fc4fd (patch) | |
tree | ed14677c476fbc1d93fbdd1d1ea8c3e9d2982b8f /mcs/class/System.XML/Mono.Xml.Xsl | |
parent | 1d5372356c7702c1dc0724716830a56e6dba1108 (diff) |
2006-11-30 Atsushi Enomoto <atsushi@ximian.com>
* XslStylesheet.cs, XslTemplate.cs : added XSLT stack frame debug
support, based on the patch by Michael Meeks.
* XslTransform.cs, XsltException.cs : added XSLT stack frame debug
support, based on the patch by Michael Meeks.
svn path=/trunk/mcs/; revision=68730
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.Xsl')
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs | 38 |
3 files changed, 49 insertions, 1 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog index 0cb88128790..fd0a2ce4d16 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog @@ -1,3 +1,8 @@ +2006-11-30 Atsushi Enomoto <atsushi@ximian.com> + + * XslStylesheet.cs, XslTemplate.cs : added XSLT stack frame debug + support, based on the patch by Michael Meeks. + 2006-04-07 Atsushi Enomoto <atsushi@ximian.com> * XslTransformProcessor.cs : push current node context after iterating diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs index fa051436fd2..41d1eb3a49b 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs @@ -64,6 +64,8 @@ namespace Mono.Xml.Xsl { XslTemplateTable templates; + string baseURI; + // stylesheet attributes string version; XmlQualifiedName [] extensionElementPrefixes; @@ -107,6 +109,10 @@ namespace Mono.Xml.Xsl { get { return templates; } } + public string BaseURI { + get { return baseURI; } + } + public string Version { get { return version; } } @@ -120,6 +126,7 @@ namespace Mono.Xml.Xsl { c.PushStylesheet (this); templates = new XslTemplateTable (this); + baseURI = c.Input.BaseURI; // move to root element while (c.Input.NodeType != XPathNodeType.Element) diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs index c939bd739a9..41c77bdcf10 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs @@ -350,9 +350,45 @@ namespace Mono.Xml.Xsl { c.Input.MoveToParent (); } } - + + string LocationMessage { + get { + XslCompiledElementBase op = (XslCompiledElementBase) content; + return String.Format (" from\nxsl:template {0} at {1} ({2},{3})", Match, style.BaseURI, op.LineNumber, op.LinePosition); + } + } + + void AppendTemplateFrame (XsltException ex) + { + ex.AddTemplateFrame (LocationMessage); + } + public virtual void Evaluate (XslTransformProcessor p, Hashtable withParams) { + if (XslTransform.TemplateStackFrameError) { + try { + EvaluateCore (p, withParams); + } catch (XsltException ex) { + AppendTemplateFrame (ex); + throw ex; + } catch (Exception ex) { + // Note that this catch causes different + // type of error to be thrown (esp. + // this causes NUnit test regression). + XsltException e = new XsltException ("Error during XSLT processing: ", null, p.CurrentNode); + AppendTemplateFrame (e); + throw e; + } + } + else + EvaluateCore (p, withParams); + } + + void EvaluateCore (XslTransformProcessor p, Hashtable withParams) + { + if (XslTransform.TemplateStackFrameOutput != null) + XslTransform.TemplateStackFrameOutput.WriteLine (LocationMessage); + p.PushStack (stackSize); if (parameters != null) { |