native barcode generator for crystal reports Investigating XSLT in Font

Maker Code 39 Full ASCII in Font Investigating XSLT

Investigating XSLT
Code39 Drawer In None
Using Barcode maker for Font Control to generate, create Code 39 Full ASCII image in Font applications.
www.OnBarcode.com
Create PDF 417 In None
Using Barcode generation for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
Of course, with XSLT then there is no IDE to investigate, but there is a complex toolset to understand. Have a look at Further Reading for some suggested material. We took some time to look at the capabilities of the CodeSmith IDE, before we began to look at some coding to support the delivery processes. In a moment we are going to look at specific CodeSmith templates to provide the code generation, and also XSLT templates to do the same. There is one area where we also need to provide some framework code to aid the use of XSLT: a processor to output multiple files. Again, the aim is to produce one ccnet.config file and then one build file and one deploy file per project. Ordinarily, XSLT will transform one XML file. With a little coding we can generate the same output as we have seen with CodeSmith. Ultimately, this code will be used by NAnt to regenerate its own files (we can see this later on) so we will use a <script> task for this framework code. Let us take a look.
Create GS1 - 12 In None
Using Barcode printer for Font Control to generate, create GTIN - 12 image in Font applications.
www.OnBarcode.com
Create Code 3 Of 9 In None
Using Barcode drawer for Font Control to generate, create Code 39 image in Font applications.
www.OnBarcode.com
Generating Multiple Output Files with XSLT
Barcode Generation In None
Using Barcode maker for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
USS-128 Creator In None
Using Barcode drawer for Font Control to generate, create EAN128 image in Font applications.
www.OnBarcode.com
To start this work, we will create a separate NAnt file, in this case called Builder.XSLT.xml. The build file is quite simple, with a single target called XsltBuilder and a call to this target. The XsltBuilder target will contain a script task to perform the generation. We saw an example of this in 3. So the skeleton for Builder.XSLT.xml looks like this: < xml version="1.0" > <project> <target name="XsltBuilder"> <script language="C#"> <imports> <import namespace="System.Xml"/> <import namespace="System.Xml.Xsl"/> <import namespace="System.Xml.XPath"/> </imports> <code><![CDATA[ public static void ScriptMain(Project project) {} ]]></code> </script> </target> <call target="XsltBuilder"/> </project>
Making QR Code In None
Using Barcode encoder for Font Control to generate, create Quick Response Code image in Font applications.
www.OnBarcode.com
Painting Rationalized Codabar In None
Using Barcode generation for Font Control to generate, create Monarch image in Font applications.
www.OnBarcode.com
CHAPTER 9 CODE GENERATION
USS Code 39 Maker In None
Using Barcode maker for Online Control to generate, create Code-39 image in Online applications.
www.OnBarcode.com
Decode Code39 In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
I have extended the <script> task to include the various XML namespaces that will be required for the scaffolding code. All that we need to do now is fill in the blanks, beginning with the ScriptMain method: public static void ScriptMain(Project project) { string projectSetFile = project.Properties["xslt.projectset"]; string outputDir = project.Properties["xslt.output"]; string xsltDir = project.Properties["xslt.directory"]; XmlDocument dom = new XmlDocument(); dom.Load(projectSetFile); ProduceCcnetConfigFile(xsltDir, outputDir, dom); ProduceBuildAndDeployFiles(xsltDir, outputDir, dom); } As you know, we need to pass through the NAnt project as a requirement of the Script Main method. We can then use the properties (for instance) in the project within the script. Here I have assumed that the three properties in bold are available in the NAnt script. We will implement those later. The other action of the entry point is to load the ProjectSet XML file that we saw in the CodeSmith examples into memory as an XML document. We then move to produce the relevant files. The ProduceCcnetConfigFile method looks like this: static void ProduceCcnetConfigFile(string xsltDirectory, string outputDirectory, XmlDocument dom) { string outputPath = Path.Combine(outputDirectory, "ccnet.config"); string xsltFile = Path.Combine(xsltDirectory, "Ccnet.xsl"); TransformXml(dom, xsltFile, outputPath, null); Console.WriteLine("Produced file: " + outputPath); } This is quite a straightforward method, performing a simple transformation to provide the ccnet.config file. The TransformXml utility method is shown here: static void TransformXml(XmlDocument document, string xsltFile, string outputPath, XsltArgumentList arguments) { string output = ""; XmlUrlResolver resolver = new XmlUrlResolver(); XslTransform stylesheet = new XslTransform(); stylesheet.Load(xsltFile); using(MemoryStream stream = new MemoryStream()) {
Creating Quick Response Code In Java
Using Barcode creation for Java Control to generate, create QR Code image in Java applications.
www.OnBarcode.com
Code 128 Code Set C Printer In None
Using Barcode encoder for Software Control to generate, create Code 128 image in Software applications.
www.OnBarcode.com
CHAPTER 9 CODE GENERATION
Barcode Maker In Java
Using Barcode generator for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
2D Drawer In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create 2D Barcode image in ASP.NET applications.
www.OnBarcode.com
stylesheet.Transform(document.DocumentElement.CreateNavigator(), arguments, stream, resolver); stream.Position = 0; using(StreamReader sr = new StreamReader(stream)) {output = sr.ReadToEnd();} } using(StreamWriter sw = new StreamWriter(outputPath)) {sw.WriteLine(output);} } This method performs a transformation accepting further arguments for the transformation (this is important for the build and deploy files as we will see a bit later) and then writes out the resulting transformed output to the requested location. Producing multiple outputs based on the single input file is a little more complicated. The opening method, ProduceBuildAndDeployFiles, is shown here: static void ProduceBuildAndDeployFiles(string xsltDirectory, string outputDirectory, XmlDocument dom) { string companyName = dom.DocumentElement.SelectSingleNode("Settings") .Attributes["CompanyName"].InnerText; int index = 1; foreach(XmlNode projectNode in dom.DocumentElement.SelectNodes("Projects/Project")) { string projectName = projectNode.Attributes["Name"].InnerText; string solutionName = string.Join(".", new string[] { companyName, projectName }); ProduceBuildAndDeployFile("Build", xsltDirectory, outputDirectory, solutionName, projectNode, dom, index); ProduceBuildAndDeployFile("Deploy", xsltDirectory, outputDirectory, solutionName, projectNode, dom, index); index++; } } As you might expect, this method loops over the XML file containing the ProjectSet, picking out the required solution name information in order to name the files appropriately, and then calls the ProduceBuildAndDeployFile method for the build and deploy transformation for each node (or project). This is very similar to the code we created for CodeSmith. The ProduceBuildAndDeployFile method is as follows:
Create GS1 128 In Visual Studio .NET
Using Barcode printer for Visual Studio .NET Control to generate, create EAN 128 image in .NET applications.
www.OnBarcode.com
UCC.EAN - 128 Recognizer In Visual Basic .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Code-128 Creator In None
Using Barcode creator for Office Excel Control to generate, create Code 128 Code Set A image in Office Excel applications.
www.OnBarcode.com
UPC-A Supplement 5 Creation In None
Using Barcode creation for Office Excel Control to generate, create UPC-A Supplement 2 image in Office Excel applications.
www.OnBarcode.com
Code 39 Printer In Java
Using Barcode printer for Android Control to generate, create Code39 image in Android applications.
www.OnBarcode.com
Matrix Barcode Generator In VB.NET
Using Barcode creator for .NET Control to generate, create 2D image in .NET applications.
www.OnBarcode.com
Copyright © OnBarcode.com . All rights reserved.