|1 ||XSLT: Extensible Stylesheet Language Transformations ||Landing, Web, XSLT |
Extensible Stylesheet Language Transformations (XSLT) is an XML-based language used, in conjunction with specialized processing software, for the transformation of XML documents. |
|2 ||Common XSLT Errors ||XSLT |
|Your server needs to send both the source and the stylesheet with a XML mime type, |
application/xml. To find out the current type, load the file in Mozilla and look at the page info. Or use a download tool, those usually tell the mime type.
|3 ||Index ||Index, Reference, XSLT |
|Found 54 pages: |
|4 ||PI Parameters ||XSLT |
|No summary! |
|No summary! |
|6 ||Advanced Example ||XSLT |
xslloaded variable to true once it has finished loading the file. Using the
XSLTProcessor.getParameter() method, the code can figure whether to sort in ascending or descending order. It defaults to ascending if the parameter is empty (the first time the sorting happens, as there is no value for it in the XSLT file). The sorting value is set using
|7 ||Basic Example ||XSLT |
|The basic example will load an XML file and apply a XSL transformation on it. These are the same files used in the Generating HTML example in the XSLT in Netscape Gecko article. The XML file describes an article and the XSL file formats the information for display. |
|8 ||Interface List ||NeedsContent, Reference |
XSLTProcessor in the Web API documentation section.
XSLTProcessor object. Once instantiated, an
XSLTProcessor has an
XSLTProcessor.importStylesheet() method that takes as an argument the XSLT stylesheet to be used in the transformation. The stylesheet has to be passed in as an XML document, which means that the .xsl file has to be loaded by the page before calling
XSLTProcessor.importStylesheet(). This can be done via
|11 ||Resources ||XSLT |
|No summary! |
|12 ||Setting Parameters ||XSLT |
|13 ||Transforming XML with XSLT ||NeedsMigration, Transforming_XML_with_XSLT, XML, XSLT |
|The separation of content and presentation is a key design feature of XML. The structure of an XML document is designed to reflect and clarify important relationships among the individual aspects of the content itself, unhindered by a need to provide any indication about how this data should eventually be presented. This intelligent structuring is particularly important as more and more data transfers are automated and take place between highly heterogeneous machines linked by a network. |
|14 ||An Overview ||NeedsHelp, NeedsMarkupWork, Transforming_XML_with_XSLT, XML, XSLT |
|The eXtensible Stylesheet Language/Transform is a very powerful language, and a complete discussion of it is well beyond the scope of this article, but a brief discussion of some basic concepts will be helpful in understanding the description of Netscape's capabilities that follows. |
|15 ||For Further Reading ||NeedsContent, NeedsHelp, Transforming_XML_with_XSLT, XML, XSLT |
|16 ||Resources ||Extensions, NeedsContent, NeedsExample, NeedsLiveSample, XML, xsl |
|No summary! |
|17 ||The Netscape XSLT/XPath Reference ||Netscape, Reference, XSLT, axes |
|No summary! |
|19 ||XSLT elements reference ||Element, Overview, Reference, XSLT |
|There are two types of elements discussed here: top-level elements and instructions. A top-level element must appear as the child of either |
<xsl:transform>. An instruction, on the other hand, is associated with a template. A stylesheet may include several templates. A third type of element, not discussed here, is the literal result element (LRE). An LRE also appears in a template. It consists of any non-instruction element that should be copied as-is to the result document, for example, an
<hr> element in an HTML conversion stylesheet.
|20 ||<xsl:apply-imports> ||Element, Reference, XSLT, apply-imports |
<xsl:apply-imports> element is fairly arcane, used mostly in complex stylesheets. Import precedence requires that template rules in main stylesheets have higher precedence than template rules in imported stylesheets. Sometimes, however, it is useful to be able to force the processor to use a template rule from the (lower precedence) imported stylesheet rather than an equivalent rule in the main stylesheet.
|21 ||<xsl:apply-templates> ||Element, Reference, XSLT, apply-templates |
<xsl:apply-templates> element selects a set of nodes in the input tree and instructs the processor to apply the proper templates to them.
|22 ||<xsl:attribute-set> ||Element, Reference, XSLT, attribute-set |
<xsl:attribute-set> element creates a named set of attributes, which can then be applied as whole to the output document, in a manner similar to named styles in CSS.
|23 ||<xsl:attribute> ||Attribute, Element, Reference, XSLT |
<xsl:attribute> element creates an attribute in the output document, using any values that can be accessed from the stylesheet. The element must be defined before any other output document element inside the output document element for which it establishes attribute values. But it may be after or inside elements that won't be part of the output (like
|24 ||<xsl:call-template> ||Element, Reference, XSLT, call-template |
<xsl:call-template> element invokes a named template.
|25 ||<xsl:choose> ||Element, Reference, XSLT, choose |
<xsl:choose> element defines a choice among a number of alternatives. It behaves like a switch statement in procedural languages.
|26 ||<xsl:comment> ||Comment, Element, Reference, XSLT |
<xsl:comment> element writes a comment to the output document. It must include only text.
|27 ||<xsl:copy-of> ||Element, Reference, XSLT, copy-of |
<xsl:copy-of> element makes a deep copy (including descendant nodes) of whatever the select attribute specifies to the output document.
|28 ||<xsl:copy> ||Element, Reference, XSLT, copy |
<xsl:copy> element transfers a shallow copy (the node and any associated namespace node) of the current node to the output document. It does not copy any children or attributes of the current node.
|29 ||<xsl:decimal-format> ||Element, Reference, XSLT, decimal-format |
<xsl:decimal-format> element defines the characters and symbols that are to be used in converting numbers into strings using the
format-number( ) function.
|30 ||<xsl:element> ||Element, Reference, XSLT |
<xsl:element> element creates an element in the output document.
|31 ||<xsl:fallback> ||Element, Reference, XSLT, fallback |
<xsl:fallback> element specifies what template to use if a given extension (or, eventually, newer version) element is not supported.
|32 ||<xsl:for-each> ||Element, Reference, XSLT, for, for-each |
<xsl:for-each> element selects a set of nodes and processes each of them in the same way. It is often used to iterate through a set of nodes or to change the current node. If one or more
<xsl:sort> elements appear as the children of this element, sorting occurs before processing. Otherwise, nodes are processed in document order.
|33 ||<xsl:if> ||Element, Reference, XSLT, if |
<xsl:if> element contains a test attribute and a template. If the test evaluates to true, the template is processed. In this it is similar to an if statement in other languages. To achieve the functionality of an if-then-else statement, however, use the
<xsl:choose> element with one
<xsl:when> and one
|34 ||<xsl:import> ||Element, Reference, XSLT, import |
<xsl:import> element is a top-level element that serves to import the contents of one stylesheet into another stylesheet. Generally speaking, the contents of the imported stylesheet have a lower import precedence than that of the importing stylesheet. This is in contrast to
<xsl:include> where the contents of the included stylesheet have exactly the same precedence as the contents of the including stylesheet.
|35 ||<xsl:include> ||Element, Reference, XSLT, include |
<xsl:include> element merges the contents of one stylesheet with another. Unlike the case of
<xsl:import>, the contents of an included stylesheet have exactly the same precedence as the contents of the including stylesheet.
|36 ||<xsl:key> ||Element, Key, Reference, XSLT |
<xsl:key> element declares a named key which can be used elsewhere in the stylesheet with the
key( ) function.
|37 ||<xsl:message> ||Element, Reference, XSLT, message |
|38 ||<xsl:namespace-alias> ||Element, Reference, XSLT, namespace-alias |
<xsl:namespace-alias> element is a rarely used device that maps a namespace in the stylesheet to a different namespace in the output tree. The most common use for this element is in generating a stylesheet from another stylesheet. To prevent a normally
xsl:-prefixed literal result element (which should simply be copied as-is to the result tree) from being misunderstood by the processor, it is assigned a temporary namespace which is appropriately re-converted back to the XSLT namespace in the output tree.
|39 ||<xsl:number> ||Element, Number, Reference, XSLT |
<xsl:number> element counts things sequentially. It can also be used to quickly format a number.
|40 ||<xsl:otherwise> ||Element, Reference, XSLT, otherwise |
<xsl:otherwise> element is used to define the action that should be taken when none of the
<xsl:when> conditions apply. It is similar to the
default case in other programing languages.
|41 ||<xsl:output> ||Element, Reference, XSLT, output |
<xsl:output> element controls the characteristics of the output document. To function correctly in Netscape, this element, with the method attribute, must be used. As of 7.0,
method="text" works as expected.
|42 ||<xsl:param> ||Element, Reference, XSLT, param |
<xsl:param> element establishes a parameter by name and, optionally, a default value for that parameter. When used as a top-level element, the parameter is global . When used inside an
<xsl:template> element, the parameter is local to that template. In this case it must be the first child element of the template.
|43 ||<xsl:preserve-space> ||Element, Reference, XSLT, preserve-space |
<xsl:preserve-space> element defines the elements in the source document for which whitespace should be preserved. If there is more than one element, separate the names with a whitespace character. Preserving whitespace is the default setting, so this element only needs to be used to counteract an
|44 ||<xsl:processing-instruction> ||Element, Reference, XSLT, processing-instruction |
<xsl:processing-instruction> element writes a processing instruction to the output document.
|45 ||<xsl:sort> ||Element, Reference, XSLT, sort |
<xsl:sort> element defines a sort key for nodes selected by
<xsl:for-each> and determines the order in which they are processed.
|46 ||<xsl:strip-space> ||Element, Reference, XSLT, strip-space |
<xsl:strip-space> element defines the elements in the source document for which whitespace should be removed.
|47 ||<xsl:stylesheet> ||Element, Reference, StyleSheet, XSLT |
<xsl:stylesheet> element (or the equivalent
<xsl:transform> element) is the outermost element of a stylesheet.
|48 ||<xsl:template> ||Element, Reference, Template, XSLT |
<xsl:template> element defines an output producing template. This element must have either the match attribute or the name attribute set.
|49 ||<xsl:text> ||Element, Reference, Text, XSLT |
<xsl:text> element writes literal text to the output tree. It may contain
#PCDATA, literal text, and entity references.
|50 ||<xsl:transform> ||Element, Reference, XSLT, transform |
<xsl:transform> element is exactly equivalent to the
|51 ||<xsl:value-of> ||Element, Reference, XSLT, value-of |
<xsl:value-of> element evaluates an XPath expression, converts it to a string, and writes that string to the result tree.
|52 ||<xsl:variable> ||Element, Reference, XSLT, variable |
<xsl:variable> element declares a global or local variable in a stylesheet and gives it a value. Because XSLT permits no side-effects, once the value of the variable has been established, it remains the same until the variable goes out of scope
|53 ||<xsl:when> ||Element, Reference, XSLT, when |
<xsl:when> element always appears within an
<xsl:choose> element, acting like a case statement.
|54 ||<xsl:with-param> ||Element, Reference, XSLT, with-param |
<xsl:with-param> element sets the value of a parameter to be passed into a template.