1. Trang chủ
  2. » Công Nghệ Thông Tin

XSLT processing with Java ppsx

37 118 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • XSLT processing with Java

  • Agenda

  • Extensible Stylesheet Language Transformations

  • Diagram

  • Ảnh chiếu 5

  • XSLT Parser

  • XSLT installation and Setup

  • Understanding XPath

  • Location Paths

  • Simple location paths

  • Simple location paths (continued)

  • Ảnh chiếu 12

  • Ảnh chiếu 13

  • Matching with Predicates

  • Ảnh chiếu 15

  • Matching with Predicates (continued)

  • Ảnh chiếu 17

  • XSLT Stylesheet Elements

  • Ảnh chiếu 19

  • XSLT template Element

  • XSLT apply-templates Element

  • XSLT value-of Element

  • XSLT value-of Element (continued)

  • XSLT for-each Element

  • XSLT if Element

  • XSLT choose Element

  • XSLT output Element

  • Steps for translating a document

  • Ảnh chiếu 29

  • Step 1: specific a transformer

  • Specific a transformer, Example

  • Step 2: Creating a Transformer Factory

  • Step 3: Creating a Transformer

  • Step 4: Invoke the Transformer

  • Advantages and Disadvantages

  • Summary

  • Slide 37

Nội dung

XSLT processing with Java GV: Vũ Đình Hồng Khoa: CNTT – TỨD Company Logo Agenda 5. An XSL transformer 4. Understanding XPath notation 3. Processing elements in XSLT templates 2. XSLT installation and setup 1. XSLT Overview Company Logo Extensible Stylesheet Language Transformations  XSLT applies user-defined transformations to an XML document  Transformed output can be :HTML, XML, WML …  www.ecrion.com  XSLT versions  XSLT 1.0 (11/1999)  XSLT 2.0 (11/2002) • Namespace addition  Official web for XSLT • http://www.w3.org/Style/XSL/ Company Logo Diagram XSL transform process Company Logo Extensible Stylesheet Language Transformations  XSL is a language for expressing stylesheets  XSLT • Transformation of XML document • http://www.w3.org/TR/xslt  XPath • An expression language used by XSLT to locate elements and/or attributes within an XML document • http://www.w3.org/TR/xpath  XSL-FO (Formatting Objects) • Specific the formatting properties for rendering the document • http://www.w3.org/TR/XSL/XSL-FO/ Company Logo XSLT Parser  Apache Xalan  http://xml.apache.org/xalan/  Oracle  http://technet.oracle.com/tech/xml/  Saxon  http://saxon.sourceforget.net/  Microsoft’s XML Parser 4.0 (MSXML)  http://www.microsoft.com/xml Company Logo XSLT installation and Setup  All the necessary classes are included with jdk 1.4  See javax.xml.transform package  XSL Transformation 1. Use • XPath: to identify (select) parts of an XML document • XSLT templates: to apply transformation 1. Requires • Well formed XML document • XSL document (stylesheet) that contains formatting and transformation templates • XSLT Parser to perform the transformation Company Logo Understanding XPath  XPath is an expression language to:  Identify parts (location paths) of the input document • Commonly used in match and select attributes in XSLT document <xsl: template match = “/name/first”> . . . </xsl>  Test boolean conditions  Manipulate strings  Perform numerical calculations Company Logo Location Paths  Location paths are interpreted with respect to a context  Or simply, the node in the tree from which the expression is evaluated  The evaluated expression represents a set of nodes matching the condition  Possibly the empty set if no occur  A location path consists of one or more location steps separated by / or //  Paths can be relative or absolute Company Logo Simple location paths  Matching the root node  A leading / indicates the root node <xml : template match=“/”> <!– Match all the root node > </xml : template>  Matching all children  Use the * wild card to select all element nodes in the current context <xml : template match=“*”> <!– Match all children nodes > </xml : template> [...]... language Can’t change the value of variables (requires recursion) Company Logo Summary  Xslt specific how to transform XML into HTML, XML, or other document formats  XPath pattern selects a set of node for processing  Control conditional processing through XSLT templates (elements)  Apache Xalan -J in a popular XSLT compliant transformer  InputSource document is typically a File or a String (StringReader)... Logo XSLT for-each Element Xslt: for-each select =“expression”  Process each node selected by the xpath expression Larry Brown Marty Hall Company Logo XSLT if Element Xslt: ... command line –D option java –Djavax.xml.transform.TransformerFactory= weblogic.apache.xalan.processor.TransformerFactoryImpl …  Use the Apache Xalan transformer otherwise public static void main (String[] args){ String jaxpPropertyName = “javax.xml.transform.TransformerFactory”; if (System.getProperty(jaxpPropertyName)==null){ String apacheXercesPropertyValue = “org.apache.xalan.xsltc.trax.TransformerFactoryImpl”;... template> Company Logo XSLT apply-templates Element Xslt: apply-templates  Applies matching templates to the children of the context node Ktee Siamese Company Logo XSLT value-of Element Xslt: value-of... Company Logo XSLT choose Element Xslt: choose  Select any number of the alternatives  Instruction to use in place of if-else or switch construct found in other programming languages Missing value! Company Logo XSLT output Element Xslt: output  Control the format... template> Company Logo Matching with Predicates Use []: choose node in order - /AAA/BBB[1]: Node BBB level 1 (child of AAA) content - /AAA/BBB[2]: Node BBB level 2 (child of AAA) - /AAA/BBB[last()]: Node BBB last - /AAA/BBB[CCC=“content”]: Node BBB level 3 (have child node CCC with content ) Company Logo Matching with Predicates (continued) Matching... Company Logo XSLT Stylesheet Elements Matching and selection templates  Xsl: template  Xsl: apply-templates  Xsl: value-of Branching elements  Xsl: for-each  Xsl: if  Xsl: choose Company Logo Diagram StyleSheet Element Branching elements Matching and Selection templates XSL : template XSL : applytemplate XSL : value-of XSL : for-each XSL : if XSL : choose Company Logo XSLT template Element Xslt :... document Company Logo Step 1: specific a transformer 1 Approaches to specific a transformer  Set a system property for Javax.xml.transform.TransformerFactory  Specific the parser in jre_dir/lib/jaxp/properties  Through the J2EE Services API and the class specified in META-INF/services/javax.xml.transform.TransformerFactory  Use system-dependant default parser (check documentation) Company Logo Specific...  XSLT has no if-else construct (use choose) Company Logo XSLT. .. discount attribute > with a value of 3145 > Company Logo Matching with Predicates (continued) Use @: access to properties - /AAA/BBB[[@id]: Nodes BBB have properties . XSLT processing with Java GV: Vũ Đình Hồng Khoa: CNTT – TỨD Company Logo Agenda 5. An XSL transformer 4. Understanding XPath notation 3. Processing elements in XSLT templates 2. XSLT installation. output can be :HTML, XML, WML …  www.ecrion.com  XSLT versions  XSLT 1.0 (11/1999)  XSLT 2.0 (11/2002) • Namespace addition  Official web for XSLT • http://www.w3.org/Style/XSL/ Company Logo Diagram XSL. expressing stylesheets  XSLT • Transformation of XML document • http://www.w3.org/TR /xslt  XPath • An expression language used by XSLT to locate elements and/or attributes within an XML document • http://www.w3.org/TR/xpath  XSL-FO

Ngày đăng: 07/08/2014, 15:21

w