Full HTML for

Basic foilset Advanced XML and its applications

Given by Lukasz Beca at CPS714 Computational Science Information Track on July 7 99. Foils prepared August 1 99
Outside Index Summary of Material


XML documents and grammar specifications
XML in applications
XSL stylesheets

Table of Contents for full HTML of Advanced XML and its applications

Denote Foils where Image Critical
Denote Foils where HTML is sufficient

1 CPS714 - Applied XML
2 Contents
3 XML Documents and Grammar Specifications
4 Structure of XML Document
5 XML Markup
6 Comments
7 Entity References
8 Character References
9 Processing Instructions
10 CDATA Sections
11 Start and End Tags
12 Empty Elements
13 Example of XML Document
14 Document Grammar Specifications
15 Document Grammar Specifications
16 Document Type Definition
17 Notation Used for Element Content Declarations
18 DTD - Element Declaration
19 DTD - Attribute List
20 DTD - Attribute List Cont.
21 DTD - Entity Declaration
22 DTD - Entity Declaration
23 DTD - Notation Declaration
24 Example of XML Grammar
25 Valid and Well-Formed XML Documents
26 Namespaces
27 Namespace - Example
28 XML in Applications
29 XML Parsers
30 SAX Parser
31 DOM Parser
32 Operations on XML Documents
33 Browsing Document with SAX Parser
34 Browsing Document with SAX Parser
35 Browsing Document with SAX Parser - Results
36 Browsing Document with DOM Parser
37 Browsing Document with DOM Parser
38 Browsing Document with DOM Parser - Results
39 Modification of Document
40 Modification of Document
41 Validation of Document
42 Validation of Document
43 Validation of Document - Modification
44 Validation of Document - Results
45 Storing and Retrieving Objects as XML Documents
46 XML Document and Database
47 XML Document and Database
48 XSL Stylesheets
49 Process
50 XML Process
51 Result Tree Construction
52 XSL Template Element
53 XSL Patterns
54 XSL Patterns
55 Other Important Elements
56 XSL Stylesheet - Translation to HTML
57 XSL Stylesheet - Translation to HTML
58 XSL Stylesheet - Translation to HTML
59 XSL Stylesheet - Translation to HTML
60 References

Outside Index Summary of Material



HTML version of Basic Foils prepared August 1 99

Foil 1 CPS714 - Applied XML

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Lukasz Beca
beca@npac.syr.edu
3-287 CST
NPAC, Syracuse University

HTML version of Basic Foils prepared August 1 99

Foil 2 Contents

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
XML documents and grammar specifications
XML in applications
XSL stylesheets

HTML version of Basic Foils prepared August 1 99

Foil 3 XML Documents and Grammar Specifications

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Structure of XML document
Elements of XML markup
Document grammar specifications
  • Document Type Definition
  • XML Schema
Valid and well-formed documents
Namespaces

HTML version of Basic Foils prepared August 1 99

Foil 4 Structure of XML Document

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Prolog
  • XML declaration - information about document XML version and encoding
  • Example:
  • <?xml version="1.0"?>
  • Document Type Declaration (DTD)
    • internal - embedded in the document
    • external - pointer to the file with defined grammar
Body - structured data with one root element

HTML version of Basic Foils prepared August 1 99

Foil 5 XML Markup

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Comments
Entity references
Character references
Processing instructions
CDATA sections
Start tags and end tags
Empty elements
XML markup specifies the structure of the document. All text that is not markup is the character data of the document:

HTML version of Basic Foils prepared August 1 99

Foil 6 Comments

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Comments make the structure of the document clearer
Can appear anywhere in a document
Comments are not part of the document data (content of comments may be ignored by XML parsers)
Example:
<name>
<!--This is a short comment-->
Smith
</name>

HTML version of Basic Foils prepared August 1 99

