c# code 39 checksum CH APT ER 6 T RANS FO RMI NG XM L WI T H XS LT in C#

Painting Code 39 Extended in C# CH APT ER 6 T RANS FO RMI NG XM L WI T H XS LT

CH APT ER 6 T RANS FO RMI NG XM L WI T H XS LT
Code 39 Full ASCII Drawer In Visual C#.NET
Using Barcode generator for .NET framework Control to generate, create ANSI/AIM Code 39 image in VS .NET applications.
www.OnBarcode.com
Scanning USS Code 39 In Visual C#
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The employeeid attribute has now become the EMPCODE attribute. The <firstname>, <lastname>, <homephone>, and <notes> elements have now become <FNAME>, <LNAME>, <PHONE>, and <REMARKS>, respectively. The XSLT style sheet that brings about this transformation is shown in Listing 6-8. Listing 6-8. Transforming Employees.xml < xml version="1.0" encoding="UTF-8" > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <EMPLOYEES> <xsl:apply-templates/> </EMPLOYEES> </xsl:template> <xsl:template match="employee"> <xsl:element name="E{@employeeid}"> <xsl:attribute name="EMPCODE"> <xsl:value-of select="@employeeid"/> </xsl:attribute> <xsl:apply-templates select="firstname"/> <xsl:apply-templates select="lastname"/> <xsl:apply-templates select="homephone"/> <xsl:apply-templates select="notes"/> </xsl:element> </xsl:template> <xsl:template match="firstname"> <FNAME> <xsl:value-of select="."/> </FNAME> </xsl:template> <xsl:template match="lastname"> <LNAME> <xsl:value-of select="."/> </LNAME> </xsl:template> <xsl:template match="homephone"> <PHONE> <xsl:value-of select="."/> </PHONE> </xsl:template>
Creating QR Code In C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications.
www.OnBarcode.com
DataMatrix Generator In C#.NET
Using Barcode creation for .NET framework Control to generate, create Data Matrix 2d barcode image in VS .NET applications.
www.OnBarcode.com
C HA PTER 6 TRAN SFORM IN G XML WITH XSLT
Print EAN / UCC - 14 In C#.NET
Using Barcode creator for .NET framework Control to generate, create USS-128 image in .NET applications.
www.OnBarcode.com
Encode 1D Barcode In C#.NET
Using Barcode maker for Visual Studio .NET Control to generate, create Linear image in VS .NET applications.
www.OnBarcode.com
<xsl:template match="notes"> <REMARKS> <xsl:value-of select="."/> </REMARKS> </xsl:template> </xsl:stylesheet> Notice the code marked in bold. The topmost <xsl:template> element now contains the <EMPLOYEES> element. The template that matches the <employee> element does an interesting job: the <xsl:element> element is used to define new elements in the resultant output. You might be wondering why we need this element; after all, you can directly specify new element names (as we do for <FNAME>, <LNAME>, <PHONE>, and <REMARKS> later on). Note that we need to create an element name that is E followed by the employee ID. Something like this can be accomplished only by using the <xsl:element> element. Observe carefully how the element name has been formed by specifying the dynamic part (employee ID) in curly brackets. Next, the <xsl:attribute> element defines the EMPCODE attribute. The templates for <firstname>, <lastname>, <homephone>, and <notes> are then applied. In each of these templates, the new markup tag is emitted along with the value of the element. If you open this file in a web browser, you may not see the desired markup because the output is not HTML this time. The Visual Studio IDE provides an easy way to see the resultant output. Open the XML document (Employees.xml) in the IDE, and apply the latest style sheet to it by using the xml-stylesheet processing instruction. Then choose XML Show XSLT Output from the menu. Visual Studio will apply the style sheet to the XML document and display the resultant output.
Barcode Generation In Visual C#.NET
Using Barcode generator for .NET Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
USPS POSTNET Barcode Generator In Visual C#
Using Barcode generation for .NET framework Control to generate, create USPS POSTal Numeric Encoding Technique Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
The XslCompiledTransform Class
Code 3/9 Creator In Java
Using Barcode generation for Android Control to generate, create Code 39 Full ASCII image in Android applications.
www.OnBarcode.com
Code39 Encoder In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create Code 39 image in .NET applications.
www.OnBarcode.com
Up until now, we have attached XSLT style sheets to XML documents at design time. However, in many real-world cases, you may need to apply them programmatically. For example, you might be generating the XML data at run time and wish to transform it by using XSLT. The XslCompiledTransform class is intended for just such a situation. The XslCompiledTransform class resides in the System.Xml.Xsl namespace and represents the .NET Framework s XSLT processor. It compiles the XSLT style sheets and performs XSLT transformations. The XslCompiledTransform class can accept XML data to transform it in several forms. Similarly, the output generated by XslCompiledTransform can be in various forms. To be specific, the source of transformation can be as follows: An object that implements IXPathNavigator (for example, XmlNode or XPathDocument) An XmlReader A URL or path of the XML file The output of the transformation can be in the form of the following: An XmlWriter class A physical disk file
Generating Barcode In Java
Using Barcode printer for Eclipse BIRT Control to generate, create Barcode image in BIRT applications.
www.OnBarcode.com
Reading DataMatrix In Visual Basic .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
CH APT ER 6 T RANS FO RMI NG XM L WI T H XS LT
Barcode Generation In .NET
Using Barcode creator for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Barcode Printer In Objective-C
Using Barcode maker for iPad Control to generate, create Barcode image in iPad applications.
www.OnBarcode.com
A stream (for example, MemoryStream or FileStream) A class inheriting from the TextWriter abstract class (for example, StringWriter or StreamWriter)
Create UPC-A In Objective-C
Using Barcode printer for iPhone Control to generate, create UPCA image in iPhone applications.
www.OnBarcode.com
Recognize GS1 - 13 In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Performing Transformations by Using XslCompiledTransform
Draw Universal Product Code Version A In None
Using Barcode creation for Office Word Control to generate, create UPCA image in Word applications.
www.OnBarcode.com
DataBar Maker In Java
Using Barcode generation for Java Control to generate, create GS1 DataBar Stacked image in Java applications.
www.OnBarcode.com
In this section, you will learn to use the XslCompiledTransform class. You will develop an application like the one shown in Figure 6-5.
Code 128 Code Set C Creation In None
Using Barcode encoder for Online Control to generate, create Code 128B image in Online applications.
www.OnBarcode.com
Generating GS1 - 12 In VS .NET
Using Barcode creator for ASP.NET Control to generate, create UPC Code image in ASP.NET applications.
www.OnBarcode.com
Figure 6-5. Application to apply XSLT transformations As shown in Figure 6-5, the application consists of three text boxes to accept the source XML filename, the XSLT style sheet filename, and the destination filename, respectively. Clicking the Transform button performs the transformation, and the output of the transformation is stored in a file specified by the Destination File text box. You can also open the destination file after a successful transformation by selecting the check box. Listing 6-9 shows the Click event handler of the Transform button. Listing 6-9. Using the XslCompiledTransform Class private void button1_Click(object sender, EventArgs e) { if(Path.GetExtension(textBox3.Text)!=".htm" && Path.GetExtension(textBox3.Text)!=".html") { MessageBox.Show("File extension must be .htm or .html"); return; } XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(textBox2.Text); xslt.Transform(textBox1.Text, textBox3.Text); if (checkBox1.Checked) { System.Diagnostics.Process.Start(textBox3.Text); } }
Copyright © OnBarcode.com . All rights reserved.