1 / 36

XML

XML. The Good, the Bad, and the Ugly. XML Process Overview. XML. XML Process in Motion. Showtime!!. XML: Overview XML does NOT DO Anything!. XML stands for E X tensible M arkup L anguage XML is a markup language much like HTML XML was designed to describe data

river
Download Presentation

XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML The Good, the Bad, and the Ugly XML, The Good, the Bad, and the Ugly

  2. XML Process Overview XML, The Good, the Bad, and the Ugly

  3. XML XML, The Good, the Bad, and the Ugly

  4. XML Process in Motion • Showtime!! XML, The Good, the Bad, and the Ugly

  5. XML: OverviewXML does NOT DO Anything! • XML stands for EXtensible Markup Language • XML is a markup language much like HTML • XML was designed to describe data • XML tags are not predefined. You must define your own tags • XML uses an XML Schema or a Document Type Definition (DTD) to describe the data (yeah, but…). • XML with an XML Schema or a DTD is designed to be self-descriptive. (whatever that means…) XML, The Good, the Bad, and the Ugly

  6. XML Overview: ElementsData is Divided into Elements <ARGUMENT> <FACT>One way to learn a language is to immerse yourself in it.</FACT> <FACT>If you’re reading this, you’re immersed in XML.</FACT> <CONCLUSION>One way to learn XML is to read this.</CONCLUSION> </ARGUMENT> <ARGUMENT> <FACT>I made up these tags to suit my purpose.</FACT> <FACT>My purpose was to help you read XML.</FACT> <CONCLUSION>I made up these tags to help you.</CONCLUSION> </ARGUMENT> XML, The Good, the Bad, and the Ugly

  7. XML Overview: Root ElementOne Root Element <EXAMPLES_OF_LOGIC> <ARGUMENT> <FACT>One way to learn a language is to immerse yourself in it.</FACT> <FACT>If you’re reading this, you’re immersed in XML.</FACT> <CONCLUSION>One way to learn XML is to read this.</CONCLUSION> </ARGUMENT> <ARGUMENT> <FACT>I made up these tags to suit my purpose.</FACT> <FACT>My purpose was to help you read XML.</FACT> <CONCLUSION>I made up these tags to help you.</CONCLUSION> </ARGUMENT> </EXAMPLES_OF_LOGIC> XML, The Good, the Bad, and the Ugly

  8. XML Overview: Empty ElementsEmpty, but not forgotten <EXAMPLES_OF_LOGIC> <ARGUMENT> <FACT>One way to learn a language is to immerse yourself in it.</FACT> <FACT>If you’re reading this, you’re immersed in XML.</FACT> <CONCLUSION>One way to learn XML is to read this.</CONCLUSION> </ARGUMENT> <ARGUMENT/> <ARGUMENT> <FACT>I made up these tags to suit my purpose.</FACT> <FACT>My purpose was to help you read XML.</FACT> <CONCLUSION>I made up these tags to help you.</CONCLUSION> </ARGUMENT> </EXAMPLES_OF_LOGIC> XML, The Good, the Bad, and the Ugly

  9. XML Overview: Attributes Properties by another name <EXAMPLES_OF_LOGIC> <ARGUMENT convincing="Yes"> <FACT>All virtues are laudable.</FACT> <FACT>Kindness is a virtue.</FACT> <CONCLUSION>Kindness is laudable.</CONCLUSION> </ARGUMENT> <ARGUMENT convincing="No"/> <ARGUMENT convincing="No"> <FACT>Socrates was a man.</FACT> <FACT>All men are created equal.</FACT> <CONCLUSION>Socrates was Plato.</CONCLUSION> </ARGUMENT> </EXAMPLES_OF_LOGIC> XML, The Good, the Bad, and the Ugly

  10. XML Overview:Declarations (Duuude, I'm XML!) • Declare that a file contains XML and conforms to version 1.0 (the current and only version, but hey!)<?xml version="1.0"?> (location: if used, line 1 always) • Declare other attributes • character encoding scheme <?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="iso-8859-1"?> XML, The Good, the Bad, and the Ugly

  11. XML Components So Far • One root element • One or more elements (can be nested) • Empty Elements--optional • Attributes--optional • XML declaration—optional XML, The Good, the Bad, and the Ugly

  12. XML Overview: NamespacesWhere is Martha Stewart when you need her?? (And what ARE these?) • An XML good thing: you get to name your data elements. • An XML bad thing: everybody else gets to name their data elements, too! • The result: naming conflicts (are we having fun yet?) • XML uses Namespaces to prevent like-named elements from being confused. (and there is nothing worse than a confused element, trust me…) XML, The Good, the Bad, and the Ugly

  13. XML Namespace Example <TRAINING_MODULE xmlns=“http://www.wordsite.com/NameSpace1”> <BUILDING_BLOCK> <NAME>Element</NAME> <DESCRIPTION>An element consists of a start tag, an end tag, and the data that lies between the start and end tags. For example, this sentence is part of a DESCRIPTION element.</DESCRIPTION> <FUNCTION>Stores data.</FUNCTION> <NOTE>Elements can be nested inside other elements. For example, this NOTE element is nested inside a BUILDING_BLOCK element. The preceding NAME element, DESCRIPTION element, and FUNCTION element are also nested inside the same BUILDING_BLOCK element.</NOTE> </BUILDING_BLOCK> …………………………………………. </TRAINING_MODULE> XSLT XML, The Good, the Bad, and the Ugly

  14. XML: GraduationThe (mostly) Whole Enchalada • One root element • One or more elements (can be nested) • Empty Elements--optional • Attributes--optional • XML declaration—optional • Namespaces XML, The Good, the Bad, and the Ugly

  15. XSLT XML, The Good, the Bad, and the Ugly

  16. XSLT: OverviewXSLT DOES do something! XSL consists of three parts: • XSLT: A language for transforming XML documents • XPath:A language for defining or filtering parts of an XML document. • XSL-FO:A language for formatting XML documents XML, The Good, the Bad, and the Ugly

  17. XSLT Overview: eXtensible Stylesheet Language • Purpose (porpoise, papoose):Transform XML data to some type of output format – html files, PDF files, another xml file, etc. for presentation. • Specialized XML vocabulary • Single Sourcing (oooh, wow…)Multiple XSLT files can be applied to one xml file to create multiple outputs. • Separate Data from Presentation XML, The Good, the Bad, and the Ugly

  18. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://www.wordsite.com/NameSpace1"> <HTML> <HEAD> <TITLE>Building Blocks of XML: A Teacher Guide</TITLE> </HEAD> <BODY> <H2>Building Blocks of XML: A Teacher Guide</H2> <H3>Instructions for teacher:</H3> <TABLE> <xsl:for-each select="ns1:TRAINING_MODULE/ns1:BUILDING_BLOCK"> <TR ALIGN="LEFT" VALIGN="TOP"> <TD width="96"> <xsl:value-of select="ns1:NAME"/> </TD> <TD width="216"> <xsl:value-of select="ns1:DESCRIPTION"/> </TD> <TD width="216"> <xsl:value-of select="ns1:FUNCTION"/> </TD> <TD width="216"> <xsl:value-of select="ns1:NOTE"/> </TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template> </xsl:stylesheet> XML, The Good, the Bad, and the Ugly

  19. XSD: eXtensible Stylesheet Definition XML, The Good, the Bad, and the Ugly

  20. XSD Overview: Schema Pupose • Purpose:A schema is an XML file that describes the structure of an XML data file and the rules for what kind of data can be stored there. • Valid XML:A file that conforms to the structure and rules. • Separate Validation from Data and Presentation. • A secret (sssshhh…): Not required to display XML data (!) XML, The Good, the Bad, and the Ugly

  21. XSD Schema Example • Take a look at your schema handout for an example of a schema. • Go to www.w3schools.com and Microsoft for more information about schema construction. XML, The Good, the Bad, and the Ugly

  22. XML Transformation: Example • View a real life XML transform. • See how the components fit together. XML, The Good, the Bad, and the Ugly

  23. XML Uses: The Good Stuff • Web: Table of Contents, table oriented data • Word and Excel import/export • DocBook Schemas and Transforms • RoboHelp import/export • XSL-FO to PDF XML, The Good, the Bad, and the Ugly

  24. XML, The Good, the Bad, and the Ugly

  25. XML, The Good, the Bad, and the Ugly

  26. XML, The Good, the Bad, and the Ugly

  27. XML : The BadWhat They Never Tell You XML, The Good, the Bad, and the Ugly

  28. XML: The BAD How DOES XML Get Displayed????? Things they don't tell you… • No shoes, no shirt, no display.Requires XML-aware software and the extra stuff necessary to display it. • Special encoding and character display. • Using CSS XML, The Good, the Bad, and the Ugly

  29. XML Display Gotchas • Special characters like < > & and others need special handling so that the xml parser doesn’t get confused and think they are part of the XML data.<![CDATA a > b > c ]]> • Character encoding—most of the time a non issue. <?xml version="1.0" encoding="utf-8"?> • Handling blank spaces XML, The Good, the Bad, and the Ugly

  30. XML: The UglyMy Data, YOUR Browser Browsers use different ways of displaying XML (requires browser detection) • How the heck does XML actually GET displayed??? • Client display and Server display • Validation and Error Interception XML, The Good, the Bad, and the Ugly

  31. My Data, YOUR BrowserBrowser Detection • Option 1: Script Detection //**** JavaScript Browser Variables **** var isIE = (document.all) ? true : false; var isDOM=(document.getElementById && !document.all) ? true : false; var isNetscape=(document.layers) ? true : false; • Option 2 Put all XSLT and CSS references in the XML file and sort of forget about Browser detection. <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="exchangerates.xsl"?> <?xml-stylesheet type="text/css" href="help_style.css"?> XML, The Good, the Bad, and the Ugly

  32. My Data, YOUR BrowserAre You Being Served? Server or Client Displayif (isServerBased()) { // Do some Server display } else { // Do Client display } XML, The Good, the Bad, and the Ugly

  33. My Data, YOUR BrowserWhat Really, Really Happens • Load the XML file into memory using the browser’s method. Look out for the bad guys. • Load the XSLT file into memory using the browser’s method. Same bad guy check. • Call the Transform process of the Browser you’re using and write it out to the current page. XML, The Good, the Bad, and the Ugly

  34. XML A good option even so! • Example 1: An XML TOC and data display. XML, The Good, the Bad, and the Ugly

  35. Sources and Links • Grandma: http://www.w3.org • www.w3schools.comA great place to learn all kinds of web related technologies • Microsoft (oh, yes!)http://msdn.microsoft.com/xml/ • www.siteexperts.com(cf. Building Documents with XML, XSL, and CSS) • DOCBook: www.docbook.org and www.docbook.sourceforge.net • http://www.codehound.com/xml/ XML, The Good, the Bad, and the Ugly

  36. XML Tools and Editors • Free, free, free http://architag.com/xray/ XML, The Good, the Bad, and the Ugly

More Related