COAP:COAP-2180/week7: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Week 7 [[Help:COAP-2180|COAP 2180]] ===
== Week 7 [[Help:COAP-2180|COAP 2180]] ==


(under construction ....)
Week seven includes three main topics:
 
Week seven includes two topics:
# XML Schema, a more powerful document type definition (gramar) language
# XML Schema, a more powerful document type definition (gramar) language
# Almost final touches to the term project
# XML Q/R if necessary
# XSLT Q/R if necessary
# Work on term project. Each student should a have a good DTD, a provisional XML Schema, an XML test file and an XSLT by the end of the week !


<span style="color:red;">WARNING/REMINDER</span>: The Wednesday week 7 lesson is cancelled. Make-up class is scheduled for '''next Friday (december 10) at ''12.00h'' '''.
In addition:
* [https://www.mozilla.org/en-US/developer/css-grid/ CSS grids] (Mozilla), [https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout CSS Grid Layout] (MDN). As of Feb 2017 it is [https://www.w3.org/TR/css3-grid-layout/ W3C Candidate Recommendation]
* [[Tour de XML]] (other layout languages)


==== Teaching materials ====
== Teaching materials ==


* [[XSD tutorial - Basics‎‎]]
* [[XSD tutorial - Basics‎‎]]
* [http://tecfa.unige.ch/guides/te/files/xml-schema.pdf xml-schema.pdf] (same contents)
* [http://tecfa.unige.ch/guides/te/files/xml-schema.pdf xml-schema.pdf] (slides with same contents)
* XSD example directory: [http://tecfa.unige.ch/guides/xml/examples/xsd-examples/ xsd-examples/] (not really needed)
* [http://www.w3.org/TR/xmlschema-0/ XML Schema Part 0: Primer Second Edition] (W3C Recommendation 28 October 2004, you should have at least a short look at this).
* Text book chapters in the world classroom (see below)
 
== Textbook chapters ==
 
* Ray, Learning XML, Second Edition, '''Chapter 4, Quality Control with Schemas''' (ok explanation by example, but a bit too short)
* Harold, XML in a Nutshell, '''Chapter 17, XML Schema''' (this text is not too easy to understand, but useful reading anyhow)
* Harold, XML in a Nutshell, '''Chapter 22, Schemas reference''' (For reference, in particular for full-time CS students)
 
== Classroom activities ==
 
=== Monday ===
* Translate your "best" DTD to XSD, using the Exchanger Editor (menu Schema->Convert Schema)
* Add at least one data constraint to your XSD, e.g. either a [[XML_Schema_tutorial_-_Basics#Value_constraints|Value constraint]] for a number or a [[XML_Schema_tutorial_-_Basics#Simple_user-defined_types_.28simpleType.29|restricted lists of words to choose from]].
* Validate the XSD Schema
* Validate the XML (remove the DTD and manually select the XSD when asked)
* Work on term project. See the [[COAP:COAP-2180/week8|week8]] page
 
=== Wednesday ===
* Continue adding data constraints to your XSD, e.g. either a [[XML_Schema_tutorial_-_Basics#Value_constraints|Value constraint]] for a number or a [[XML_Schema_tutorial_-_Basics#Simple_user-defined_types_.28simpleType.29|restricted lists of words to choose from]].
* Validate the XML against the XSD.
* Work on term project.
 
The simplest method for validating is the following (in XML Exchanger):
# Remove the DTD reference from the XML
# Click on the "validation" button, then provide the filename of the XSD.
... of course, you will have to repeat this procedure each time you open the XML file
 
More ambitious students can try to associate the XML with the XSD. You need to make changes in both XML and XSD files, as shown in the following example. Change the "myrecipes.org" in the example below by a namespace of your own. In addition ('''more difficult'''), you will have to add namespaces to the XSLT. Read [[XSLT_for_compound_documents_tutorial#Using_XSLT_with_documents_that_have_a_single_name_space | Using XSLT with documents that have a single name space]]
 
XML file:
<source lang="xml">
  <?xml version="1.0"?>
  <list
    xmlns="http://myrecipes.org/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://myrecipes.org/ recipe.xsd"
  >
    ......
  </list>
</source>
 
XSD file:
<source lang="xml">
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://myrecipes.org/"
            xmlns="http://myrecipes.org/"
            elementFormDefault="qualified">
    ....
</xs:schema>
</source>
 
== Homework 7 ==
 
'''Task'''
 
* Take the DTD from your term project or homework 4/5.
* Create an XSD from the DTD
* Add several extra constraints that are appropriate with respect to your project (as many as possible and useful). Typically you may constrain the number of child elements and add data types for element and/or attribute contents.
* Create an XML test file. XSLT/CSS is not required
 
'''Tips:'''
 
* Look at examples (includes ones that could be found on the Internet). e.g. you can google something like "XSD datatypes example"
 
* There are two validation methods in Exchanger:
: (1) Exchanger can easily validate the following kind of XML/XSD combination (as explained [[XSD_tutorial_-_Basics#Association_of_XSD_with_XML.2C_Solution_2| in the XSD tutorial]])
 
XML file fragment:
<source lang="XML">
<your_root
  xmlns="http://myrecipes.org/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://myrecipes.org/ recipe.xsd">
...
<your_root>
</source>
XSD fragment:
<source lang="XML">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://myrecipes.org/"
    xmlns="http://myrecipes.org/"
    elementFormDefault="qualified">
  ...
</xs:schema>
</source>
 
(2) If you are not able to get this to work, then just remove all DTD and Schema-related information from your XML and tell Exchanger where to find the Schema file when you hit the validation button.
 
; Conversion
To translate a DTD to an XSD, use Menu '''Schema->Convert Schema'''.
 
'''Deadline and submission:'''
 
* '''Monday week 8''' (before start of class)
* Use the world classroom
* Submit the *.xsd, the *.xml test files, and an optional optional report file (see below)
 
'''Evaluation criteria (roughly)'''
 
''Work considered as weak:''
* Pure translation without any extra hand editing
 
''Work considered as minimalist:''
* Minimal changes, e.g. a single extra constraint with respect to the number of child elements


==== Textbook chapters ====
''Good work and excellent work (B to A-) may include one or several of the following:
* Inserted comments <!-- ... --> in the XSD that explain some (not all) of the schema
* A report (e.g. in HTML, word, PDF etc.)
* All possible sorts of extra constraints you could reasonably use for your problem, i.e. more than I require for the term project...


* Ray, Learning XML, Second Edition, Chapter 4,  Quality Control with Schemas (ok explanation by example, but a bit too short)
''Brilliant work (A)''
* Harold, XML in a Nutshell, XML Schema, chapter 17 (this text is not too easy to understand, but useful reading anyhow)
* Does '''all''' of the above, i.e. produces a result that could be used in real life.

Latest revision as of 19:15, 2 May 2017

Week 7 COAP 2180

Week seven includes three main topics:

  1. XML Schema, a more powerful document type definition (gramar) language
  2. XML Q/R if necessary
  3. Work on term project. Each student should a have a good DTD, a provisional XML Schema, an XML test file and an XSLT by the end of the week !

In addition:

Teaching materials

Textbook chapters

  • Ray, Learning XML, Second Edition, Chapter 4, Quality Control with Schemas (ok explanation by example, but a bit too short)
  • Harold, XML in a Nutshell, Chapter 17, XML Schema (this text is not too easy to understand, but useful reading anyhow)
  • Harold, XML in a Nutshell, Chapter 22, Schemas reference (For reference, in particular for full-time CS students)

Classroom activities

Monday

  • Translate your "best" DTD to XSD, using the Exchanger Editor (menu Schema->Convert Schema)
  • Add at least one data constraint to your XSD, e.g. either a Value constraint for a number or a restricted lists of words to choose from.
  • Validate the XSD Schema
  • Validate the XML (remove the DTD and manually select the XSD when asked)
  • Work on term project. See the week8 page

Wednesday

The simplest method for validating is the following (in XML Exchanger):

  1. Remove the DTD reference from the XML
  2. Click on the "validation" button, then provide the filename of the XSD.

... of course, you will have to repeat this procedure each time you open the XML file

More ambitious students can try to associate the XML with the XSD. You need to make changes in both XML and XSD files, as shown in the following example. Change the "myrecipes.org" in the example below by a namespace of your own. In addition (more difficult), you will have to add namespaces to the XSLT. Read Using XSLT with documents that have a single name space

XML file:

  <?xml version="1.0"?>
  <list
    xmlns="http://myrecipes.org/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://myrecipes.org/ recipe.xsd" 
   >
     ......
  </list>

XSD file:

 <?xml version="1.0"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://myrecipes.org/" 
            xmlns="http://myrecipes.org/" 
            elementFormDefault="qualified">
    ....
 </xs:schema>

Homework 7

Task

  • Take the DTD from your term project or homework 4/5.
  • Create an XSD from the DTD
  • Add several extra constraints that are appropriate with respect to your project (as many as possible and useful). Typically you may constrain the number of child elements and add data types for element and/or attribute contents.
  • Create an XML test file. XSLT/CSS is not required

Tips:

  • Look at examples (includes ones that could be found on the Internet). e.g. you can google something like "XSD datatypes example"
  • There are two validation methods in Exchanger:
(1) Exchanger can easily validate the following kind of XML/XSD combination (as explained in the XSD tutorial)

XML file fragment:

<your_root
  xmlns="http://myrecipes.org/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://myrecipes.org/ recipe.xsd">
 ...
<your_root>

XSD fragment:

 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	    targetNamespace="http://myrecipes.org/" 
	    xmlns="http://myrecipes.org/" 
	    elementFormDefault="qualified">
  ...
 </xs:schema>

(2) If you are not able to get this to work, then just remove all DTD and Schema-related information from your XML and tell Exchanger where to find the Schema file when you hit the validation button.

Conversion

To translate a DTD to an XSD, use Menu Schema->Convert Schema.

Deadline and submission:

  • Monday week 8 (before start of class)
  • Use the world classroom
  • Submit the *.xsd, the *.xml test files, and an optional optional report file (see below)

Evaluation criteria (roughly)

Work considered as weak:

  • Pure translation without any extra hand editing

Work considered as minimalist:

  • Minimal changes, e.g. a single extra constraint with respect to the number of child elements

Good work and excellent work (B to A-) may include one or several of the following:

  • Inserted comments in the XSD that explain some (not all) of the schema
  • A report (e.g. in HTML, word, PDF etc.)
  • All possible sorts of extra constraints you could reasonably use for your problem, i.e. more than I require for the term project...

Brilliant work (A)

  • Does all of the above, i.e. produces a result that could be used in real life.