Introduction to XML DTD

Similar documents
The main problem of DTD s...

Introduction to XML. XML: basic elements

COMP9321 Web Application Engineering

XML. Presented by : Guerreiro João Thanh Truong Cong

XML. XML Namespaces, XML Schema, XSLT

CountryData Technologies for Data Exchange. Introduction to XML

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

Part 2: XML and Data Management Chapter 6: Overview of XML

Session [2] Information Modeling with XSD and DTD

HTML vs. XML In the case of HTML, browsers have been taught how to ignore invalid HTML such as the <mymadeuptag> element and generally do their best

XML DTDs and Namespaces. CS174 Chris Pollett Oct 3, 2007.

Information Systems. DTD and XML Schema. Nikolaj Popov

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

Overview. Introduction to XML Schemas. Tutorial XML Europe , Berlin. 1 Introduction. 2 Concepts. 3 Schema Languages.

Markup Languages. Lecture 4. XML Schema

XML Applications. Prof. Andrea Omicini DEIS, Ingegneria Due Alma Mater Studiorum, Università di Bologna a Cesena

XML. COSC Dr. Ramon Lawrence. An attribute is a name-value pair declared inside an element. Comments. Page 3. COSC Dr.

7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML

Querying XML Data. Querying XML has two components. Selecting data. Construct output, or transform data

XML. Objectives. Duration. Audience. Pre-Requisites

7.1 Introduction. 7.1 Introduction (continued) - Problem with using SGML: - SGML is a meta-markup language

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

CS6501 IP Unit IV Page 1

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML

IBM. XML and Related Technologies Dumps Braindumps Real Questions Practice Test dumps free

Week 2: Lecture Notes. DTDs and XML Schemas

XML and Content Management

Introduction Syntax and Usage XML Databases Java Tutorial XML. November 5, 2008 XML

EXtensible Markup Language XML

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

- XML. - DTDs - XML Schema - XSLT. Web Services. - Well-formedness is a REQUIRED check on XML documents

Chapter 3 Brief Overview of XML

X(ml)S(chema)D(definition) Complex Types Indicators

extensible Markup Language

EMERGING TECHNOLOGIES. XML Documents and Schemas for XML documents

but XML goes far beyond HTML: it describes data

Structured documents

extensible Markup Language

CS/INFO 330: Applied Database Systems

More XML Schemas, XSLT, Intro to PHP. CS174 Chris Pollett Oct 15, 2007.

EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML

XML (4) Extensible Markup Language

Sticky and Proximity XML Schema Files

CHAPTER 8. XML Schemas

XML extensible Markup Language

Software Engineering Methods, XML extensible Markup Language. Tutorial Outline. An Example File: Note.xml XML 1

HR-XML Schema Extension Recommendation, 2003 February 26

SuccessMaker Data Services API Guide

WHITE PAPER. Query XML Data Directly from SQL Server Abstract. DilMad Enterprises, Inc. Whitepaper Page 1 of 32

XML Extensible Markup Language

Internet Technologies 11-XML. F. Ricci 2010/2011

~ Ian Hunneybell: DIA Revision Notes ~

A namespace prefix is defined with a xmlns attribute using the syntax xmlns:prefix="uri".

XML. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior

MASTER OF SCIENCE THESIS

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

XML - Schema. Mario Arrigoni Neri

Creation of the adaptive graphic Web interfaces for input and editing data for the heterogeneous information systems on the bases of XML technology

Data Services API Guide SuccessMaker 9

Data Services API Guide SuccessMaker 10

HTML and XML. XML stands for extensible Markup Language

Data Presentation and Markup Languages

Agenda. XML document Structure. XML and HTML were designed with different goals: XML was designed to describe data and to focus on what

Appendix H XML Quick Reference

DTD MIGRATION TO W3C SCHEMA

웹기술및응용. XML Schema 2018 년 2 학기. Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering

Semantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95

