Class 12 Outline

  1. Quiz 2
  2. Homework 2

2. Homework 2 - XML and Schema

Details

  • Create and submit a matching xml dataset and schema.
  • The xml must be a custom dataset that you invent.
  • For guidance, see the example: myxmlre.xml and myxmlre.xsd

  • To receive full credit, your xml and schema must pass a validation test.

    • terminal-based xml validation:
      • xmllint --noout --schema myxmlre.xsd myxmlre.xml
    • python also has an xml validation package called xmlschema
      • you must install this package.
        • I installed by entering into the terminal: conda install -c conda-forge xmlschema
In [1]:
import xmlschema # google xmlschema and read.
my_schema = xmlschema.XMLSchema('class12_files/myxmlre.xsd')
my_schema.is_valid('class12_files/myxmlre.xml')
Out[1]:
True
In [ ]:
#What does the following do?
d = xmlschema.to_dict('class12_files/myxmlre.xml')

Due Date

  • Sunday March 11 at 11:59pm

Submission

  • Submit to UBLearns a zipped folder called: YourLastNane_HW2.zip (e.g., Taylor_HW2.zip)
  • Inside the zipped folder should be 2 files:
    • HW2.xml
    • HW2.xsd
  • Points will be deducted if you do not use this naming format.