XSLT Can Be One of the Following Five Types

Total Page:16

File Type:pdf, Size:1020Kb

XSLT Can Be One of the Following Five Types XPath Quick Reference Node Types Nodes can be of the following types: NodeType Name String Value root Concatenation of alI text nodes in the document element Element name Concatenation of alI text nodes descended from the element attribute Attribute name Attribute value text Text cornrnent Text held within the comment processing Processing Text in the processing instruction after the space after the instruction target targetname narnespace Namespace prefix Namespace URI Object Types Values in XSLT can be one of the following five types: Object Type Description boolean true or false number A floating-point number: a double-precision 64-bit format IEEE 754 value Table continued on following page Appendix A Object Type Description string A sequence of XML characters node set An unordered collection of nodes result tree fragment The root node of a generated node tree The various object types can be converted to each other by the following rules. Object Boolean Number String boolean 1 if the boolean is , true' if the boolean is true, O if the true, 'false' if the boolean is false boolean is false number false ifthe A string version of the number is O or number with no leading or NaN, otherwise trailing zeros; 'NaN' if the true number is NaN, , Infinity' if the number is infinity, and '-Infinity' ifthe number is negative infinity string false ifthe The number held string is an empty by the string, as string, otherwise long as it is a valid true XPath number (which doesn't include exponents or grouping separators) ; otherwise NaN node set true if the node The result of The string value of the first set holds nodes; converting the node in the node set false ifthe string value of the node set is empty first node in the node set to a number result tree true The result of The string value of the re suit fragment converting the tree fragment string value of the re suIt tree fragment to a number Booleans, numbers, and strings cannot be converted to node sets or result tree fragments. 694 XPath Quick Reference Paths Paths are made up of a number of steps, separated by / s. Each step is made up of an optional axis (defaults to child), a node test, and any number of predicates (held in square brackets). Axes Axes dictate the relationship between the context node and the selected nodes. The direction of an axis determines how the posi tion () of a node is calculated - forward axes look at document order, reverse axes look at reverse document order. Axis Direction Description self Forward Selects the context node itself ehild Forward Selects the children of the context node parent Reverse Selects the parent of the context node attribute Forward Selects the attributes of the context node deseendant Forward Selects the descendants of the context node at any level deseendant- Forward Selects the descendants of the context node, and the or-self context node itself aneestor Reverse Selects the ancestors of the context node aneestor-or-self Reverse Selects the ancestors of the context node, and the context node itself following-sibling Forward Selects the siblings of the context node that follow the context node in document order preeeding-sibling Reverse Selects the siblings of the context node that precede the context node in document order following Forward Selects the nodes (asi de from attribute and namespace nodes) that follow the context node in document order and that are not descendants of the context node preeeding Reverse Selects the nodes (asi de from attribute and namespace nodes) that precede the context node in document order and that are not ancestors of the context node namespaee Forward Selects the namespace nodes on the context node 695 Appendix A Node Tests Node tests match different kinds of nodes as follows: Node Test Description node() Matches nodes of all types * Matches elements with any name (or attributes if you're using the attribute axis) name Matches elements with the given name (or attribute if you're using the attribute axis) text( ) Matches text nodes comment () Matches comment nodes processing-instruction() Matches processing instruction nodes processing­ Matches processing instruction nodes with the given instruction('target') target Abbreviated Syntax You can use several abbreviations in XPath expressions, as described in the following table. Abbreviation Full Equivalent Description self: :node() The context node parent: :node () The parent of the context node II /descendant-or­ SuppIies quick access to descendants of the context self: :node () / node @ attribute: : Shortens expressions that access attributes Operators The operators in XPath can be spIit into four groups: o Logical operators O Comparisons O Numerical operators O N ode set operators 696 XPath Quick Reference The precedence of the operators (from lowest to highest) is as follows: 1. or 2. and 3. =, != 4. <=,<,>=,> 5. +, - 6. *,div,mod 7. unary - 8. Logical Operators Operator Description or true if either operand is true when converted to booleans; the right operand is not evaluated if the Ieft operand is true and true if both operands are true when converted to booleans; the right operand is not evaluated ifthe Ieft operand is false Comparisons Operator Description Equal to != Not equal to < Less than <= Less than or equal to > Greater than >= Greater than or equal to Comparisons between node sets and values are true if the comparison is true for the string value of any node in the node set. 697 Appendix A The numeric comparisons «, <=, >, and >=) can only be used to do numeric comparisons - you can't use them to test whether one string is alphabetically less than another string. Numerical Operators Operator Description + Addition Subtraction * Multiplication div Floating-point division mod Remainder from integer division unary - Negation Node Set Operator Operator Description Creates a union of two node sets Functions XPath and XSLT together define the following functions: boolean() Syntax: boolean boolean (object) See also: string (), number () Converts the argument to a boolean value (either true or false). Usually this is done automatically, for example in test attributes. ceiling() Syntax: number ceiling (number) See also: floor (), round () Rounds the argument up to the nearest integer. For negative numbers, this means rounding nearer to 0, so ceiling (-1. 5) is -1. 698 XPath Quick Reference concat() Syntax: string concat (string, string+) Concatenates the strings passed as arguments into a single string. contains() Syntax: boolean contains (string, string) See also: starts-with () Returns true if the string passed as the first argument contains the string passed as the second argument or if the second argument is an empty string, and false otherwise. count() Syntax: number count (node-set) See also: last ( ), posi tion (), <xsl: number> Counts the number of nodes in the node set passed as the argument. current() Syntax: node-set current ( ) See also: the path . Returns the current node - the node that's current1y being processed within the <xsl: for-each> or <xsl: template> as opposed to the context node, which is the node currently being looked at within an XPath. document() Syntax: node-set document (object, node-set?) If the first argument is a string, returns the node found at the URL specified by that string (usualIy the root node of a document). The URL is resolved relative to the location of the file containing the first node in the node set passed as the second argument (which is usualIy used to resolve the URL relative to the source document). If the second argument is- missing, the URL is resolved relative to the stylesheet itself. If the first argument is a node set, then the result is a node set containing alI the nodes that are retrieved by calling the document () function with the string values of the nodes in the node set. element-available( ) Syntax: boolean element-available (string) See also: function-available ( ), <xsl: fallback> 699 Appendix A Returns true if the processor supports the extension element or new XSLT instruction named by the string passed as the argument. The string should be a qualified name, with a prefix. false() Syntax: boolean false ( ) See also: true ( ), boolean ( ) Returns false. floorO Syntax: number floor (number) See also: ceiling (), round () Rounds the number down to the nearest integer. If the number is negative, then it gets rounded away from zero, so floor (-1.5) returns -2. format-number( ) Syntax: string format-number (number, string, string?) See also: number (), <xsl: decimal-format>, <xsl: number> Returns the number passed as the first argument formatted according to the format pattern passed as the second argument. The format pattern usually contains # to mean an optional digit, O to indicate a required digit, . to indicate the decimal point, and , to indicate a grouping separator. For example, format-number (1234.5, '#, ##0.00' ) returns 1,234.50. If the third argument is specified, it gives the name of a decimal format, declared with the <xsl: decimal-format> element, which can de fine other characters to be used instead of #, O, " and function-avai lable() Syntax: boolean function-available (string) See also: element-available ( ) Returns true if the processor supports the function named by the argument string. The string usually includes a prefix to test for the availability of extension functions. generate-id( ) Syntax: string generate-id (node-set?) Returns an ID for the first node in the node set passed as the argument which is both unique and a valid XML ID. If no argument is given, it returns a unique ID for the context node. The unique IDs are not stable - they are different from processor to processor, and even for the same processor operating over the same stylesheet with the same source XML document.
Recommended publications
  • XML a New Web Site Architecture
    XML A New Web Site Architecture Jim Costello Derek Werthmuller Darshana Apte Center for Technology in Government University at Albany, SUNY 1535 Western Avenue Albany, NY 12203 Phone: (518) 442-3892 Fax: (518) 442-3886 E-mail: [email protected] http://www.ctg.albany.edu September 2002 © 2002 Center for Technology in Government The Center grants permission to reprint this document provided this cover page is included. Table of Contents XML: A New Web Site Architecture .......................................................................................................................... 1 A Better Way? ......................................................................................................................................................... 1 Defining the Problem.............................................................................................................................................. 1 Partial Solutions ...................................................................................................................................................... 2 Addressing the Root Problems .............................................................................................................................. 2 Figure 1. Sample XML file (all code simplified for example) ...................................................................... 4 Figure 2. Sample XSL File (all code simplified for example) ....................................................................... 6 Figure 3. Formatted Page Produced
    [Show full text]
  • XML Information Set
    XML Information Set XML Information Set W3C Recommendation 24 October 2001 This version: http://www.w3.org/TR/2001/REC-xml-infoset-20011024 Latest version: http://www.w3.org/TR/xml-infoset Previous version: http://www.w3.org/TR/2001/PR-xml-infoset-20010810 Editors: John Cowan, [email protected] Richard Tobin, [email protected] Copyright ©1999, 2000, 2001 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply. Abstract This specification provides a set of definitions for use in other specifications that need to refer to the information in an XML document. Status of this Document This section describes the status of this document at the time of its publication. Other documents may supersede this document. The latest status of this document series is maintained at the W3C. This is the W3C Recommendation of the XML Information Set. This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the file:///C|/Documents%20and%20Settings/immdca01/Desktop/xml-infoset.html (1 of 16) [8/12/2002 10:38:58 AM] XML Information Set Web. This document has been produced by the W3C XML Core Working Group as part of the XML Activity in the W3C Architecture Domain.
    [Show full text]
  • Renderx XEP User Guide XEP User Guide
    RenderX XEP User Guide XEP User Guide © Copyright 2005-2019 RenderX, Inc. All rights reserved. This documentation contains proprietary information belonging to RenderX, and is provided under a license agreement containing restrictions on use and disclosure. It is also protected by international copyright law. Because of continued product development, the information contained in this document may change without notice.The information and intellectual property contained herein are confidential and remain the exclusive intellectual property of RenderX. If you find any problems in the documentation, please report them to us in writing. RenderX does not warrant that this document is error- free. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means - electronic, mechanical, photocopying, recording or otherwise - without the prior written permission of RenderX. RenderX Telephone: 1 (650) 328-8000 Fax: 1 (650) 328-8008 Website: http://renderx.com Email: [email protected] Table of Contents 1. Preface ................................................................................................................... 9 1.1. What©s in this Document? .............................................................................. 9 1.2. Prerequisites ................................................................................................ 9 1.3. Acronyms ................................................................................................... 10 1.4. Technical Support
    [Show full text]
  • Xpath Overview
    XXPPAATTHH OOVVEERRVVIIEEWW http://www.tutorialspoint.com/xpath/xpath_overview.htm Copyright © tutorialspoint.com XSL Before learning XPath, we should first understand XSL which stands for EXtensible Stylesheet Langauge. It is similar to XML as CSS is to HTML. Need for XSL In case of HTML document, tags are predefined such as table, div, span and browser knows how to add style to them and display them using CSS styles. But in case of XML document, tags are not predefined. In order to understand and style an XML document, World Wide Web Consortium W3C developed XSL which can act as XML based Stylesheet Language. An XSL document specifies how a browser should render an XML document. Following are the main parts of XSL. XSLT - used to transform XML document into various other types of document. XPath - used to navigate XML document. XSL-FO - used to format XML document. What is XPath The XPath is an official recommendation of the World Wide Web Consortium W3C. It defines a language to find information in an XML file. It is used to traverse elements and attributes of an XML document. XPath provides various types of expressions which can be used to enquire relevant information from the XML document. Structure Definations - XPath defines the parts of an XML document like element, attribute, text, namespace, processing-instruction, comment, and document nodes Path Expressions XPath provides powerful path expressions select nodes or list of nodes in XML documents. Standard FunctionsXPath provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.
    [Show full text]
  • Document Object Model †DOM‡ Level 1 Specification
    Document Object Model (DOM) Level 1 Specification REC-DOM-Level-1-19981001 Document Object Model (DOM) Level 1 Specification Version 1.0 W3C Recommendation 1 October, 1998 This version http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001 http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.ps http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.pdf http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.tgz http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.zip http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.txt Latest version http://www.w3.org/TR/REC-DOM-Level-1 Previous versions http://www.w3.org/TR/1998/PR-DOM-Level-1-19980818 http://www.w3.org/TR/1998/WD-DOM-19980720 http://www.w3.org/TR/1998/WD-DOM-19980416 http://www.w3.org/TR/WD-DOM-19980318 http://www.w3.org/TR/WD-DOM-971209 http://www.w3.org/TR/WD-DOM-971009 WG Chair Lauren Wood, SoftQuad, Inc. Editors Vidur Apparao, Netscape Steve Byrne, Sun Mike Champion, ArborText Scott Isaacs, Microsoft Ian Jacobs, W3C Arnaud Le Hors, W3C Gavin Nicol, Inso EPS Jonathan Robie, Texcel Research Robert Sutor, IBM Chris Wilson, Microsoft Lauren Wood, SoftQuad, Inc. Principal Contributors Vidur Apparao, Netscape Steve Byrne, Sun (until November 1997) Mike Champion, ArborText, Inc. 1 Status of this document Scott Isaacs, Microsoft (until January, 1998) Arnaud Le Hors, W3C Gavin Nicol, Inso EPS Jonathan Robie, Texcel Research Peter Sharpe, SoftQuad, Inc. Bill Smith, Sun (after November 1997) Jared Sorensen, Novell Robert Sutor, IBM Ray Whitmer, iMall Chris Wilson, Microsoft (after January, 1998) Status of this document This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a W3C Recommendation.
    [Show full text]
  • Xpath Is a Syntax for Defining Parts of an XML Document. Xpath Uses Path Expressions to Navigate in XML Documents
    XML PROGRAMMING: SUB CODE- 24662 QPCODE: -780 PART-A (Each question carries 1 marks, Answer any FIFTEEN(15) questions) 1.Mention any two part of XML tree structure. Root node Leaf node 2. Write any two use of XPath. (Any Two) XPath is a syntax for defining parts of an XML document. XPath uses path expressions to navigate in XML documents. XPath contains a library of standard functions. XPath is a major element in XSLT and in XQuery. XPath is a W3C recommendation. 3. Define WML. Wireless markup language (WML) is a markup language for wireless devices that adhere to Wireless Application Protocol (WAP) and have limited processing capability. 4.What is an absolute location path? Location path specifies the location of node in XML document. This path can be absolute or relative. If location path starts with root node or with '/' then it is an absolute path. Following are few of the example locating the elements using absolute path. 5.Write the limitation of schema language. Poor support for xml namespace Poor data typing Limited content model description It supports only the text string data type. Limited possibilities to express the cardinality for elements. 6.Mention any two declaration that can be used in DTDs. (Any Two) <!ELEMENT letter (date, address, salutation, body, closing, signature)> Element – letter Child Elements - date, address, salutation, body,closing,signature <!ELEMENT Name (#PCDATA)> #PCDATA – parsed character data - Data contains only text 1 <!ELEMENT Street (#CDATA)> #CDATA – Character Data - Data may contain text, numbers and other character. <!ELEMENT br EMPTY> EMPTY – It has no content.
    [Show full text]
  • Introduction to XSL Max Froumentin - W3C
    Introduction to XSL Max Froumentin - W3C l Introduction to XSL l XSL and other W3C specs l XML Documents l Transformations: XSLT l Styling XML Documents l General-purpose XSLT l XSL l Templates l Example I: Hamlet l XSLT statements l Example II: Mixed Writing Modes l "Play" to HTML l Example III: database l XPath l Other Examples l Formatting Objects basics l How do they do that? l Pages l The XSL Process(es) l The area model l Server-Side/Client-Side XSL l Block/inline areas Introduction to XSL Max Froumentin - W3C l Formatting Objects: l Properties l Example: Play to FO l Top-level Template l I18N Formatting Objects and Properties l Other Formatting Objects l Example: mixed writing modes l If you are still interested... Introduction to XSL In a nutshell: XSL is a W3C specification that describes a method for visually presenting XML documents. This tutorial will cover: l An overview of the XSL spec (including XSLT and XPath) l Examples of various use cases l Relationship with other XML technologies l A detailed example These slides are available at http://www.w3.org/People/maxf/XSLideMaker/ Introduction to XSL Max Froumentin - W3C 1 of 30 XML Documents l XML (eXtensible Markup Language) adds information to text files, using tags and attributes [example1], [example2] l Tag names are defined for a specific document type. l Uses the Unicode character set l Designed to be easily processed by machine while remaining readable. Introduction to XSL Max Froumentin - W3C 2 of 30 Styling XML Documents l XML documents are ideally semantic.
    [Show full text]
  • Extensible Markup Language
    XML, XPath, and XSLT Jim Fawcett CSE 681 – Software Modeling and Analysis Fall 2016 Topics • XML is an acronym for eXtensible Markup Language. – Its purpose is to describe structured data • XPath is a language for navigating through an XML document. – It’s used to select specific pieces of information from the document • XSLT is a language for transforming XML into something else. – Often used to generate HTML or another XML document. 3 Introduction to XML • XML is a tagged markup language designed to describe data: LectureNote.xml • XML has only a couple of predefined tags – All the rest are defined by the document designer. – XML can be used to create languages • XML is commonly used to: – Define data structures. – Define messages – Create web pages 4 Validation • To be correct XML a set of markup needs only to be well formed, see Well-Formed XML. • To determine if an XML document belongs to some document type, XML uses either: – Document Type Definition (DTD) – XML Schema XML that satisfies a Schema or DTD is said to be valid. • DTDs and Schemas define allowable tags, attributes, and value types, and may also specify where these may occur in the document structure. – XML schemas are written in XML, DTDs are not. 5 XML Element • Elements are building blocks for XML documents • Element sytax: – Elements are composed of tags, attributes, and a body: <tag *[attribName=“value”]>body</tag> example: <book author=“Prosise”>Programming .Net</book> – All parts of the element are unicode text – body may contain both plain text and markup, e.g. lower level elements.
    [Show full text]
  • Using XML, XSL, and CSS in a Digital Library
    Using XML, XSLT, and CSS in a Digital Library Timothy W. Cole, William H. Mischo, Robert Ferrer, and Thomas G. Habing Grainger Engineering Library Information Center University of Illinois at Urbana-Champaign Abstract The functionality of formats available for the online representation of text continues to evolve. ASCII and bit-mapped image representations of text objects (e.g., journal articles) have been superceded by more functional representations such as application- specific word processing formats and proprietary and non-proprietary information interchange formats (e.g., Adobe PDF, Microsoft RTF, TeX, SGML). Standards like SGML and now XML, which support the representation of a text as an “ordered hierarchy of content objects,” are arguably the best and most sophisticated models available for representing text objects.1 Ratified as an international standard in 1989, SGML has become a well-established approach for encoding text. However SGML’s complexity and requirements for specialized and expensive tools to implement SGML- based systems have limited its scope as an information interchange standard, particularly in today’s Web-dominated environment. XML, established as a W3 Consortium Recommendation in February 1998, strives to make the best features of SGML more accessible to Web authors and publishers, but the XML specification itself doesn't explicitly deal with the presentation of content, nor does it address document object transformation. These issues must be addressed through the use of CSS and XSLT (both more recent W3 Consortium Recommendations). It is necessary to use these three technologies in concert to create powerful and robust text applications on the Web. This paper describes how XML, XSLT, and CSS can be used in a digital library application.
    [Show full text]
  • XSL Transformations
    XSL Transformations Previously we used DOM and SAX to extract data from an XML document and present that information as plain text, as HTML, or organized in a new XML document. XSLT supplies another way to perform these kinds of tasks. XSL (Extensible Stylesheet Language) is an application of XML that provides tools for transforming an XML document into some other textual form. Features of XSLT • XSL is written entirely in XML. • Its elements are found in a namespace with the URI "http://www.w3.org/1999/XSL/Transform". • XSL is a declarative programming language: we describe what we want, but we do not prescribe how to get it. SQL takes the same approach to programming. • It is complete programming language with variables, methods, and parameters but no assignment command to change the value of a variable. • The result of a transformation will be another XML document, an HTML document, or a text document. • The XSLT processor parses the XML document to produce a source tree that the transformation definition works on to produce a result tree. • XSLT uses XPath expressions to specify nodes and values in the source tree. XSLT Copyright 2006 by Ken Slonneger 1 XSLT Process Structure of an XSLT Document <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- series of templates that match items in the source tree and define the content to be placed in the result tree --> </xsl:stylesheet> 2 Copyright 2006 by Ken Slonneger XSLT Simple XSLT Examples The basic behavior of the XSLT processor will be illustrated by a series of simple examples that work on the XML document phoneA.xml.
    [Show full text]
  • The Extensible XML Information Set
    The Extensible XML Information Set Erik Wilde Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology, Z¨urich TIK Report 160 (February 2003) Abstract XML and its data model, the XML Information Set, are used for a large number of applications. These applications have widely varying data models, ranging from very sim- ple regular trees to irregularly structured graphs using many different types of nodes and vertices. While some applications are sufficiently supported by the data model provided by the XML Infoset itself, others could benefit from extensions of the data model and assistance for these extensions in supporting XML technologies (such as the DOM API or the XSLT programming language). In this paper, we describe the Extensible XML Information Set (EXIS), which is a reformulation of the XML Infoset targeted at making the Infoset easier to extend and to make these extensions usable in higher-level XML technologies. EXIS provides a framework for defining extensions to the core XML Infoset, and for identifying these extensions (using namespace names). Higher-level XML tech- nologies (such as DOM or XPath) can then support EXIS extensions through additional interfaces, such as a dedicated DOM module, or XPath extension mechanisms (extension axes and/or functions). In order to make EXIS work, additional efforts are required in these areas of higher-level XML technologies, but EXIS itself could be used rather quickly to provide a foundation for well-defined Infoset extensions, such as XML Schema’s PSVI contributions, or the reformulation of XLink as being based on a data model (rather than a syntax).
    [Show full text]
  • Use Cascading Stylesheets to Display XML Combine XSLT and CSS to Process XML
    Display XML with Cascading Stylesheets, Part 3: Use Cascading Stylesheets to display XML Combine XSLT and CSS to process XML Skill Level: Intermediate Uche Ogbuji ([email protected]) Principal consultant Fourthought Inc. 20 Jun 2005 In parts 1 and 2 of this tutorial series, Uche Ogbuji has shown how to use Cascading Stylesheets (CSS) to display XML in browsers, presenting basic and advanced techniques. Although some people see XSLT and CSS as opposing technologies, they are actually very complementary. There are many XML rendering tasks that CSS cannot handle, and is not designed to handle. XSLT can be used for many such tasks, and can even be used to manage the CSS that is still used to fine-tune the presentation. This tutorial covers techniques for using XSLT to process XML in association with CSS. Section 1. Tutorial introduction CSS versus XSLT In the previous tutorials in this series (Part 1 and Part 2), Uche Ogbuji showed how to use Cascading Stylesheets (CSS) to display XML in browsers, presenting basic techniques and advanced topics. Some discussions present XSLT and CSS as opposing technologies for presenting XML, but I find little reason to view them this way. Each one offers far more to complement than to counter the other. This cooperation has many manifestations, but the most common is using XSLT to generate CSS and include it in the output. XSLT provides more algorithmic power than CSS, so these two technologies form a very rich combination. This tutorial builds on its predecessors to explore this combination. Use Cascading Stylesheets to display XML © Copyright IBM Corporation 1994, 2008.
    [Show full text]