XML. Part II DTD (cont.) and XML Schema

!" DTDs rely on a mechanism based on the use of. !" It is intended to specify cross references" !" Reference to a figure, chapter, section, etc.!

Extensible Markup Language (XML) Hamid Zarrabi-Zadeh Web Programming Fall 2013

Outline. XML vs. HTML and Well Formed vs. Valid. XML Overview. CSC309 Tutorial --XML 4. Edward Xia

ENTSO-E ACKNOWLEDGEMENT DOCUMENT (EAD) IMPLEMENTATION GUIDE

THE EXTENSIBLE MARKUP LANGUAGE (XML) AS A MEDIUM FOR DATA EXCHANGE

XML Overview, part 1

Contents. 1 Introduction Basic XML concepts Historical perspectives Query languages Contents... 2

XML Schemas. Purpose of XML Schemas (and DTDs)

XML Namespaces. Mario Arrigoni Neri

SDPL : XML Basics 2. SDPL : XML Basics 1. SDPL : XML Basics 4. SDPL : XML Basics 3. SDPL : XML Basics 5

Module 3. XML Schema

CA Data Protection. Account Import XML Schema Guide. Release 15.0

XML Data Management. Peter Wood BBK. Peter Wood (BBK) XML Data Management 1 / 337

Extensible Markup Stylesheet Transformation (XSLT)

Creating Coverage Zone Files

No Trade Secrets. Microsoft does not claim any trade secret rights in this documentation.

Chapter 11 XML Data Modeling. Recent Development for Data Models 2016 Stefan Deßloch

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

XML Schema 3/14/12! XML Schema. Overview

<!-- type definitions -->

COMP9321 Web Application Engineering

XML Data Management. P. Atzeni (heavily from Peter Wood) P. Atzeni (heavily from Peter Wood) XML Data Management 1 / 239

- What is a markup language? - What is a data serialization language?

XML and Java: Lessons Learned in Building Application. Ted Leung Technical Lead, XML4J Parser

XMI Version 1Production of XML Schema Specification

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

OASIS SECURITY SERVICES DYNAMIC SESSION SPECIFICATION WORKING DRAFT

asexml SCHEMA CHANGE REQUEST

Gestão e Tratamento de Informação

Style Sheet A. Bellaachia Page: 22

Transcription:

Introduction to XML DTD

What is a DTD? A DTD is usually a file (or several files to be used together) which contains a formal definition of a particular type of document. This sets out what names can be used for elements, where they may occur, and how they all fit together. It's a formal language which lets processors automatically parse a document and identify where every element comes and how they relate to each other, so that stylesheets, navigators, browsers, search engines, databases, printing routines, and other applications can be used. A DTD contain metadata relative to a collection of XML docs.

Valid documents a valid XML document is one that conforms to an existing DTD in every respect. For example... Unless the DTD allows an element with the name "color", an XML document containing an element with that name is not valid according to that DTD (but it might be valid according to some other DTD). An invalid XML document can be a perfectly good and useful XML document.

Valid documents Validity is not a requirement of XML Because XML does not require a DTD, in general, an XML processor cannot require validation of the document. Many very useful XML documents are not valid, simply because they were not constructed according to an existing DTD. To make a long story short, validation against a DTD can often be very useful, but is not required.

Constraing &ValidatingXML XML file Validating Parser Validation DTD file

Constraing & Validating XML XML file Validating Parser Validation XML Schema DTD is not XML DTD is not powerful enough (e.g. at least 3, no more than 5)

Where are the DTDs? A DTD can be external or internal to a document. Internal DTD <DOCTYPE Report> <DOCTYPE Report SYSTEM Report.dtd > <DOCTYPE Report PUBLIC Report.dtd > External DTD Broadly and publicly available URL

