Using XSLT as the language compiler-using XSLT to generate PostScript from XML

Source: Internet
Author: User
Tags constructor xslt

Introduction: Explore the concept of generating PostScript files from an XML document using XSLT as the programming language compiler, especially when creating an XML layer before postscript®. This article describes the style sheet as the concept of implicit language definitions, the basics of PostScript, and the abstraction layers involved when creating XML to PostScript compilers.

Using XSLT as a compiler

You can use XSLT to convert XML data into any other data format. Typically, XSLT is treated as a conversion language of XML to XML, and it is imported into XML documents and converted to other XML structures (including XHTML), but it can actually be used to generate arbitrary output, not just XML. When considering this approach, the XSLT stylesheet is actually a tool for defining a new language and can be treated as a language compiler. It may seem odd to use this literal compiler. Typically, a compiler is considered a program that converts human-readable code into machine language or virtual machine bytecode, but the general compiler is just a translator: compiling one language into another. The target language is usually in binary format (such as machine code), but not always in this format. In this sense, XSLT is a compiler technique. An XSLT stylesheet implicitly defines a new language, an XML dialect (XML dialect), which is compiled into different forms, which can be other XML dialects or other languages.

As an example of this concept of XSLT as a compiler, if you need to generate Java™ code through XML, assuming that you need to generate Java beans as part of an object-relational mapping system, you can do this using XSLT. A Java bean is a Java class with a default constructor (a constructor that does not get arguments) that exposes the getter and setter methods that allow callers to read and set object properties. Listing 1 shows an example of an XML document that defines a Java bean class with an xml-based language.

Listing 1. XML document that defines the Java Bean class

<java>
<bean-class name= "Employee" >
<property name= "id" type= "int"/>
<property Name= "Name" type= "string"/>
<property name= "title" Type= "string"/>
</bean-class>
</ Java>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.