Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:dydaktyka:semweb:lab-xml [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== eXtensible Markup Language (XML) ======
 +===== Before the lab =====
 +Reading: ​
 +  * [[http://​www.w3schools.com/​xml/​xml_whatis.asp|XML]] ​
 +  * [[http://​www.w3schools.com/​dtd/​default.asp|DTD]]
 +  * [[http://​www.w3schools.com/​schema/​default.asp|XSD]]
 +  * [[http://​www.w3schools.com/​xpath/​default.asp|XPath]]
 +  * [[http://​www.w3schools.com/​xml/​xml_xsl.asp|XSL]]
 +  * [[#​if_you_want_to_know_more|If you want to know more...]]
  
 +===== Introduction =====
 +Lectures:
 +  * {{http://​home.agh.edu.pl/​~wta/​semweb/​geist-semweb-uri.pdf|Semantic Web: 1.5 - Unicode and URI}}
 +  * {{http://​home.agh.edu.pl/​~wta/​semweb/​geist-semweb-xml.pdf|Semantic Web: 2 - XML}}
 +
 +
 +
 +
 +
 +===== Lab instructions =====
 +
 +The lab is divided into sections. You should allow aprox. 10 minutes for each section. ​
 +However, note that the tasks are increasingly difficult and latter sections may be more time-consuming than the former ones.
 +
 +==== - Warm-up: Well-formedness of the XML ====
 +8-) Determine which of the following XML documents is well-formed. If a document is well-formed,​
 +show its corresponding tree model. If it is not well-formed,​ explain why not. You may assume that all
 +of these documents are intended to be XML 1.0 documents, and thus the declaration is not needed.
 +
 +//NOTE: Assume that the prolog of the documents is present and the following lines are the body of the document//​.\\
 +<​code>​
 +  - <​a><​b/><​a>​
 +  - <​a><​b>​foo</​b></​a><​a>​bar</​a>​
 +  - <​a><​b>​foo</​b><​b>​bar</​a>​
 +  - <​a><​b><​c>​foo</​b>​bar</​c></​a>​
 +  - <​a/><​b>​foo</​b><​b>​bar<​b>​
 +  - <​a><​b><​c>​foo</​c>​baz<​c>​bar</​c></​b></​a>​
 +  - <a x="​1"​ X="​2"><​b>​foo</​b></​a>​
 +  - <a x="​1"><​b x="​2">​foo</​b></​a>​
 +  - <a x="​1"​ y="​2"​ x="​3"><​b>​foo</​b></​a>​
 +  - <​a><​b x="​3"><​c y="​1">​foo</​c><​c>​bar</​c></​b></​a>​
 +</​code>​
 +
 +==== - Creating XML document ====
 +8-) Modify the code below to describe the best book from your bookshelf:
 +
 +<code xml>
 +<​book>​
 +  <​author>​Grigoris Antoniou</​author>​
 +  <​author>​Frank van Harmelen</​author>​
 +  <​title>​A Semantic Web Primer</​title>​
 +  <​date>​2008-10-09</​date>​
 +  <​publisher>​The MIT Press</​publisher>​
 +</​book>​
 +</​code>​
 +
 +  * You can modify the markup and hierarchy.
 +
 +==== - DTD ====
 +  * Using a text editor, define a [[http://​www.w3schools.com/​dtd/​default.asp|DTD]] definition for your XML syntax. Put it in the report 8-)
 +  * You can define DTD definition inside XML file: \\ <​code>​
 +<?xml version="​1.0"​ ?> 
 +<​!DOCTYPE root [
 +]>
 +XML content
 +</​code>​
 +
 +==== - Validating XML with DTD ====
 +  * Test your XML against defined DTD using [[http://​www.xmlvalidation.com/​index.php|online validator]] - **it requires embedded DTD**. \\ or
 +  * You can also test your XML using //​xmlstarlet//​ command: \\ Testing xml file against external DTD definition file use:<​code>​
 +xmlstarlet val -e -d file.dtd file.xml
 +</​code>​or when you use embeded DTD definition use:<​code>​
 +xmlstarlet val -e -E file.xml
 +</​code>​
 +
 +
 +==== - XSD ====
 +  * Using a text editor, define an [[http://​www.w3schools.com/​schema/​default.asp|XSD]] definition for your XML syntax. Put it in the report 8-)
 +
 +==== - Validating XML with XSD ====
 +  * Test your XML against defined XSD using:
 +    * using //​xmlstarlet//​ command:<​code>​
 +xmlstarlet val -e -s file.xsd file.xml
 +</​code>​ \\ or
 +    * [[http://​tools.decisionsoft.com/​schemaValidate|XSD online validator]] \\ or
 +    * [[http://​www.xmlme.com/​Validator.aspx|XML Schema Validator]]
 +
 +==== - XPath ====
 +  * Go to the [[http://​www.xmlme.com/​XpathTool.aspx|XPath Tool]]
 +  * Paste your XML code in the prepared tesxtfield
 +  * Build and test the XPathc for the following:
 +    * find the lastnames of all students,
 +    * find all lastnames of members from a given group,
 +    * find an address of the second member from a given group,
 +    * find all the cities of all members,
 +    * find all the students which are older/​younger than a given age,
 +    * find a lastname of your group leader.
 +  * Put the queries in the report 8-)
 +
 +==== - XSLT: XML -> HTML ====
 +  * Go to the W3Schools'​ [[http://​www.w3schools.com/​xsl/​tryxslt.asp?​xmlfile=cdcatalog&​xsltfile=cdcatalog|online XSLT editor]].
 +  * Paste your XML code in the left textarea
 +  * Modify the XSLT code in the right text area to display your data in a table. Make experiments.
 +===== Control questions =====
 +  * What are the required elements of XML file?
 +  * What is an empty element?
 +  * Does the XML have any predefined tags?
 +  * How to define a comment?
 +  * Is the XML platform dependent?
 +  * What is a CDATA section in XML file?
 +  * What is the meaning of the colon within tag name?
 +  * What is the DTD?
 +  * What is the XSD?
 +  * Which language (DTD or XSD) is more expressive?
 +  * What is the XPath?
 +  * Does the XPath allow for nested queries?
 +  * What is XSLT for?
 +  * How does the XSLT work?
 +===== If you want to know more =====
 +    * [[http://​www.w3.org|www.w3.org]]
 +    * [[http://​validator.w3.org|validator.w3.org]]
 +    * [[http://​www.xml.org|www.xml.org]]
 +    * [[http://​www.xml.com|www.xml.com]]
 +    * [[http://​xml.coverpages.org|xml.coverpages.org]]
 +    * [[http://​www.w3schools.com/​|www.w3schools.com]]
 +    * [[http://​www.ibm.com/​developerworks/​xml|www.ibm.com/​developerworks/​xml]]
 +    * [[http://​xml.oreilly.com/​xml|xml.oreilly.com]]
 +    * [[http://​developer.mozilla.org/​en/​docs/​Main_Page|Mozilla Developer Center]]
 +    * xml schemas: [[http://​www.ibm.com/​developerworks/​library/​x-schematips/?​ca=dgr-lnxw07x-schematips&​S_TACT=105AGX59&​S_CMP=GRsitelnxw07|Ten XML schemas you should know]]
 +    * CSS: [[http://​meyerweb.com/​eric/​css/​|Eric Meyer]]
pl/dydaktyka/semweb/lab-xml.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0