Xml p3 -Lecture Notes
- 2. xsd
• Schema --- 1.Simple type(no child,attributes)
• restriction,built in data types.
• 2.Complex type(can contain)
• Simple content----no child,extension,restriction.
• Complex content------child,no limitations
2
- 4. Top Layer
• <?xml version="1.0"?>
<note xmlns="https://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
xsi:schemaLocation="https://www.w3schools.com
note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
4
- 8. Complex type
• <product pid="1345"/>
• <employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
• <food type="dessert">Ice cream</food>
• <description>
It happened
on <date lang="norwegian">03.03.99</date> ....
</description>
8
- 31. Complex type
• <xml version=“1.0”>
• <schema xmlns=http://www.w3.org/2001/XMLSchema
• xmlns:computer= “”
• targetnamespace=“ “>
• <simpleType name=“gigahertz”>
• <restriction base=“decimal”>
• <mininclusive value=“2.1”/>
• </restriction>
• </simpleType>
• <complexType name=“CPU”>
• <simpleContent>
• <extension base=“string”>
• <attribute name=“model” type=“string”/>
• </extension>
• </simpleContent>
• </complexType>
31
- 32. Complex type
• <complexType name=“portable’>
• <all>
• <element name=“processor” type=“computer:cpu” />
• <element name=“monitor” type=“int” />
• <element name=“CPUSpeed” type=“computer:gigahertz” />
• <element name=“RAM” type=“int” />
• </all>
• <attribute name=“manufacturer” type=“string” />
• </complexType>
• <element name=“laptop” type=“computer:portable” />
• </schema>
32