XML Part 2 Josh Steele CS 6704, Spring 2002
XML Part 2 XSL/XSLT –Structure Revisited –Definition –Example –Components XML’s Linking Languages XML’s Uses
Structure Revisited Information Structure Display XML File XSL File XML Schema (.xsd) File
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)
XSLT Transforms one set of XML tags to another set of XML tags Benefits of this?
Example - XML < Recipe xmlns:rec=“ xmlns:xsi= xsi:schemaLocation=“myxsd.xsd” > Bean Burrito 1 can refried beans 1 cup longhorn colby cheese, shredded …… Empty can of refried beans ……
XML Schema
Example - XSLT <xsl:stylesheet version = “1.0” xmlns:xsl=“ xmlns=“ <xsl: output method=“xml” encoding=“iso ” />
Example - XSLT (cont) Ingredients Cooking Instructions ………
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. )
Components (cont) Text –Literal text can be captured with the tag Repetition –Handled by use of the tag
XML’s Linking Languages XLink –Alternative to XHTML for linking (the tag) – – – works just like (with some more features) –,, - provides a whole new set of linking policies
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 )
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:,
XLink:Locator These <xlink:extended role=“weapon list” title=“Description of Weapons” showdefault=“new” show actuate=“onRequest”>weapons revolutionized medieval warefare……
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”/>
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
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)
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”))
XML Uses MathML – allows math expressions in web pages ( 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!
References XML for Dummies, 2 nd edition (Ed Tittel, Frank Boumphrey) - XPointerhttp:// - XSLThttp:// - XSLhttp:// - XMLhttp://