Foil 7 Entity References

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Entity is a term that represents certain data
XML parser will substitute that data for the entity
Entities can be used to store binary data
Predefined entities: amp, lt, gt, apos, quot that stand for: &, <, >, `, "
Example:
<statementɱ < 8</statement>

HTML version of Basic Foils prepared August 1 99

Foil 8 Character References

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Character reference is a character in the ISO 10646 character set, usually not directly accessible from available input devices
Character reference is specified as a hexadecimal or decimal code for a character
Example:
#x000d is a carriage return

HTML version of Basic Foils prepared August 1 99

Foil 9 Processing Instructions

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Processing instructions are not part of the document's data but must be passed through to the application
Hold processing directions and information passed to XML parsers and programs
PI begins with the target application identifier
Example:
<?xml version = "1.0" ?>
<?xml-stylesheet type="text/xsl" href="mystyle.xsl"?>

HTML version of Basic Foils prepared August 1 99

Foil 10 CDATA Sections

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
CDATA section can be used to store marked-up text so that the markup is not evaluated
CDATA sections are useful if the user wants to store XML markup as a data
Example:
<buffer>
<![CDATA[<priceᡪ</price>]]>
</buffer>

HTML version of Basic Foils prepared August 1 99

Foil 11 Start and End Tags

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Denote the start and end of the element
Element: <tagname>content</tagname>
Start tag can contain attributes
Content of the element can contain markup and character data
Example:
<name>Smith</name>

HTML version of Basic Foils prepared August 1 99

Foil 12 Empty Elements

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Empty element tag has special form
<tagname/>
Represent elements that have no content
Example:
<img align="left" source="picture.jpg" />

HTML version of Basic Foils prepared August 1 99

Foil 13 Example of XML Document

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<?xml version="1.0" ?>
<!DOCTYPE doc SYSTEM "pubgrammar.dtd">
<doc>
<publication number="pn1">
<title>Collaborative Virtual Workspace</title>
<author>
<lastname>Spellman</lastname>
<firstname>Peter</firstname>
</author>
<date򗶭</date>
<keywords>
<keyword>collaboration framework</keyword>
<keyword>virtual environments</keyword>
</keywords>
</publication>
</doc>

HTML version of Basic Foils prepared August 1 99

Foil 14 Document Grammar Specifications

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Document Type Definition
Provides definition of:
  • tags used in XML document
  • order of the tags
  • containment relationships between tags
  • types of data contained in the elements
Enables validation of the document

HTML version of Basic Foils prepared August 1 99

Foil 15 Document Grammar Specifications

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
XML Schema
  • XML syntax
  • Validation of documents with markup from different namespaces
  • Extensibility
  • Default element content
  • Data types with possibility of constraint specifications
  • User defined data types

HTML version of Basic Foils prepared August 1 99

Foil 16 Document Type Definition

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
External DTD
<?xml version="1.0"?>
<!DOCTYPE greeting SYSTEM "hello.dtd">
<greeting>Hello</greeting>
Internal DTD
<?xml version="1.0"?>
<!DOCTYPE greeting [
<!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello</greeting>
Standalone Document Declaration section can be used to specify which DTD should be used
<xml version="1.0" standalone=`yes' ?>

HTML version of Basic Foils prepared August 1 99

Foil 17 Notation Used for Element Content Declarations

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
(expression) - expression treated as a unit
(a, b) - sequence: a followed by b
(a|b) - choice: a or b but not both
a? - a or nothing
a+ - one or more occurrences of a
a* - zero or more occurrences of a
Example:
(title,author+,date,keywords?)*

HTML version of Basic Foils prepared August 1 99

Foil 18 DTD - Element Declaration

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Element declaration indicates the element's type and its content
The content:
  • element content - only other elements
  • mixed content - other elements and character data
  • `EMPTY' content - element is empty
  • `ANY' content
