web analytics
Debugging XSLT Style Sheets in Visual Studio Options
codeling
Posted: Wednesday, June 15, 2016 12:02:35 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 832
Points: 3483

You can step into XSLT while debugging an application. When you press F11 on an System.Xml.Xsl.XslCompiledTransform.Transform call, the debugger can step into the XSLT code.

To start debugging an XSLT application

  1. When instantiating the XslCompiledTransform object, set the enableDebug parameter to true in your code.

    This tells the XSLT processor to create debug information when the code is compiled.

  2. Press F11 to step into the XSLT code.

    The XSLT style sheet is loaded in a new document window and the XSLT debugger is started.

    Alternatively, you can add a break point to the style sheet and run your application.

Sponsor
Posted: Wednesday, June 15, 2016 12:02:35 PM
codeling
Posted: Wednesday, June 15, 2016 12:03:53 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 832
Points: 3483

The following is an example of a C# XSLT program. It shows how to enable XSLT debugging.

 

using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;

namespace ConsoleApplication 
{
  class Program 
  {
    private const string sourceFile = @"c:\data\xsl_files\books.xml";
    private const string stylesheet = @"c:\data\xsl_files\belowAvg.xsl";
    private const string outputFile = @"c:\data\xsl_files\output.xml";
 
    static void Main(string[] args)
    {
      // Enable XSLT debugging.
      XslCompiledTransform xslt = new XslCompiledTransform(true);

      // Compile the style sheet.
      xslt.Load(stylesheet)

      // Execute the XSLT transform.
      FileStream outputStream = new FileStream(outputFile, FileMode.Append);
      xslt.Transform(sourceFile, null, outputStream);
    }
  }
}
codeling
Posted: Wednesday, June 15, 2016 12:08:50 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 832
Points: 3483

Exception “stylesheet is too complex” when loading large XSLT

An exception "The stylesheet is too complex" when attempting to load an XSLT stylesheet in .NET 4.0.

Solution

Adding the following setting to your config file and the problem should go away.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="system.xml">
      <section name="xslt" type="System.Xml.XmlConfiguration.XsltConfigSection, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </sectionGroup>
  </configSections>
  <system.xml>
    <xslt limitXPathComplexity="false"/>
  </system.xml>
 </configuration>

 

 

Users browsing this topic
Guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


© 2017 Digcode.com. All rights reserved.