copyright © 1999, architag international corporation. all rights reserved. use without express...
Post on 27-Mar-2015
221 Views
Preview:
TRANSCRIPT
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
Using XSLT To Using XSLT To Transform XMLTransform XML
Brian E. TravisBrian E. TravisArchitag International CorpArchitag International Corpbtravis@architag.combtravis@architag.com
9-3339-333
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLXSLExtensible Stylesheet LanguageExtensible Stylesheet Language
HTML: "Format without Structure"HTML: "Format without Structure" Typesetting languageTypesetting language Not extensibleNot extensible
CSS: "Enhanced Format, No Structure"CSS: "Enhanced Format, No Structure" Stylesheet languageStylesheet language Overrides default formatting for HTML, but annot Overrides default formatting for HTML, but annot
change basic structure of the documentchange basic structure of the document XML: "Structure Without Format"XML: "Structure Without Format"
Defines "elements" using "tags"Defines "elements" using "tags" Creates hierarchical structure of information setCreates hierarchical structure of information set
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLTXSLT"Adding Format to Structure""Adding Format to Structure"
Transforms XML to XMLTransforms XML to XML Declarative programming languageDeclarative programming language Creates formatted outputCreates formatted output Does limited processingDoes limited processing
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
QuizQuiz
May 5, 2000May 5, 2000
<I>May 5, 2000</I><I>May 5, 2000</I>
<birthday>May 5, 2000</birthday><birthday>May 5, 2000</birthday>
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLT OperationXSLT Operation
XSLXSL
TransformerTransformer
Output (x)Output (x)
StylesheetStylesheetxmlns:xslxmlns:xsl
Source TreeSource Tree(your XML)(your XML)
XSLTXSLT
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
Example In XRayExample In XRay
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLT Stylesheet ArchitectureXSLT Stylesheet Architecture
<xsl:stylesheet <xsl:stylesheet
version="1.0"version="1.0"
xmlns:xsl="http://xmlns:xsl="http://
www.w3.org/1999/www.w3.org/1999/
XSL/Transform">XSL/Transform">
......
</xsl:stylesheet></xsl:stylesheet>
Start tag for stylesheet Start tag for stylesheet
document, containing document, containing
XSL Namespace XSL Namespace
indicatorindicator
Template rules and Template rules and
other stuffother stuff End of stylesheetEnd of stylesheet
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLT Template RuleXSLT Template Rule<xsl:template match="chapter/title">
<DIV STYLE="font-family:sans-serif;font-weight:bold;color:blue;"><xsl:apply-templates/>
</DIV></xsl:template>
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
PatternsPatterns
ParagraphParagraph ElementElement
abstract/paragraphabstract/paragraph ParentParent
chapter//quotechapter//quote AncestorAncestor
chapter[synopsis]chapter[synopsis] FilterFilter
list[@type]list[@type] Attribute filter Attribute filter
(specified)(specified)
list[@type=‘ordered’list[@type=‘ordered’
]]Attribute filter (value)Attribute filter (value)
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
<xsl:apply-templates/>
<xsl:value-of/>
<xsl:template match=“something”/>
XSLT Template RuleXSLT Template Rule
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLT StylesheetXSLT Stylesheet
<?xml version="1.0"?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="weather"><H1><xsl:value-of select="@type"/></H1><xsl:apply-templates/><HR/>
</xsl:template>
<xsl:template match="temp"><LI>Temperature <xsl:apply-templates/>°F</LI>
</xsl:template>
<xsl:template match="wind"><LI>Wind: <xsl:apply-templates/>mph</LI>
</xsl:template>
<xsl:template match="text()"><xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
<weather type="Current conditions"><temp>76</temp><wind>5</wind>
</weather>
<H1>Current conditions</H1>
76
<LI>Temperature: °F</LI>76
<wind>5</wind>
5<LI>Wind: mph</LI>
<temp>76</temp>
5
<HR/>
1
2
3
4
5
6
8
7
9
10
11 1213
XSLT TransformationXSLT Transformation
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
Demonstration: Demonstration: XSL for DocumentsXSL for Documents Create stylesheet for complex documentCreate stylesheet for complex document Run in browserRun in browser
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
Demonstration: Demonstration: XSL On The ServerXSL On The Server Get XML document from serverGet XML document from server
Article.xmlArticle.xml Apply stylesheet, transform, and deliver Apply stylesheet, transform, and deliver
HTML to the browserHTML to the browser Article.aspArticle.asp Article.xslArticle.xsl
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
XSLT OperationXSLT Operation
XMLXML
XSL (TOC)XSL (TOC) XSL(Abstract)XSL(Abstract) XSL (Full)XSL (Full)
HTML (TOC)HTML (TOC)HTML (Abstract)HTML (Abstract)HTML (Full)HTML (Full)XSL XSL
ProcessorProcessor
(HTML)(HTML)
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
Demonstration: Demonstration: XML Data IslandsXML Data Islands Create HTML document with XML data Create HTML document with XML data
islandsislands Article.xmlArticle.xml Article-toc.xslArticle-toc.xsl Article-abstract.xslArticle-abstract.xsl Article-full.xslArticle-full.xsl Article-wtoc.xslArticle-wtoc.xsl
Switch stylesheet under script controlSwitch stylesheet under script control ApplyStyle.htmApplyStyle.htm
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
Case Study: Case Study: <TAG> Newsletter<TAG> Newsletter
XML-enabled Web SiteXML-enabled Web Sitehttp://tagnewsletter.comhttp://tagnewsletter.com
Copyright © 1999, Architag International Corporation.All rights reserved. Use without express written permission from Architag International Corporation is expressly forbidden.
</Tutorial></Tutorial>
Tech Ed 2000 MaterialsTech Ed 2000 Materials http://architag.com/r/TechEd2000http://architag.com/r/TechEd2000
XML and XSLXML and XSL http://msdn.microsoft.com/xmlhttp://msdn.microsoft.com/xml http://www.w3.org/Style/XSL/http://www.w3.org/Style/XSL/
top related