XSL stands for Extensible Stylesheet Stylesheets are used to manage organization and presentation of data Implemented as an XML language Rules of XML apply Made up of XSL-FO (Formatting Objects) XSLT (Transformations) XSL
XSL-FO focused on presentation to screen and paper Not well-supported by browsers XSLT emphasizes re-organization of data Typically used for presentation but can also be used for conversion of data storage format XSLT is a declarative language Similar to SQL, describe results not steps XSL Implementation
Cascading Style Sheets used to separate presentation from data XSLT used to change – transform – data Convert an XML document to XHTML Can use both together XSLT v CSS
XSL requires several steps XML processor reads document Creates document tree XSL processor applies rules from stylesheet Rules applied to document tree Rules applied by using pattern matching Identify nodes to apply rules to Rules are stored as templates Using XSL
XSL works by using an Input Tree Input Tree comes from XML processor Process of changing input values is call Tree Transformation Result of transformation is the Result Tree Result Tree can include XML HTML (must adhere to XML rules, i.e., XHTML) Formatting Objects XSL Process
Extensible Stylesheet Transformations is method of changing (transforming) XML based on rules of a stylesheet Xpath allows manipulation of parts of XML document Not XML-based Provides compact references Useful in URI’s, attributes Document must exist as nodes (previously parsed) XSLT
Templates are definitions of rules, organization Patterns define values searching for (where to apply templates) Expressions allow use of functions using nodes as inputs When referring to document attributes preface name with “@” XSLT Constructs
< xsl:stylesheet > is root element Uses namespace to define elements, attributes valid in a stylesheet < xsl:template > defines the rules/ transformations to apply Match attribute specifies pattern to apply rules to Functions similar to criteria < xsl:apply -templates> applies the rules defined for a particular element Select attribute specifies elements to apply to XSLT Elements
< xsl:value -of> returns the value of a specified node, function Select attribute specifies value source < xsl:copy > copies a node to the result tree without any child nodes or attributes < xsl:copy -of> copies a node and child/attribute nodes < xsl:output > controls the result tree method=“ xml|html|text ” XSLT Elements – 2
< xsl:if > provides a boolean test to determine processing < xsl:choose > offers an IF ... THEN ... ELSE construct < xsl:for -each> allows each node in a group to be processed < xsl:sort > specifies order for a group of nodes XSLT Elements – 3
Match can use node name current position (represented by “.”) relative position (for example, parent = “..”) Specifies where the transformation to be applied Match