Example:
<!ELEMENT thing (#PCDATA|container)>
<!ELEMENT container (#PCDATA,(thing)*)>
where PCDATA stands for parsed character data

HTML version of Basic Foils prepared August 1 99

Foil 19 DTD - Attribute List

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Attributes are used to associate name-value pairs with elements
Attribute specifications may appear only within start-tags and empty-element tags
Declarations may be used to:
  • define the set of attributes fort a given element
  • establish constraints for these attributes
  • provide default values for attributes

HTML version of Basic Foils prepared August 1 99

Foil 20 DTD - Attribute List Cont.

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Attribute types:
  • String type: CDATA
  • Tokenized type: ID, IDREF, IDREFS, ENTITY, ENTITIES
  • Enumerated type: attribute can take only one of a list of values provided in the declaration
Attribute defaults:
  • required - forces the attribute to appear in the element (no default value)
  • implied - the application supplies the default value
  • fixed - can have only one value (specified)
Declaration of `name' attribute for element `thing':
<!ATTLIST thing name CDATA #REQUIRED>

HTML version of Basic Foils prepared August 1 99

Foil 21 DTD - Entity Declaration

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Entities are replaced in the document by the parser with actual data
Entity types
  • general: for use in the document content
  • <!ENTITY entityname "replacement text">
  • &entityname;
  • parameter: can be used in external parts of DTD and in conditional selections,
  • <!ENTITY % entityname "replacement text">
  • %entityname;

HTML version of Basic Foils prepared August 1 99

Foil 22 DTD - Entity Declaration

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Location of data
  • internal entities
  • <!ENTITY entityname "replacement text">
  • external entities: parsed and uparsed
  • <!ENTITY entityname SYSTEM "URI">
Parsed entities - external files that contain XML, can be inserted in the document
Unparsed entities - mostly binary files, can be used only as attribute values on elements with ENTITY attributes
<!ENTITY picture SYSTEM "mypicture.gif" NDATA gif>

HTML version of Basic Foils prepared August 1 99

Foil 23 DTD - Notation Declaration

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Notation is used to identify an external binary format
Name of the helper application can be specified that parser might use to launch or process the binary entity
<!NOTATION gif SYSTEM "Editor.exe">
<!ATTLIST picture
format NOTATION (gif | jpg)>

HTML version of Basic Foils prepared August 1 99

Foil 24 Example of XML Grammar

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<!ELEMENT doc (publication)*>
<!ELEMENT publication (title,author+,date,keywords?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (lastname, firstname)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT keywords (keyword)+>
<!ELEMENT keyword (#PCDATA)>
<!ATTLIST publication number ID #REQUIRED>

HTML version of Basic Foils prepared August 1 99

Foil 25 Valid and Well-Formed XML Documents

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Well-formed document:
  • contains one or more elements
  • there is precisely one element (the root) for which neither the start nor the end tag is inside any other element
  • all other tags nest within each other correctly
Valid document: document complies with DTD
  • content model validity: order and nesting
  • data type validity: correct type and other constraints satisfaction e.g. value range

HTML version of Basic Foils prepared August 1 99

Foil 26 Namespaces

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Collection of related XML elements and attributes identified by a URI reference
NOTE: URIs are used to avoid collisions in namespace's names
Provides unique names for elements and attributes by adding context to the tags
Enables reuse of grammar specifications

HTML version of Basic Foils prepared August 1 99

Foil 27 Namespace - Example

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<?xml version="1.0" ?>
<!DOCTYPE doc SYSTEM "pubgrammar.dtd">
<doc xmlns="http://npac.syr.edu/publications">
<publication number="pn1">
<title>Collaborative Virtual Workspace</title>
<author>
<lastname>Spellman</lastname>
<firstname>Peter</firstname>
</author>
<date򗶭</date>
<keywords>
<keyword>collaboration framework</keyword>
<keyword>virtual environments</keyword>
</keywords>
</publication>
</doc>

HTML version of Basic Foils prepared August 1 99

Foil 28 XML in Applications

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
XML parsers
Operations on XML documents
Storing objects as XML documents
XML and databases

HTML version of Basic Foils prepared August 1 99

Foil 29 XML Parsers

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Validation
  • validating parsers
  • non-validating parsers
Application Programming Interfaces
  • Document Object Model (DOM) - tree based
    • compiles an XML document into an internal tree structure
    • allows application to navigate the tree
  • Simple API for XML (SAX) - event based
    • reports parsing events directly to the application through callbacks
    • does not usually build an internal tree

HTML version of Basic Foils prepared August 1 99

Foil 30 SAX Parser

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
SAXParser
ErrorHandler
DocumentHandler

HTML version of Basic Foils prepared August 1 99

Foil 31 DOM Parser

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Document
Element publication
Element doc
Element publication
Element author
Element title
Text
Element lastname
Element firstname
Text
Text

HTML version of Basic Foils prepared August 1 99

Foil 32 Operations on XML Documents

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Browsing document
Document modification
Saving changes
Validation of XML documents

HTML version of Basic Foils prepared August 1 99

Foil 33 Browsing Document with SAX Parser

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
import org.xml.sax.HandlerBase;
import org.xml.sax.AttributeList;
public class MyHandler extends HandlerBase {
String tag = "outside";
int indent = 0;
public void startElement (String name, AttributeList atts) {
int i;
indent = indent + 2;
for(i = 0; i < indent; i ++) {
System.out.print(" ");
}
System.out.println("Start element: " + name);
tag = "inside";
}

HTML version of Basic Foils prepared August 1 99

Foil 34 Browsing Document with SAX Parser

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
import org.xml.sax.Parser;
import org.xml.sax.DocumentHandler;
import org.xml.sax.helpers.ParserFactory;
public class XMLContent {
static final String parserClass = "com.ibm.xml.parsers.SAXParser";
public static void main (String args[]) throws Exception {
Parser parser = ParserFactory.makeParser(parserClass);
DocumentHandler handler = new MyHandler();
parser.setDocumentHandler(handler);
for (int i = 0; i < args.length; i++) {
parser.parse(args[i]);
}
}
}

HTML version of Basic Foils prepared August 1 99

Foil 35 Browsing Document with SAX Parser - Results

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Start element: doc
Start element: publication
Start element: title
Content: Collaborative Virtual Workspace
End element: title
Start element: author
Start element: lastname
Content: Spellman
End element: lastname
Start element: firstname
Content: Peter
End element: firstname
End element: author
Start element: date
Content: 1997
End element: date
Start element: keywords
Start element: keyword
Content: collaboration framework

HTML version of Basic Foils prepared August 1 99

Foil 36 Browsing Document with DOM Parser

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
import org.w3c.dom.*;
import com.ibm.xml.parsers.DOMParser;
public class DOMAccess {
static final String parserClass = "com.ibm.xml.parsers.DOMParser";
public static void main (String args[]) throws Exception {
DOMParser parser = new DOMParser();
Document document;
Element root;
NodeList publications;
Element publication;
Element author;
Element lastname;
Text nameString;
parser.parse(args[0]);

HTML version of Basic Foils prepared August 1 99

Foil 37 Browsing Document with DOM Parser

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
document = parser.getDocument();
root = document.getDocumentElement();
System.out.println("Node name: " + root.getNodeName());
publications = root.getElementsByTagName("publication");
publication = (Element) publications.item(0);
System.out.println("Node name: "+publication.getNodeName());
author = (Element) (publication.getElementsByTagName("author")).item(0);
System.out.println("Node name: " + author.getNodeName());
lastname = (Element) (author.getElementsByTagName("lastname")).item(0);
System.out.println("Node name: " + lastname.getNodeName());
nameString = (Text) lastname.getFirstChild();
System.out.println("Last Name: " + nameString.getData());

HTML version of Basic Foils prepared August 1 99

Foil 38 Browsing Document with DOM Parser - Results

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Node name: doc
Node name: publication
Node name: author
Node name: lastname
Last Name: Spellman

HTML version of Basic Foils prepared August 1 99

Foil 39 Modification of Document

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
import org.w3c.dom.*;
import com.ibm.xml.parser.*;
import java.io.*;
public class DocModification {
public static void main (String args[]) throws Exception {
Parser parser = new Parser(args[0]);
InputStream in = new FileInputStream(args[0]);
TXDocument document;
Element root;
Element publication;
NodeList publications;
Element title;
Element lastname;
Text titleText;
PrintWriter pw;

HTML version of Basic Foils prepared August 1 99

Foil 40 Modification of Document

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
document = parser.readStream(in);
root = document.getDocumentElement();
System.out.println("Node name: " + root.getNodeName());
publications = root.getElementsByTagName("publication");
publication = (Element) publications.item(0);
System.out.println("Node name: "+publication.getNodeName());
title = (Element) (publication.getElementsByTagName("title")).item(0);
System.out.println("Node name: " + title.getNodeName());
titleText = (Text) title.getFirstChild();
System.out.println("Title: " + titleText.getData());
titleText.setData("Something More Interesting");
System.out.println("Title: " + titleText.getData());
pw = new PrintWriter(new BufferedWriter (new FileWriter(args[0])));
document.printWithFormat(pw);

HTML version of Basic Foils prepared August 1 99

Foil 41 Validation of Document

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
import org.xml.sax.Parser;
import org.xml.sax.ErrorHandler;
import org.xml.sax.helpers.ParserFactory;
public class Validator {
static final String parserClass = "com.ibm.xml.parsers.ValidatingSAXParser";
public static void main (String args[]) throws Exception {
Parser parser = ParserFactory.makeParser(parserClass);
ErrorHandler handler = new ErrorReport();
parser.setErrorHandler(handler);
parser.parse(args[0]);
}
}

HTML version of Basic Foils prepared August 1 99

Foil 42 Validation of Document

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class ErrorReport
implements ErrorHandler {
/** Warning. */
public void warning(SAXParseException ex) {
System.err.println("[Warning] "+
getLocationString(ex)+": "+
ex.getMessage());
}
/** Error. */
public void error(SAXParseException ex) {
System.err.println("[Error] "+
getLocationString(ex)+": "+
ex.getMessage());
}

HTML version of Basic Foils prepared August 1 99

Foil 43 Validation of Document - Modification

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<doc>
<publications number="pn1">
<title>Something More Interesting</title>
<author>
<lastname>Spellman</lastname>
<firstname>Peter</firstname>
</author>
<date򗶭</date>
<keywords>
<keyword>collaboration framework</keyword>
<keyword>virtual environments</keyword>
</keywords>
</publications>
.
.
.

HTML version of Basic Foils prepared August 1 99

Foil 44 Validation of Document - Results

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
D:\docs\cis\domexample>java Validator ..\publications.xml
[Error] publications.xml:15:24: Attribute, "number", is not declared in element, "publications".
[Error] publications.xml:26:18: Element, "publications" is not declared in the DTD
[Error] publications.xml:56:7: Element "<doc>" is not valid because it does not follow the rule, "(publication)*".)

HTML version of Basic Foils prepared August 1 99

Foil 45 Storing and Retrieving Objects as XML Documents

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Customizing Java serialization mechanism
  • java.io.Serializable
  • readObject(java.io.ObjectInputStream)
  • writeObject(java.io.ObjectOutputStream)
Solution for JavaBeans
  • use of information gathered from BeanInfo class
  • use of `set' methods for each object field

HTML version of Basic Foils prepared August 1 99

Foil 46 XML Document and Database

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Part Name Part ID Price InStock
window 001 40$ yes
muffler 002 150$ yes
door 003 30$ no

HTML version of Basic Foils prepared August 1 99

Foil 47 XML Document and Database

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<store>
<part id="p001">
<part-name>window</part-name>
<priceᡠ</price>
<instock>yes</instock>
</part>
<part id="p002">
<part-name>muffler</part-name>
<price</price>
<instock>yes</instock>
</part>
</store>

HTML version of Basic Foils prepared August 1 99

Foil 48 XSL Stylesheets

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Process
Result tree construction
XSL template element
XSL patterns
Important XSL elements
Displaying XML data in Web browsers

HTML version of Basic Foils prepared August 1 99

Foil 49 Process

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Construction of source tree from XML document
Transformation of source tree to result tree using stylesheet contained in XSL document
Application of style rules to each node of result tree
Display of document by user agent using appropriate styling on a display, on paper or some other medium

HTML version of Basic Foils prepared August 1 99

Foil 50 XML Process

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Source Tree
Result Tree
Interpretation of result tree

HTML version of Basic Foils prepared August 1 99

Foil 51 Result Tree Construction

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Stylesheet - set of template rules
Template rule
  • pattern - identifies the source node to which the processing is applied
  • template - the fragment to be instantiated to form a part of the result tree
Creation of result tree: finding the template rule for the root node and instantiating its template

HTML version of Basic Foils prepared August 1 99

Foil 52 XSL Template Element

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Describes template rule
match attribute - source node to which the rule applies
Content - the template, may contain XSL formatting vocabulary
Conflict resolution
  • most specific rule will be applied
  • priorities (priority attribute of the rule)
Namespaces used to distinguish XSL instructions from other template content

HTML version of Basic Foils prepared August 1 99

Foil 53 XSL Patterns

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Matching by name
<xsl:template match="publication">
Matching by ancestry
<xsl:template match="publication/title">
Matching several names
<xsl:template match="title|keyword">
Matching the root
<xsl:template match="/">
Wildcard matches
<xsl:template match="*">

HTML version of Basic Foils prepared August 1 99

Foil 54 XSL Patterns

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
Matching by ID
<xsl:template match="id(pn1)">
Matching by attribute
<xsl:template match="publication[attribute(number) =`pn1']">
Matching by child
<xsl:template match="publication[date]">
Matching by position
<xsl:template match="publication[first-of-type()]">

HTML version of Basic Foils prepared August 1 99

Foil 55 Other Important Elements

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<xsl:apply-templates select="pattern"/>
Applies template rules to the children of the node
<xsl:value-of select="pattern">
Extracts value of element pattern
<xsl:for-each select="pattern">
Performs operation for each element described by pattern
<xsl:sort select="key">
Used in apply-template or for-each element, sorts children according to the key

HTML version of Basic Foils prepared August 1 99

Foil 56 XSL Stylesheet - Translation to HTML

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional">
<xsl:template><xsl:apply-templates/></xsl:template>
<xsl:template match="/doc">
<HTML>
<HEAD>
<TITLE>Publications</TITLE>
</HEAD>
<BODY>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>

HTML version of Basic Foils prepared August 1 99

Foil 57 XSL Stylesheet - Translation to HTML

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<xsl:template match="/doc/publication">
<P>
<H1>
Title: <xsl:value-of select="title"/>
</H1>
Author:
<BR/>
<xsl:apply-templates select="author"/>
<BR/>
Date: <xsl:value-of select="date"/>
<BR/>
Keywords:
<BR/>
<xsl:apply-templates select="keywords"/>
</P>
<HR/>
</xsl:template>

HTML version of Basic Foils prepared August 1 99

Foil 58 XSL Stylesheet - Translation to HTML

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
<xsl:template match="/doc/publication/author">
<B>
<xsl:value-of select="firstname"/>
<xsl:value-of select="lastname"/>
</B> <BR/>
</xsl:template>
<xsl:template match="/doc/publication/keywords">
<I>
<xsl:apply-templates select="keyword"/>
</I> <BR/>
</xsl:template>
<xsl:template match="/doc/publication/keywords/keyword">
<I>
<xsl:value-of/>
</I> <BR/>
</xsl:template>
</xsl:stylesheet>

HTML version of Basic Foils prepared August 1 99

Foil 59 XSL Stylesheet - Translation to HTML

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index

HTML version of Basic Foils prepared August 1 99

Foil 60 References

From Advanced XML and its applications CPS714 Computational Science Information Track -- July 7 99. *
Full HTML Index
XML Applications by Frank Boumphrey et al.
XML Complete by Steven Holtzner
Extensible Stylesheet Language (XSL) Version 1.0, W3C Working Draft 16-Dec-98
Extensible Markup Language (XML) 1.0, W3C Recommendation 10-Feb-98
SAX - http://www.megginson.com/SAX
Document Object Model (DOM) Level 1 Specification, Verson 1.0, W3C Recommendation 1-Oct-98
Various Info - www.xml.com
Parsers and Tools - http://www.alphaworks.ibm.com/tech/xml/

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Aug 1 1999