How to Generate Word Documents Using XSLT

Extensible Stylesheet Language Transformations (XSLT) is a newer version of Extensible Stylesheet Language (XLT). XSLT defines the formating for XML (Extensible Markup Language) documents. XSLT works as a type of template for how all of the data will be displayed in XML data presentations. The Microsoft word-processing application, Word, works well with XSLT and XML. Microsoft even includes a XML reader with some of their Office application suites that can also convert Word documents into the XML format. In return, use XSLT to generate and format Word documents.

Instructions

    • 1

      Open the program you use to create XSLT programs, such as Visual Studio or a text-editing program. Create a new file or open an exiting file that you want to add this function to.

    • 2

      Add references so that the XSLT code understands the functions that you will have to use to generate the Word document.

      "Imports System

      Imports System.Collections.Generic

      Imports System.Drawing

      Imports System.Text

      Imports System.Windows.Forms

      Imports System.Xml

      Imports System.Xml.Xsl

      Imports System.Xml.XPath

      Imports.IO"

    • 3

      Add the code to generate the Word document. The following code uses the XmlTextWriter to create a Rich Text Format, or RTF, document that can be opened in Microsoft Word.

      "Dim xDoc as XmlDataDocument

      Dim xPath as XPathNavigator

      Dim xWriter as XmlTextWriter

      Dim xRoot as XmlElement

      Dim xCompile as xslCompiledTransform

      xDoc - New XmlDataDocument

      xRoot = xDoc.DocumentElement

      xPath = xRoot.CreateNavigator()

      xWriter = New XmlTextWriter("Text.rtf", System.Text.Encoding.Default)

      xCompile.transform(xPath, xWriter)

      xWriter.Close()"

    • 4

      Save the XSLT document.

Related Searches:

References

Comments

You May Also Like

  • How to Use Excel XML & XSLT

    Microsoft Excel is a spreadsheet and data storage application that is used to store information in a tabular format. Excel is included...

  • How to Change the Background Color in a Microsoft Word Document

    You can change the background color in a Microsoft Word 97 and 2000 (for PC) and 98 (for Macintosh) document if you...

  • What Is an Unknown XSLT Function?

    An unknown XSLT function is an error that occurs when a style sheet attempts to call a function that is not there,...

  • Doc to XML Conversion

    DOC, the computer format that originates in Microsoft Word, is commonly composed of text, shapes, and images. In some cases, you may...

  • How to Create an RTF File

    An RTF file, or Rich Text Format file, is a basic word processing document file type with the extension ".rtf." RTF files...

  • How to: Word Document to XML

    Microsoft Word offers many features as a word processing program. After creating a document in Word 1999 through Word 2003, you can...

  • XML to XSL Conversion

    XML to XSL conversion refers to the transformation of XML data into a required output format using XSL, or "Extensible Stylesheet Language,"...

  • What Is the File Extension XSLT?

    Files with the XSLT extension contain EXtensible Stylesheet Language Transformations. XSLT files are used to define style rules for displaying XML data....

Related Ads

Featured