Roy Tennant California Digital Library

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

What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
XSL XSLT and XPath 11-Apr-17.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XML Unit 6 October 31. XML, review XML is used to markup data Used to describe information Uses tags like HTML –But all tags are user-defined –Must be.
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
IS 373—Web Standards Todd Will
XSL Unit 6 November 2. XSL –eXtensible Stylesheet Language –Basically a stylesheet for XML documents XSL has three parts: –XSLT –XPath –XSL-FO.
Tutorial 11 Creating XML Document
XML Primer. 2 History: SGML vs. HTML vs. XML SGML (1960) XML(1996) HTML(1990) XHTML(2000)
Introduction to XML Extensible Markup Language
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
XML – Extensible Markup Language Sivakumar Kuttuva & Janusz Zalewski.
WPF chapter 15 Dr. John Abraham Professor UTPA. WPF –an introduction WPF provides a single platform capable of handling graphics, audio and video. WPF.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
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.
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.
WORKING WITH XSLT AND XPATH
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,
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Session IV Chapter 9 – XML Schemas
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Presentation Topic: XML and ASP Presented by Yanzhi Zhang.
Lecture 11 XSL Transformations (part 1: Introduction)
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
XML Introduction to XML Extensible Markup Language.
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.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
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.
Beyond HTML: Extensible Markup Language (XML)
Kynn Bartlett 11 April 2001 STC San Diego The HTML Writers Guild Copyright © 2001 XML, XHTML, XSLT, and other X-named specifications.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
XML Introduction Bill Jerome.
Unit 4 Representing Web Data: XML
Extensible Markup Language XML
XML QUESTIONS AND ANSWERS
XML in Web Technologies
Extensible Markup Language XML
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
Chapter 7 Representing Web Data: XML
XML Problems and Solutions
Allyson Falkner Spokane County ISD
More XML XML schema, XPATH, XSLT
Unit 6 - XML Transformations
Presentation transcript:

Roy Tennant California Digital Library XML in a Nutshell Roy Tennant California Digital Library

Outline XML Basics Displaying XML with CSS Transforming XML with XSLT Serving XML to Web Users Resources Tips & Advice

Documents XML is expressed as “documents”, whether an entire book or a database record Must haves: At least one element Only one “root” element Should haves: A document type declaration; e.g., <?xml version="1.0"?> Namespace declarations Can haves: One or more properly nested elements Comments Processing instructions

Elements Must have a name; e.g., <title> Names must follow rules: no spaces or special characters, must start with a letter, are case sensitive Must have a beginning and end; <title></title> or <title/> May wrap text data; e.g., <title>Hamlet</title> May have an attribute that must be quoted; e.g., <title level=“main”>Hamlet</title> May contain other “child” elements; e.g., <title level=“main”>Hamlet <subtitle> Prince of Denmark</subtitle></title>

Element Relationships Every XML document must have only one “root” element All other elements must be contained within the root An element contained within another tag is called a “child” of the container element An element that contains another tag is called the “parent” of the contained element Two elements that share the same parent are called “siblings”

The Tree <?xml version="1.0"?> <book> <author> <lastname>Tennant</lastname> <firstname>Roy</firstname> </author> <title>The Great American Novel</title> <chapter number=“1”> <chaptitle>It Was Dark and Stormy</chaptitle> <p>It was a dark and stormy night.</p> <p>An owl hooted.</p> </chapter> </book> Root element Parent of <lastname> Child of <author> Siblings

Comments & Processing Instructions You can embed comments in your XML just like in HTML: <!-- Whatever is here (whether text or markup) will be ignored on processing --> A processing instruction tells the XML parser information it needs to know to properly process an XML document: <?xml-stylesheet type="text/css" href="style2.css"?>

Well-Formed XML Follows general tagging rules: All tags begin and end But can be minimized if empty: <br/> instead of <br></br> All tags are case sensitive All tags must be properly nested: <author> <firstname>Mark</firstname> <lastname>Twain</lastname> </author> All attribute values are quoted: <subject scheme=“LCSH”>Music</subject> Has identification & declaration tags Software can make sure a document follows these rules

Valid XML Uses only specific tags and rules as codified by one of: A document type definition (DTD) A schema definition Only the tags listed by the schema or DTD can be used Software can take a DTD or schema and verify that a document adheres to the rules Editing software can prevent an author from using anything except allowed tags

