C# Code Generation

You use the C# Code Generation dialog box to specify information Stylus Studio will use to generate C# code for the current XQuery or XSLT. C# files are generated with a .cs extension.


Target directory

The target directory in which you want the C# code created. c:\temp\myPipelineC#Code, for example. If the directory you name does not exist, Stylus Studio creates it when you run the Code Generation wizard. The default is the same directory as the .pipeline file.


Stylus Studio uses the namespace name to create a folder in the target directory you specify. If you use myNamespace, for example, the generated code is written to c:\temp\myPipelineC#Code\myNamespace. (Though optional, it is considered good practice to create a namespace.)

Class name

Stylus Studio uses the class name for the .cs file created by the Code Generation wizard. For example, if you provide the name myClass, Stylus Studio creates c:\temp\myPipelineC#Code\myClass.cs. Stylus Studio uses the XML pipeline name as the default class name.

Saxon .NET folder

Allows you to specify the location of Saxon .NET on your system. Stylus Studio adds this URL to the Microsoft Visual Studio 2005 project, allowing the generated C# code for .NET to compile.

Create a Main method

Whether or not you want the resulting .cs file to contain a static void Main(String
[ ] args)

Open the generated file

Whether or not you want to open the generated code file. If selected, the generated C# file is opened in whatever application is registered to open .cs files.

Embed the XQuery source in the generated program

Whether or not you want to embed the XQuery source in the generated C# code. This option is available when using either the Saxon XQuery or DataDirect XQuery processors.

Note: This option appears only if you are generating XQuery code.

Add the class to a Visual Studio 2005 project

Either creates a new Visual Studio 2005 project or updates an existing one. If a new project is created, it is automatically opened with whatever application is registered to open .csproj files. The .csproj file contains all the necessary references to the generated .cs file, as well as all the .dll files that the .cs file requires.

To run the .cs file, simply press Ctrl+F5 in Visual Studio.

For More Information

Generating C# Code for XQuery

Generating C# Code for XSLT

Free Stylus Studio XML Training:
W3C Member