Groups | Blog | Home
all groups > dotnet xml > may 2007 >

dotnet xml : how to locate where an xslt stylesheet failed


Andy Fish
5/23/2007 5:36:00 PM
Dear experts,

After converting some .net code from using XslTransform to
XslCompiledTransform, one of my XSLs no longer runs. it fails with:

Attribute and namespace nodes cannot be added to the parent element after a
text, comment, pi, or sub-element node has already been added.

trouble is my stylesheet is long and complicated and I don't know where the
error was. is there any way of finding out which line number in the XSLT
produced the error? I tried it on Xml spy (which does tell you where the
error was) but the same transform doesn't fail in xml spy.

Andy

Martin Honnen
5/23/2007 6:45:44 PM
[quoted text, click to view]

XsltException
<http://msdn2.microsoft.com/en-us/library/system.xml.xsl.xsltexception.aspx>
has properties LineNumber and LinePosition so assuming you get such an
exception your code should be able to catch it and output those properties.
--

Martin Honnen --- MVP XML
ajfish NO[at]SPAM blueyonder.co.uk
5/24/2007 1:26:49 AM
[quoted text, click to view]

Thanks Martin,

I caught the exception but unfortunately these 2 values are both 0 (I
suspect if they weren't they would have appeared in the message).
Still, at least the error message itself is good so it will give me
somewhere to start

AddThis Social Bookmark Button