Namespaces A method to keep metadata elements from different schemas from colliding Example: the tag <name> may have a very different meaning in different standards A namespace declaration specifies from which specification a set of tags is drawn <mets xmlns="http://www.loc.gov/METS/" xsi:schemaLocation= "http://www.loc.gov/standards/mets/mets.xsd">

Character Encoding XML is Unicode, either UTF-8 or UTF-16 However, you can output XML into other character encodings (e.g., ISO-Latin1) Use <![CDATA[ ]]> to wrap any special characters you don’t want to be treated as markup (e.g.,  )

Displaying XML: CSS A modern web browser (e.g., MSIE, Mozilla) and a cascading style sheet (CSS) may be used to view XML as if it were HTML A style must be defined for every XML tag, or the browser displays it in a default mode All display characteristics of each element must be explicitly defined Elements are displayed in the order they are encountered in the XML No reordering of elements or other processing is possible

Displaying XML with CSS Must put a processing instruction at the top of your XML file (but below the XML declaration): <?xml-stylesheet type="text/css" href="style.css"?> Must specify all display characteristics of all tags, or it will be displayed in default mode (whatever the browser wants)

CSS Demonstration XML Doc Cascading Stylesheet (CSS) Web Server

Transforming XML: XSLT XML Stylesheet Language — Transformations (XSLT) A markup language and programming syntax for processing XML Is most often used to: Transform XML to HTML for delivery to standard web clients Transform XML from one set of XML tags to another Transform XML into another syntax/system

XLST Primer XSLT is based on the process of matching templates to nodes of the XML tree Working down from the top, XSLT tries to match segments of code to: The root element Any child node And on down through the document You can specify different processing for each element if you wish

XSLT Processing Model XML Doc Source Tree XML Parser Result Tree XSLT Formatted Output Trans- formation Format- ting XSLT Stylesheet From Professional XSL, Wrox Publishers

Nodes and XPath An XML document is a collection of nodes that can be identified, selected, and acted upon using an Xpath statement Examples of nodes: root, element, attribute, text Sample statement: //article[@name=‘test’] = Select all <article> elements of the root node that have a name attribute with the value ‘test’

Templates An XSLT stylesheet is a collection of templates that act against specified nodes in the XML source tree For example, this template will be executed when a <para> element is encountered: <xsl:template match="para"> <p><xsl:value-of select="."/></p> </xsl:template>

Calling Templates A template can call other templates By default (tree processing): <xsl:apply-templates/> [processes all children of the current node] Explicitly: <xsl:apply-templates select=“title”/> [processes all <title> elements of the current node] <xsl:call-template name=“title”/> [processes the named template, regardless of the source tree]

XSLT Structures Decision: Looping: Choose: when you want an “otherwise” (default) condition If: when you don’t need a default condition Looping: For-each: processes each selected node in turn

XSLT Primer: Doing HTML Typical way to begin: <xsl:template match="/"> <html> <head> <title><xsl:value-of select="title"/></title> <link type="text/css" rel="stylesheet" href="xslt.css" /> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> Then, templates for each element appear below

XSLT Demonstration Web Server XML Processor (xsltproc) CGI script XSLT XHTML representation XSLT Stylesheet XML Processor (xsltproc) Cascading Stylesheet (CSS) XML Doc CGI script Web Server

XML vs. Databases (a simplistic formula) If your information is… Tightly structured Fixed field length Massive numbers of individual items You need a database Loosely structured Variable field length Massive record size You need XML

Serving XML to Web Users Basic requirements: an XML doc and a web server Additional requirements for simple method: A CSS Stylesheet Additional requirements for complex, powerful method: An XSLT stylesheet An XML parser XML web publishing software or an in-house CGI or Java program to join the pieces A CSS stylesheet (optional) to control how it looks in a browser

XML Web Publishing Software Software used to add XML serving capability to a web server Makes it easy to join XML documents with XSLT to output HTML for standard web browsers A couple examples, both free…

Requires a Java servlet container such as Tomcat (free) or Resin (commercial)

Requires mod_perl

http://texts.cdlib.org/escholarship/

XML & XSLT Resources Eric Morgan’s “Getting Started with XML” a good place to begin Many good web sites, and Google searches can often answer specific questions you may have Be sure to join the XML4Lib discussion

Tips and Advice Begin transitioning to XML now: XHTML and CSS for web files, XML for static documents with long-term worth Get your hands dirty on a simple XML project Do not rely on browser support of XML DTDs? We don’t need no stinkin’ DTDs! Buy my book! (just kidding…)

Contact Information Roy Tennant California Digital Library roy.tennant@ucop.edu http://roytennant.com/ 510-987-0476