G
Guest
Greetings
When checking for an Xslt Compile Exception, I found the message property did not contain the complete message. Instead there was an inner exception of type XsltException that contained the correct message, but zero for the line and postion properties. Here is the output from my debug statements
XsltCompileException Message Contents: (5,2)
XsltCompileException Message Length:
XsltCompileException Line Number:
XsltCompileException Line Position:
XsltCompileException InnerException Message Contents: './Exception' is an invalid XPath expression
XsltCompileException InnerException Message Length: 4
XsltCompileException InnerException Line Number:
XsltCompileException InnerException Line Position:
Below I have included the XSL style sheet and the code I was using.
Question:
Is this a bug in the framwork, or did I miss something when I was reading the SDK documentation?
Cheers
John
-----------------------------------------------------------------------------------------------------------------------------------------------------
Here is the style sheet I was using
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"><xslutput method="text" /><xsl:template match="./Exception"
using System
namespace DMH.Framework.Dat
/// <summary
/// The exception that is thrown when <xsl:value-of select="Description" /
/// </summary
public class <xsl:value-of select="Name" />Exception : GeneralExceptio
public <xsl:value-of select="Name" />Exception():base(){
public <xsl:value-of select="Name" />Exception(string message):base(message){}
public <xsl:value-of select="Name" />Exception(string message, Exception ex):base(message, ex){}
public static string FormatMessage(<xsl:apply-templates select="Parms" mode="MethodArgs" />
return String.Format(" <xsl:value-of select="MessageString" />", <xsl:apply-templates select="Parms" mode="MessageArgs" />);
public override int ErrorNumbe
get {return <xsl:value-of select="ErrorNumber" />;
</xsl:template><xsl:template match="Parms" mode="MethodArgs" ><xsl:apply-templates select="Parm" mode="MethodArgs" /></xsl:template><xsl:template match="Parm" mode="MethodArgs"><xsl:text>string </xsl:text><xsl:value-of select="." /><xsl:if test="position()!=last()">, </xsl:if></xsl:template><xsl:template match="Parms" mode="MessageArgs" ><xsl:apply-templates select="Parm" mode="MessageArgs" /></xsl:template><xsl:template match="Parm" mode="MessageArgs"><xsl:value-of select="." /><xsl:if test="position()!=last()">, </xsl:if></xsl:template></xsl:stylesheet
----------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the code snip
StringReader sReader = new StringReader(this.XSLText.Text);
XmlTextReader xReader = new XmlTextReader(sReader)
//Load the stylesheet
//Create a new XslTransform object
XslTransform xslt = new XslTransform()
tr
xslt.Load(xReader);
catch(XsltCompileException ex
Debug.WriteLine(ex.Message, "XsltCompileException Message Contents");
Debug.WriteLine(ex.Message.Length, "XsltCompileException Message Length")
Debug.WriteLine(ex.LineNumber, "XsltCompileException Line Number");
Debug.WriteLine(ex.LinePosition, "XsltCompileException Line Position")
if(ex.InnerException != null && ex.InnerException is XsltException
XsltException iex = (XsltException)ex.InnerException;
Debug.WriteLine(iex.Message, "XsltCompileException InnerException Message Contents");
Debug.WriteLine(iex.Message.Length, "XsltCompileException InnerException Message Length")
Debug.WriteLine(iex.LineNumber, "XsltCompileException InnerException Line Number");
Debug.WriteLine(iex.LinePosition, "XsltCompileException InnerException Line Position")
When checking for an Xslt Compile Exception, I found the message property did not contain the complete message. Instead there was an inner exception of type XsltException that contained the correct message, but zero for the line and postion properties. Here is the output from my debug statements
XsltCompileException Message Contents: (5,2)
XsltCompileException Message Length:
XsltCompileException Line Number:
XsltCompileException Line Position:
XsltCompileException InnerException Message Contents: './Exception' is an invalid XPath expression
XsltCompileException InnerException Message Length: 4
XsltCompileException InnerException Line Number:
XsltCompileException InnerException Line Position:
Below I have included the XSL style sheet and the code I was using.
Question:
Is this a bug in the framwork, or did I miss something when I was reading the SDK documentation?
Cheers
John
-----------------------------------------------------------------------------------------------------------------------------------------------------
Here is the style sheet I was using
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"><xslutput method="text" /><xsl:template match="./Exception"
using System
namespace DMH.Framework.Dat
/// <summary
/// The exception that is thrown when <xsl:value-of select="Description" /
/// </summary
public class <xsl:value-of select="Name" />Exception : GeneralExceptio
public <xsl:value-of select="Name" />Exception():base(){
public <xsl:value-of select="Name" />Exception(string message):base(message){}
public <xsl:value-of select="Name" />Exception(string message, Exception ex):base(message, ex){}
public static string FormatMessage(<xsl:apply-templates select="Parms" mode="MethodArgs" />
return String.Format(" <xsl:value-of select="MessageString" />", <xsl:apply-templates select="Parms" mode="MessageArgs" />);
public override int ErrorNumbe
get {return <xsl:value-of select="ErrorNumber" />;
</xsl:template><xsl:template match="Parms" mode="MethodArgs" ><xsl:apply-templates select="Parm" mode="MethodArgs" /></xsl:template><xsl:template match="Parm" mode="MethodArgs"><xsl:text>string </xsl:text><xsl:value-of select="." /><xsl:if test="position()!=last()">, </xsl:if></xsl:template><xsl:template match="Parms" mode="MessageArgs" ><xsl:apply-templates select="Parm" mode="MessageArgs" /></xsl:template><xsl:template match="Parm" mode="MessageArgs"><xsl:value-of select="." /><xsl:if test="position()!=last()">, </xsl:if></xsl:template></xsl:stylesheet
----------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the code snip
StringReader sReader = new StringReader(this.XSLText.Text);
XmlTextReader xReader = new XmlTextReader(sReader)
//Load the stylesheet
//Create a new XslTransform object
XslTransform xslt = new XslTransform()
tr
xslt.Load(xReader);
catch(XsltCompileException ex
Debug.WriteLine(ex.Message, "XsltCompileException Message Contents");
Debug.WriteLine(ex.Message.Length, "XsltCompileException Message Length")
Debug.WriteLine(ex.LineNumber, "XsltCompileException Line Number");
Debug.WriteLine(ex.LinePosition, "XsltCompileException Line Position")
if(ex.InnerException != null && ex.InnerException is XsltException
XsltException iex = (XsltException)ex.InnerException;
Debug.WriteLine(iex.Message, "XsltCompileException InnerException Message Contents");
Debug.WriteLine(iex.Message.Length, "XsltCompileException InnerException Message Length")
Debug.WriteLine(iex.LineNumber, "XsltCompileException InnerException Line Number");
Debug.WriteLine(iex.LinePosition, "XsltCompileException InnerException Line Position")