DTD Markup: ELEMENT <ELEMENT name content-model> <ELEMENT book (preface?,chapter+,index)> <ELEMENT preface(paragraph+)> <ELEMENT paragraph (#PCDATA)> <ELEMENT chapter (title,paragraph+,reference*)> <ELEMENT title (#PCDATA)> <ELEMENT reference (#PCDATA URL)> <ELEMENT URL (#PCDATA)>? Zero or one + One or more * Zero or more, sequence or (not xor) <ELEMENT index(number,title,page_number)> <ELEMENT number(#pcdata)> <ELEMENT page_number(#pcdata)>

DTD Markup: ATTLIST <ATTLIST element-name attribute-name type default> <ELEMENT Product (#PCDATA)> <ATTLIST Product > Name CDATA #IMPLIED Rev CDATA #FIXED 1.0 Code CDATA #REQUIRED Pid ID #REQUIRED Series IDREF Status (InProduction Obsolete) InProduction TYPES: CDATA character data ID Unique key IDREF Foreign Key ( ) Enumeration DEFAULT: #IMPLIED optional, no default #FIXED optional, default supplied. If present must match default #REQUIRED must be provided

DTD Markup: ENTITY Entities are a sort of macro General Entity <ENTITY author Marco Ronchetti, Universita di Trento > External Parsed Entity <ENTITY content SYSTEM content.xml > <Tag>&content &author</tag> External to the DTD Parameter Entity <ENTITY % AI CDATA #IMPLIED > <ATTLIST Product Name %AI> Internal at the DTD

The main problem of DTD s... They are not written in XML Solution: Another XML-based standard: XML Schema For more info see: http://www.w3.org/xml/schema

XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences

w3schools.com XML NAMESPACES

XML Namespaces p The idea behing XML namespaces is to avoid element name conflicts. p Example of name conflict (w3schools.com) <table> <tr> <td>apples</td> <td>bananas</td> </tr> </table> <table> <name>african Coffee Table</name> <width>80</width> <length>120</length> </table> Same tag- name, different content and meaning

Solving Name Conflict <h:table> Prefix h has xhtml- related <h:tr> elements and prefix f has <h:td>apples</h:td> furniture- related elements <h:td>bananas</h:td> </h:tr> </h:table> <f:table> <f:name>african Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table>

xmlns - azributes p When using prefixes in XML, a so- called namespace for the prefix must be defined. p The namespace is defined by the xmlns azribute in the start tag of an element.

xmlns - azribute <root> <h:table xmlns:h="http://www.w3.org/tr/html4/"> <h:tr> <h:td>apples</h:td> <h:td>bananas</h:td> </h:tr> </h:table> <f:table xmlns:f="http://www.w3schools.com/furniture"> <f:name>african Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table> </root>

xmlns - azribute <root xmlns:h="http://www.w3.org/tr/html4/" xmlns:f="http://www.w3schools.com/furniture"> <h:table> <h:tr> <h:td>apples</h:td> <h:td>bananas</h:td> </h:tr> </h:table> <f:table> <f:name>african Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table> </root>

Namespace name p The name of namespace should be unique: <h:table xmlns:h="http://www.w3.org/tr/html4/"> p It is just a string, but it should be declared as URI. p Using URI reduces the possibility of different namespaces using duplicate iden>fiers.

Example: An XHTML + MathML + SVG Profile p An XHTML+MathML+SVG profile is a profile that combines XHTML 1.1, MathML 2.0 and SVG 1.1 together. p This profile enables mixing XHTML, MathML and SVG in the same document using XML namespaces mechanism.

<?xml version="1.0"?> <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd"> <html xmlns xmlns:svg = "http://www.w3.org/1999/xhtml" = "http://www.w3.org/2000/svg"> <head> <title>example of XHTML, SVG and MathML</title> </head> <body> <h2>mathml</h2> <p> <math xmlns="http://www.w3.org/1998/math/mathml"> <mfrac> <mi>a</mi> <mi>b</mi> </mfrac> </math> </p> <h2>svg</h2> <p> <svg:svg width="50px" height="50px"> <svg:circle cx="25px" cy="25px" r="20px" fill="green"/> </svg:svg> </p> </body> </html>

W3C SCHEMA

XML Schema (W3C) p Language for defining set of rules for XML documents. p W3C Recommendadon (2001) p More specific than DTD n Datatypes p Is XML- language and it uses xml namespaces

Schema vs. DTD (W3Schools.com) p XML Schemas are extensible to future addidons p XML Schemas are richer and more powerful than DTDs p XML Schemas are wrizen in XML p XML Schemas support data types p XML Schemas support namespaces

DTD Linking Defines the structure, tag names and order for all xhtml - documents W3C has created XML- language "XHTML" by defining it's rules in DTD.

DTD Linking Defines the structure, tag names and order for all "book"- documents TAMK has created XML- language "Book" by defining it's rules in DTD.

Schema Linking Defines the structure, tag names and order for all "book"- documents TAMK has created XML- language "Book" by defining it's rules in a Schema.

Linking? p The basic idea with linking to Schema: <?xml version="1.0"?> <root schemalocation="note.xsd"> <foo>...</foo> </root> p The problem with this is that now it is set that azribute "schemalocadon" is part of your XML- language

Linking and Namespace Usage p Linking with namespace <?xml version="1.0"?> <root xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="note.xsd"> <foo>...</foo> </root> p Now the "schemalocadon" azribute is in it's own namespaces (xsi) and does not belong to the "main" language.

Simple Schema <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="complete_name" type="complete_name_type"/> <xsd:complextype name="type="complete_name_type"> <xsd:sequence> <xsd:element name="nome" type="xsd:string"/> <xsd:element name="cognome" type="xsd:string"/> </xsd:sequence> </xsd:complextype> </xsd:schema>

Let's remove namespaces... <?xml version="1.0"?> <schema> <element name="complete_name" type="complete_name_type"/> <complextype name="complete_name_type"> <sequence> <element name="nome" type="string"/> <element name="cognome" type="string"/> </sequence> </complextype> </schema> It doesn't look so confusing aier all?

The Basics: Element p You define the name for the elements by using element- element. J n <element name="foo" type="bar" /> p Type? n 44 Built- in schema datatypes n string, double, dme, date, etc. n See all the datatypes

Usage of Datatypes <xsd:element name="firstname" type="xsd:string" /> <xsd:element name="abletoswim" type="xsd:boolean" /> <xsd:element name="date" type="xsd:date" />

minoccurs and maxoccurs p The amount of elements n In DTD: *,?, + n In Schema: minoccurs, maxoccurs Example <xsd:element name="date" type="xsd:date" minoccurs="1" maxoccurs="2" /> p Default and special values n default minoccurs: 1 n default maxoccurs: same as minoccurs n maxoccurs="unbounded" : unlimited

Defining new Datatypes p If the the built- in datatypes are not enough, you can build your own datatypes. p This does not necessarily work: n <xsd:element name="grade" type="xsd:integer" /> p There are two ways of specifying your own datatype n Named Data Type n Anonymous Data Type

1) Named Data Type <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="grade" type="grade_type" /> <xsd:simpletype name="grade_type"> <xsd:restriction base="xsd:positiveinteger"> <xsd:mininclusive value="4"/> <xsd:maxinclusive value="10"/> </xsd:restriction> </xsd:simpletype> </xsd:schema>

2) Anonymous Data Type <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="grade"> <xsd:simpletype> <xsd:restriction base="xsd:positiveinteger"> <xsd:mininclusive value="4"/> <xsd:maxinclusive value="10"/> </xsd:restriction> </xsd:simpletype> </xsd:element> </xsd:schema>

