XML Tutorial Timothy W. Cole Thomas G. Habing University of Illinois at UC CDP / Colorado Alliance...

of 41/41
XML Tutorial Timothy W. Cole Thomas G. Habing University of Illinois at UC CDP / Colorado Alliance of Research Libraries 23/24 October 2002
  • date post

  • Category


  • view

  • download


Embed Size (px)

Transcript of XML Tutorial Timothy W. Cole Thomas G. Habing University of Illinois at UC CDP / Colorado Alliance...

  • XML TutorialTimothy W. Cole Thomas G. Habing University of Illinois at UC

    CDP / Colorado Alliance of Research Libraries 23/24 October 2002

  • PresentersTim ColeMathematics Librarian & Assoc. Prof. of Library Admin.PI, Univ. of Illinois OAI Metadata Harvesting [email protected]

    Tom HabingResearch Programmer, Grainger Engineering Library Information [email protected]

  • Agenda XML TutorialWell-formed XML (basic markup)DTDs and schemasStylesheetsXML and databases

    Topics include illustrations, demos, and exercises.

  • Well-formed XMLXML 1.0 SpecificationMarkupProlog & Document Type DeclarationElementsAttributesContentEntitiesEncoded (Unicode) characters

  • Prolog & Document Type DefinitionXML documents should begin with an XML Declaration which specifies versionOptionally may also include:Encoding (recommended)Stand-alone declarationDocument Type Definition is typically next

  • ElementsElements are markup that enclose content or Content modelsParsed Character Data OnlyChild Elements OnlyMixedEmptyCole, T

  • AttributesAssociate a name-value pair with an elementCan be used to embellish contentor to associate added content to an elementAttributes beginning XML are reserved

    Cole, T

  • EntitiesPlaceholders for internal or external contentPlaceholder for a single characteror string of textor external content (images, audio, etc.)Implementation specifics may vary

    &copyright; is replaced by &pic; is replaced by graphic image

  • Character Encoding IssuesXML Parsers must accept UTF-8 & UTF-16Also must accept nnnn; or hhhh;MARC-8 encodings must be converted to Unicode for use in XMLSpecial rules for EOL and control charactersChanges will be effective version 1.1


  • NamespacesQualify element and attribute names Allows modularization of schemasMix and match elements from multiple schemas in document instancesImport or include from one XML Schema into another

  • ZVON Tutorialhttp://www.zvon.org/xxl/XMLTutorial/General/contents.html

  • Simple IllustrationsA POEM

    Unqualified Dublin Core

  • Simple Authoring ToolsMS Notepad (Plain Text Editor)

    MS XML Notepad Beta 1.5

  • XML Markup ExerciseMarkup one or more of the sample Bib recordsUse for your root elementUse Dublin Core element names where applicable:

  • Advanced ExamplesMARCMODSOAI (version 2.0)DLI/DLIB Test Suite Journal ArticleRDF Qualified Dublin CoreGuidelines for DC & RDF DC in XMLSOAP (Primer)

  • Advanced Authoring Tool DemosYAWC - Microsoft Word

    Extensibility TurboXML

  • DTDs and Schemas Formal descriptions of document structureSet expectationsMaximize reusabilityEnforce business rulesValidation ensures that documents conform Could be multiple schemas for different purposes or different points in a documents lifecyclePrimary: DTD or XML Schema LanguageOthers: Schematron or Relax NG

  • Document Type Definitions (DTD)Legacy from SGML; part of XML standard

  • ZVON DTD Tutorialhttp://www.zvon.org/xxl/DTDTutorial/General/contents.html

  • Sample DTDsA simple DTD for poems

    XHTML 1.0 Strict

    How to validateIn Internet ExplorerUsing XML Notepad

  • DTD ExerciseCreate a DTD for the previous XML Bib FilesName your DTD file BibClass.dtdInsert at the top of each of your XML Bib Files

    Validate using XML Notepad or Internet Explorer

  • More Examples of DTDsOASIS DocBookTEIGutenberg

  • XML schema languageNew in XMLUses XML syntaxSupports datatypingRicher and more complex

  • XML SchemasBibClass.xsdSimple Dublin Core

    Datatypes and FacetsUnionsEnumerationsLists

  • More examples of XML SchemasQualified Dublin Core


  • Alternatives: Schematron & RelaxNGSchematron based on XPath (XSLT)Doesnt support datatyping as wellSupports additional content modelsMay become an ISO standardRelaxNGReturns some of the power of SGML DTDs back to XML (mixed and unordered content)Uses datatyping from the XML Schema specDoes not support inheritanceDeveloped by an OASIS Technical Committee chaired by James Clark

  • DTD and Schema ToolsExtensibility TurboXML

    Corel/SoftQuad XMetaL

    XSV for validating

  • XML & Cascading Style SheetsAttach styling instructions directly to XML files
  • XSLT Transforming StylesheetsLanguage for transforming XML documentsInto HTML, Text, or other XML documentsSupported in new browsers (IE5+, Mozilla; not Opera)Usually applied on the server or in batch modeValuable for interoperability or reusability


  • CSS & XSLT ExamplesA CSS for poems in XML

    XSLT for Dublin Core XML to XHTMLXSLT for MARC21 XML to HTML

    XSLT for MARC21 XML to DC XML

  • ZVON Tutorialhttp://www.zvon.org/xxl/XPathTutorial/General/examples.html


  • XSLT ExerciseCreate a simple XSLT to transform your previous Bib XML files into HTMLName the file simple.xslEither attach the XSLT to your files usingAnd display it in IEOr use MSXSL from the command line to create the HTML file to displaymsxsl.exe source.xml simple.xsl o source.htm


    XSL Formatter

  • XML & databasesDiscussion PointsSuitability of XML for databasesXML Query LanguageXML & relational databasesDemonstrationsXML and MS SQL ServerA simple XML search using XSLT

  • Suitability for databasesDocuments are well-structured (well-formed syntax requirement)Content is well-labeled (markup semantics)Ubiquitous, cross-application, cross-communityOpen, non-proprietary standardValidated XML potentially machine-understandable

  • XML Query LanguageIntended to facilitate interaction between the web world and the database world.Follow-on to Quilt (Don Chamberlin, et al.)Another special-purpose programming language for processing XML (& XML-like database structures)Expressions, data types, functions, etc.Access (search) functionality e.g., not for updateLike XSLT, it relies on XPathBorrows data types from XML schema languageTemplate Processor (like XSLT, PHP, JSP, ASP)

  • E.g., List books published by Addison-Wesley after 1991:

    XQuery: { for $b in document("http://www.bn.com")/bib/book where $b/publisher = "Addison-Wesley" and $b/@year > 1991 return { $b/title } } Result: TCP/IP Illustrated Advanced Programming in the Unix environment

  • XML Query ImplementationsW3C Grammar Test PageSoftwareAG Tamino / QuiPQueries XML files directly or XML in TaminoMicrosofts XQuery DemoOnline demo queries W3C use cases documentsOracle prototype XQuery implementationQueries XML filesSame site has Oracle SQL/XML implementationXindice (apache.org)Uses XPath instead of XQuery

  • XML & Relational DBMSSQLX Mapping data types, character sets, from SQL to XMLSearching XML using XPath-based SQL style queries Import / Export of XML from relational database management systems now commonSpecifics vary by implementationMicrosoft implementation allows:Query relational DB using XPathQuery with SQL, return XMLLoad XML directly into Microsoft SQLOLEDB provider for XML files

  • DemonstrationsUsing XSLT to query multiple XML docsXSLT to search multiple DC XML files

    Fetching XML from Microsoft SQL

  • Contact informationPresentationhttp://dli.grainger.uiuc.edu/Publications/CDP/[email protected] http://www.staff.uiuc.edu/~t-cole3/

    [email protected]