XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML: Extensible Markup Language
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSLT (eXtensible Stylesheet Language Transformation) 1.
Introduction to XSLT. What is XML? Design Goals of XML XML Format XML Declaration ElementsAttributes.
+ XSL eXtensible Stylesheet Language. + 2 XML Lecture Adapted from the work of Prof Mark Baker ACET, University of Reading.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Processing XML Processing XML using XSLT Processing XML documents with Java (DOM) Next week -- Processing XML documents with Java (SAX)
XSL Transformations (XSLT) Meghasyam Bokam April’1 st, 2002.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
Object Oriented Programming III1 XSLT Processing XML using XSLT Using XPath.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
17 Apr 2002 XML Stylesheets Andy Clark. What Is It? Extensible Stylesheet Language (XSL) Language for document transformation – Transformation (XSLT)
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
Technical Track Session XML Techie Tools Tim Bornholt.
Using XSLT and XPath to Enhance HTML Documents Reference: Roger L. Costello
Processing of structured documents Spring 2003, Part 5 Helena Ahonen-Myka.
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
Ertan Deniz Instructor.  XML Schema  Document Navigation (Xpath)  Document Transformation (XSLT)
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
CSE3201/CSE4500 Information Retrieval Systems
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Lecture 14 Extensible Stylesheet Language Transformations : XSLT.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT.
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lecture 11 XSL Transformations (part 1: Introduction)
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
ITB Web programming for E- Commerce 1 ITB6227 Programming for E-COMMERCE Lecture Presentation of XML Documents.
1 Copyright (c) [2000]. Roger L. Costello. All Rights Reserved. Using XSLT and XPath to Transform XML Documents Roger L. Costello XML Technologies.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Processing of structured documents Part 4. XML processing model zXML processor is used to read XML documents and provide access to their content and structure.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
XML Schema – XSLT Week 8 Web site:
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
CH 15 XSL Transformations 1. Objective What is XSL? Overview of XSL transformations Understanding XSL templates Computing the value of a node with xsl:value-of.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Unit 4 Representing Web Data: XML
Chapter 7 Representing Web Data: XML
Jagdish Gangolly State University of New York at Albany
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

XML for E-commerce III Helena Ahonen-Myka

In this part... n Transforming XML n Traversing XML n Web publishing frameworks

Transforming XML

Extensible Stylesheet Language n a language for transforming XML documents n an XML vocabulary for specifying the formatting of XML documents

XSLT n specifies the conversion of a document from one format to another n XSLT transformation (stylesheet) is a valid XML document n based on hierarchical tree structure n mechanism for matching patterns within the original XML document and applying formatting to that data

XML Path Language (XPath) n a mechanism for referring to the wide variety of element and attribute names and values in an XML document n also non-validated documents have to be able to be transformed: DTD cannot be used to outline the structure n tree-based: specify the path to the element

XPath n specify the part relative to the current element being processed n …or relative to the root: reference an element that is not in the current element’s scope n …or using pattern matching: find an element whose parent is element E and which has a sibling element F

XPath: examples n Match the element named Book relative to the current element: n

XPath: Examples n Match the element named Contents nested within the Book element n n Match the Contents element using an absolute path: n

XPath: examples n Match the focus attribute of the current element: n n Match the focus attribute of the Chapter element: n

XPath: examples n Match any Para element with an Appendix ancestor element: n … select=”Appendix//Para” n id(”W11”) matches the element with unique ID ´W11´ n Para[1] matches any Para element that is the first Para child element of its parent

XPath: examples n Para[last()=1] matches any Para element that is the only Para child element of its parent n Items/Item[position()>1] matches any Item element that has an Items parent and that is not the first Item child of its parent

XPath n Because often the input document is not fixed, an Xpath expression can result in the evaluation of no input data, one input element or attribute, or multiple input elements or attributes n the result of evaluating an Xpath expression is referred to as a node set.

XSL stylesheet is an XML document n must be well-formed n must contain an XML declaration n must declare all the namespaces it uses n the XSL namespace (prefix xsl:) defines elements that are needed for performing transformations

Skeleton XSL stylesheet <xsl:stylesheet xmlns:xsl=” xmlns:JavaXML=” version=”1.0”>

XSL Template n locates a particular element or set of elements within the input XML document and applies a rule or set of rules to the resulting XML

Printing all the data: <xsl:stylesheet xmlns:xsl=” xmlns:JavaXML= ” version=”1.0”>

Notes: n JavaXML:Book is the root element n xsl:apply-templates tells the processor to match the children of the current element and apply their templates n each element has a default template, which contains xsl:apply-templates and printing the data content n result (prev slide): all the data of the document is printed (unformatted)

Generating HTML Here is my HTML page!

HTML Output Here is my HTML page! Java and XML Introduction What Is It? How Do I Use It?...

xsl:value-of element Produces:... Java and XML...

Looping and iteration n xsl:for-each Table of Contents

Conditional processing: if n xsl:if : nodes that conform to both an XPath expression and some user- defined criteria n only chapters with focus=Java:

Conditional processing: choose (Java Focus) (XML Focus)

Adding elements and attributes n xsl:element, xsl:attribute XML is great! Produces: is great!

Numbering

Sorting James Clark …

Sorting

Copying parts without transforming n sometimes a part should be passed as such, without any transformation n assume: JavaXML:Copyright contains some HTML formatting:

Formatting objects (e.g.for PDF) <fo:block font-size=”24pt” text-align-last=”centered” space-before.optimum=”24pt”> Produces: <fo:block font-size=”24pt” text-align=”centered” space-before.optimum=”24pt”> Java and XML

Traversing XML n In transforming documents, random access to an document is needed n SAX cannot look backward or forward n difficult to locate siblings and children n DOM: access to any part of the tree

DOM n Level 1: navigation of content within a document n Level 2: modules and options for specific content models, such as XML, HTML, and CSS n Level 3

DOM Java bindings n Interfaces and classes that define and implement the DOM n java-binding.html n bindings often included in the parser implementations (the parser generates a DOM tree)

Parsing using a DOM parser import org.apache.xerces.parsers.DOMParser; DOMParser parser = new DOMParser(); parser.parse(uri);

Output is important n the entire document is parsed and added into the output tree, before any processing takes place n handle: org.w3c.dom.Document object = one level above the root element in the document parser.parse(uri); Document doc = parser.getDocument();

Printing a document Private static void printTree(Node node) { switch (node.getNodeType()) { case Node.DOCUMENT_NODE: // Print the contents of the Document object break; case Node.ELEMENT_NODE: // Print the element and its attributes break; case Node.TEXT_NODE:...

…the Document node Case Node.DOCUMENT_NODE: System.out.println(” \n”); Document doc = (Document)node; printTree(doc.getDocumentElement()); break;

… elements Case Node.ELEMENT_NODE: String name= node.getNodeName(); System.out.print(”<” + name); // Print out attributes… (see next slide…) System.out.println(”>”); // recurse on each child NodeList children = node.getChildNodes(); if (children != null) { for (int i=0; i<children.getLength(); i++) { printTree(children.item(i)); } System.out.println(” ”);

… and their attributes case Node.ELEMENT_NODE: String name = node.getNodeName(); System.out.print(”<” + name); NamedNodeMap attributes = node.getAttributes(); for (int i=0; i<attributes.getLength(); i++) { Node current = attributes.item(i); System.out.print(” ” + current.getNodeName() + ”=\”” + current.getNodeValue() + ”\””); } System.out.println(”>”);...

…textual nodes case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: System.out.print(node.getNodeValue()); break;

Web publishing frameworks n See: chapter/ch09.html