Benefits of Named Data Type p If you want re- use your datatype: <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="grade" type="grade_type" /> <xsd:element name="teachers_iq" type="grade_type" /> <xsd:simpletype name="grade_type"> <xsd:restriction base="xsd:positiveinteger"> <xsd:mininclusive value="4"/> <xsd:maxinclusive value="10"/> </xsd:restriction> </xsd:simpletype> </xsd:schema>

SimpleType: enumeradon p Alternadve content <xsd:simpletype name="car"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="audi"/> <xsd:enumeration value="golf"/> <xsd:enumeration value="bmw"/> </xsd:restriction> </xsd:simpletype>

SimpleType: pazern p Using REGEX: <xsd:simpletype name="lowercase_char"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[a-z]"/> </xsd:restriction> </xsd:simpletype>

REGEX Examples <xs:pattern value="[a-z][a-z][a-z]"/> <xs:pattern value="[a-za-z][a-za-z][a-za-z]"/> <xs:pattern value="[xyz]"/> <xs:pattern value="[0-9][0-9][0-9][0-9][0-9]"/> <xs:pattern value="([a-z])*"/> <xs:pattern value="male female"/> <xs:pattern value="[a-za-z0-9]{8}"/>

Structure of the XML- file p It's possible to define the structure of the XML- file using complextype p If element A has child- elements, then element A's type is complextype

