What does xslt




















Upon finding the pattern, the transformation is triggered to generate the output document. The pattern uses an expression language based on XPath to compare source nodes and style sheet templates. Formatting semantics are included in the result tree, which enables formatting.

Formatting semantics can be defined as a set of classes representing formatting objects. The result tree nodes are termed as formatting objects. The presentation rules are defined by classes of formatting objects and properties. By: Justin Stoltzfus Contributor, Reviewer.

By: Satish Balakrishnan. Dictionary Dictionary Term of the Day. Natural Language Processing. Techopedia Terms. But in most programming languages this is a contrivance built on top of the imperative model. It is this fundamental difference in the approach to writing stylesheets that separates a good XSLT programmer from a programmer that hacks his way to getting the correct result while using XSLT.

While getting the correct result is the end game, writing XSLT well creates a solution that can be leveraged into other solutions and can be maintained with more assurance of reducing the introduction of faults into working code. Writing XSLT well takes practice and requires the skilled programmer to engage a mindset quite different from that required when writing in traditional imperative languages.

These points are illustrated later. After decades of different intelligence organizations producing drastically differently-appearing intelligence reports, the US intelligence community has agreed upon a single XML vocabulary used by agents to record information. In the project, the organizations wanted to continue seeing the information in their own individual style where only low-level constructs such as sections, paragraphs, tables, graphics, etc.

The overall renderings, such as title pages, tables of content and layout constraints are very different. The declarative style in XSLT is ideal for creating a single solution with overriding components. Declared components that are not overridden render the portions of content the same across all documents. Declared components that are overridden for each organization render the portions of content that are different.

Designing from the bottom up in the declarative style created a solution easily leveraged as required across multiple installations.

Seasoned developers using traditional programming languages must also appreciate that the data and processing models underlying XSLT are different from what they have been dealing with. No doubt programmers are well used to considering the syntax of the files that are input to a program, the syntax of the files that are output from a program, and the steps in their program to create output syntax from input syntax.

Relying on such a traditional approach can hinder a programmer's perspective of XSLT and prevent one from properly understanding that the writing and processing of an XSLT stylesheet is entirely divorced from the syntax of the input and output files.

As shown later, the programmer is given the information that was found in the input document , and can specify how to arrange the information to be placed in the output document, but the programmer has no interaction with the syntax of either input or output documents. One can choose from a number of syntax variations when marking up XML files. Branches and leaves in this tree are called nodes and each node has a value and a relationship to other nodes above, beside and below the node. The nodes also have names, those being the labels used in the XML such as input elements , so that one can identify in the transformation the parts of your document when creating the newly-labeled information such as output elements.

There are only seven kinds of node needed to express in a tree of nodes every possible XML document. Where order is defined in XML, such as the order of an element's children, order is preserved in the tree of nodes created by a vendor's implementation. Where order is not defined in XML, such as the order of an element's attributes, the order implemented by a vendor is arbitrary and must be handled appropriately in a well-written stylesheet.

With such in mind, then, a well-written stylesheet can access the input data found in an XML file in an identical fashion regardless of which vendor's tool is being used.

Through the facility of data projection, a vendor can offer to present to the transformation any content at all, provided that content is presented as a complete XDM tree of nodes of the seven different types. Beyond that, vendors can get very imaginative in what they offer. Relational tables can be projected as nodes of rows and columns of content. This diagram depicts a number of possible data flows using a single transform for two different inputs or two different transforms for a single input.

In all cases the illustrated input to the transform is a dotted triangle tree of source XDM nodes, and the output from the transform is a dotted triangle tree of result XDM nodes. The other tree of source XDM nodes shown part way down the diagram is created through source data projection of some non-XML content.

The diagram also shows only a single input and single output to the transformation process whereas, in fact, a single transformation can access multiple trees of source XDM nodes and create multiple trees of result XDM nodes, possibly serializing each result tree using a different syntax. It is important to note that vendors compete on both the performance of standard features, and the facilities available in extended features beyond the specifications. You need to be aware of locking yourself to a vendor's product should you choose to exploit the extended features.

At a minimum, because there are no standardized requests for data projection other than XML and text, you need to distinguish how to request non-XML and non-text content be offered using XDM. Beyond that, however, you can choose to stick to the available standardized behaviours or step beyond product independence by invoking vendor-specific behaviours.

The shared XDM data model of looking at input and output information to and from the transformation process infers that the processing models be similar and this is, in fact, the case. A number of vendors offer an underlying engine implementing a processing model that effects the transformation on nodes, regardless of the expression language used to express the transformation.

Thus the product equally supports either XSLT stylesheets or XQuery expressions, as either one of these is interpreted as yet another tree, that being a tree of operation XDM nodes.

It also shows both the data projection available to create the source XDM nodes and the many possible serialized results and interpretations of the result XDM nodes. Note the convention in the diagram of using the prime symbol to associate in the output tree from which input tree a given node is copied.

The diagram illustrates how the processing model establishes the independence of the transformation logic from the syntax of the input and output files. The transformation acts solely on operation nodes and source nodes to produce result nodes. The processor worries about the syntax, not the programmer.

Again, this is very different from what your programmers are used to dealing with. XSLT and XQuery are assembling the result based on the operations performed on the input under the programmer's control. The programmer is not writing out syntax. The programmer doesn't have to think of the vagaries of what can be in the XML documents. There is no input buffering or line handling to be done as this is all handled by the processor behind the scenes.

Your programmers need to focus on how best to express how the assembly of inputs into the results is best accomplished. The opportunities to leverage into multiple solutions the investment in a given stylesheet are found in the declarative nature of the stylesheet. This benefit can be overlooked when assessing XSLT compared to traditional imperative programming languages. Choosing to use XSLT is not simply choosing to use the latest and greatest XML-oriented technology, it is choosing a programming environment more flexible and robust than others at creating structured results from structured inputs.

The declarative approach of writing an XSLT stylesheet requires the programmer to view the transformation very differently than with the top-down imperative approach. The programmer must establish a particular granularity of fragments of the output that is to be associated with and matched with the granularity of the input XML.

Each of these fragments is then made to be a template of the result associated with the processing of a single node of the input. This association need only be made once for each type and name of input node and the template is copied to the result every time a node of the given type and name is processed. This is depicted in this diagram where the input source nodes are labeled with numbers and the output result nodes are labeled with letters.

The stylesheet governing the transformation is a collection of templates associated with each input node by that node's type and name. As each input node is encountered, the stylesheet assembles the result as the next portion of the result. The programmer is always in control over which source nodes are pushed at the at the collection of templates, and the XSLT engine responds to each pushed node by matching the most appropriate template with which to build the result.

Everything is seen as nodes, not as start tags or end tags or empty tags. When assessing long-term maintenance costs of your stylesheets, a valuable property of XSLT that distinguishes it from most other programming languages is that it is "side effect free". Global variables do not vary in that they are bound with final values when declared. Templates can only see their own variables and global variables, not the variables of other templates.

There is nothing one can do in a template that impacts on the processing of all other templates. They are likely to co-exist since they meet different needs. XSL is intended for complex formatting where the content of the document might be displayed in multiple places; for example the text of a heading might also appear in a dynamically generated table of contents.

CSS is intended for dynamic formatting of online documents for multiple media; its strictly declarative nature limits its capabilities but also makes it efficient and easy to generate and modify in the content-generation workflow.

It is particularly used for formatting of print documents. See the CSS2 Recommendation for details. XSL is targeted at XML, in particular highly-structured, data-rich documents that require extensive formatting.



0コメント

  • 1000 / 1000