Download presentation
Presentation is loading. Please wait.
Published byAmbrose Lang Modified over 9 years ago
1
XML Part 2 Josh Steele CS 6704, Spring 2002
2
XML Part 2 XSL/XSLT –Structure Revisited –Definition –Example –Components XML’s Linking Languages XML’s Uses
3
Structure Revisited Information Structure Display XML File XSL File XML Schema (.xsd) File
4
XSL Stands for Extensible Stylesheet Language Parts: –XSLT – handles transformations –XPath – used to access or refer to parts of an XML document –Formatting objects – XML Vocabulary for specifying formatting semantics Compatible with CSS2 (uses different syntax though)
5
XSLT Transforms one set of XML tags to another set of XML tags Benefits of this?
6
Example - XML < Recipe xmlns:rec=“http://www.mysite.org/Recipe” xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=“myxsd.xsd” > Bean Burrito 1 can refried beans 1 cup longhorn colby cheese, shredded …… Empty can of refried beans ……
7
XML Schema
8
Example - XSLT <xsl:stylesheet version = “1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” xmlns=“http://www.w3.org/TR/xhtml1/strict”> <xsl: output method=“xml” encoding=“iso-8859-1” />
9
Example - XSLT (cont) Ingredients Cooking Instructions ………
10
Components Template –Defines what should be changed, and how Pattern –Uses “match=“ attribute in template tag to point to a specific element (uses XPath, more later) Results –Includes the HTML tags specified – - applies template to the text encapsulated by the tag (i.e. )
11
Components (cont) Text –Literal text can be captured with the tag Repetition –Handled by use of the tag
12
XML’s Linking Languages XLink –Alternative to XHTML for linking (the tag) – http://www.w3.org/1999/xlink/namespace – – works just like (with some more features) –,, - provides a whole new set of linking policies
13
XLink: Simple Attributes: –href - resource you are linking to –role - string used to describe element’s role –title – optional title of link –show - opens the new resource in its own window (new), embeds it in the current window (embed), or replaces the current window with the new one (replace) –actuate – onRequest (click a link) or auto (like loading in )
14
XLink:Extended Attributes: –Role, title – as in –showdefault – default value of show for all locator elements –actuatedefault – default value of actuate for all child elements –Needs helpers:,
15
XLink:Locator These <xlink:extended role=“weapon list” title=“Description of Weapons” showdefault=“new” show actuate=“onRequest”>weapons revolutionized medieval warefare……
16
XLink:arc Locators can be specified out-of-line – –Allows different show and actuate parameters for each locator xlink:arc specifies those values in above file: xlink:arc from=“sourcedoc” to=“longbowpic” show=“embed” actuate=“auto”/>
17
XPath Purposes: –To find and describe a section in the XML file (used in XSLT) –To be able to point to a certain part of the document (used in XPointers) In essence makes a parse tree describing the relationships between tags in the file
18
XPointers Allows one to point into a document (similar to anchors in HTML), but without any special notation (like id=“mytaghere”) Also allows selection of a section of the file (i.e. if you want section 25, it only downloads section 25, not the whole file)
19
XPointers (cont) 3 ways to reference: –#anchor (like in HTML) –#/1/3/4 (3 rd tag under root, 4 th tag under that) –#xptr (XPath expression) If you aren’t sure if there is an ID, you can concatenate different reference methods together Range: XPtr(id(“c2”) to id(“c3”))
20
XML Uses MathML – allows math expressions in web pages (www.w3.org/Math)www.w3.org/Math XML-Data – provides mechanism to reference binary data within XML docs XHTML – a merging of XML and HTML WIDL – Web Interface Definition Language – allowed direct access to Web data from e-commerce or business apps And many more!
21
References XML for Dummies, 2 nd edition (Ed Tittel, Frank Boumphrey) http://www.w3.org/TR/WD-xptr - XPointerhttp://www.w3.org/TR/WD-xptr http://www.w3.org/TR/xslt - XSLThttp://www.w3.org/TR/xslt http://www.w3.org/Style/XSL/ - XSLhttp://www.w3.org/Style/XSL/ http://www.w3.org/XML/ - XMLhttp://www.w3.org/XML/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.