SimpleType vs. ComplexType p SimpleType n <grade>7</grade> n Since grade does not hold other child elements, grade's type is simpletype p ComplexType n <students><student>jack</student></ students> n Since student does hold child element(s), student's type is complextype

Example: XML - File <?xml version="1.0"?> <students> <firstname>fernando</firstname> <lastname>alonso</lastname> </students>

Example: XSD file Named ComplexType Use now complextype (vs. simpletype) <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="students" type="students_type"> <xsd:complextype name="students_type"> <xsd:sequence> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="lastname" type="xsd:string"/> </xsd:sequence> </xsd:complextype> </xsd:schema>

Example: XSD file Anonymous ComplexType <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="students"> <xsd:complextype> <xsd:sequence> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="lastname" type="xsd:string"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema>

Example: ComplexType <xsd:element name="employee" type="personinfo"/> <xsd:element name="student" type="personinfo"/> <xsd:element name="member" <xsd:complextype name="personinfo"> <xsd:sequence> type="personinfo"/> <xsd:element name="firstname" type="xsd:string"/> <xsd:element name="lastname" type="xsd:string"/> </xsd:sequence> </xsd:complextype>

Deep Structure in XML - File <?xml version="1.0"?> <students> <student> <name> <firstname>fernando</firstname> </name> </student> </students>

Using Anonymous Data Type: The Horror <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="students"> <xsd:complextype> <xsd:sequence> <xsd:element name="student"> <xsd:complextype> <xsd:sequence> <xsd:element name="name"> <xsd:complextype> <xsd:sequence> <xsd:element name="firstname" type="xsd:string"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema>

"There is an error in my schema, could you find it for me?" <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="students"> <xsd:complextype> <xsd:sequence> <xsd:element name="student"> <xsd:complextype> <xsd:sequence> <xsd:element name="name"> <xsd:complextype> <xsd:sequence> <xsd:element name="firstname" type="xsd:string"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:complextype> </xsd:element> </xsd:schema>

Use Named Datatypes It's easier to find errors.. <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="students" type="students_type" /> <xsd:complextype name="students_type"> <xsd:sequence> <xsd:element name="student" type="student_type" /> </xsd:sequence> </xsd:complextype> <xsd:complextype name="student_type"> <xsd:sequence> <xsd:element name="name" type="name_type" /> </xsd:sequence> </xsd:complextype> <xsd:complextype name="name_type"> <xsd:sequence> <xsd:element name="firstname" type="xsd:string" /> </xsd:sequence> </xsd:complextype> </xsd:schema>

