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>