Order of the elements p Sequence: Elements appear in same order than in Schema p All: Elements can appear in any order p Choice: One element can appear from the choice- list <xsd:element name="person"> <xsd:complextype> <xsd:choice> <xsd:element name="employee" type="employee"/> <xsd:element name="member" type="member"/> </xsd:choice> </xsd:complextype> </xsd:element>

AZribute p XML n <student id="a1">...</student> p Schema <xsd:element name="student" type="student_type" /> <xsd:complextype name="student_type"> <xsd:sequence>... </xsd:sequence> <xsd:attribute name="id" type="xsd:id"/> </xsd:complextype>

Empty Element with AZribute p XML n <student id="a1" /> p Schema <xsd:element name="student" type="student_type" /> <xsd:complextype name="student_type"> <xsd:attribute name="id" type="xsd:id"/> </xsd:complextype>

Introduction to XML XSL - INTRODUCTION

Transforming XML XML file XSLT Processor XML file XSL file

XSL is complex" XSL is complex (much more complex than XML). Designing an XSL stylesheet, to be used by a rendering engine to properly render an XML document, can be a daunting task. Microsoft has developed an XSL debugger, and has made it freely available for downloading.

Some availablexslt processors Apache Xalan http://xml.apache.org James Clark s XT http://www.jclark.com/xml/xt.html Lotus XSL Processor http://alphaworks.ibm.com/tech/lotusxsl Oracle XSL Processor Keith Visco s XSL:P Michael Kay s SAXON http://technet.oracle.com/tech/xml http://www.clc-marketing.com/xslp http://users.iclway.co.uk/mhkay/saxon

Transforming XML Contenuto Forma XML file Documento XSL file 1 XSLT Processor HTML file XSL file 2 WML file

Transforming XML Contenuto XML file 1 XML file 2 Documento Forma XSLT Processor HTML file 1 XSL file HTML file 2

Hands on XSL XSL-basic elements

HANDS ON - Esempio1 XML <?xml version="1.0"?> <?xml-stylesheet href="hello.xsl" type="text/xsl"?> <-- Here is a sample XML file --> <page> <title>test Page</title> <content> <paragraph>what you see is what you get</paragraph> </content> </page>

HANDS ON - Esempio1 XSL a <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="page"> <html> <head> <title> <xsl:value-of select="title"/> </title> </head> <body bgcolor="#ffffff"> <xsl:apply-templates/> </body> </html> </xsl:template>

HANDS ON - Esempio1 XSL b <xsl:template match="paragraph"> <p align="center"> <i> </i> <xsl:apply-templates/> </p> </xsl:template> </xsl:stylesheet>

HANDS ON - Esempio1 Xalan Let us use the Apache XSLT processor: Xalan. 1) Get Xalan from xml.apache.org/xalan/index.html 2 )Set CLASSPATH=%CLASSPATH%; /xalan.jar; /xerces.jar 3) java org.apache.xalan.xslt.process IN testpage.xml XSL testpage.xsl O out.html

HANDS ON - Esempio1 Output HTML <html> <head> <title> Test Page </title> </head> <body bgcolor="#ffffff"> <p align="center"> <i> What you see is what you get </i> </p> </body> </html>

The process p The process starts by traversing the document tree, attempting to find a single matching rule for each visited node. p Once the rule is found, the body of the rule is istantiated p Further processing is specified with the <xsl:apply-templates>. The nodes to process are specified in the match attribute. If the attribute is omitted, it continues with the next element that has a matching template.

Implicit rules <template match= / * > <apply-templates/> </template> <template match= text() > <value-of select=. /> </template>

Publishing frameworks

XML Enabled HTTP Server Client HTTP Server Document Server Stylesheet Server HTTP request Get document XML document Get SS XSL stylesheet XSLT Processor HTML document XML + XSL HTML document

Publishing frameworks Apache Cocoon http://xml.apache.org Enhydra Application Server http://www.enhydra.org/ Bluestone XML Server http://www.bluestone.com/xml SAXON http://users.iclway.co.uk/mhkay/saxon