XML Schema
Posted: Fri Sep 18, 2015 8:40 pm
Hello there
I have the following .xml code and the corresponding .xsd:
XML file:
XSD file:
Now I would like to extend the .xml file as following:
Extended XML file:
Evidently I have to add some lines to the .xsd file too.
I tried this:
My Problem: How do I set up the new .xsd properly if I insist on remaining the structure as shown in the first .xsd?
Thank you for your help!
Kind regards,
Troix
I have the following .xml code and the corresponding .xsd:
XML file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<lecturelist>
xmlns="http://www.my-fh.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.my-fh.com
file:lecturelist1.xsd">
<lecture>
<name>maths</name>
<semsester>1</semester>
</lecture>
</lecturelist>
XSD file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.my-fh.com"
xmlns:fh="http://www.my-fh.com"
>
<xs:element name="lecturelist">
<xs:complexType>
<xs:sequence>
<xs:element ref="fh:lecture" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="lecture">
<xs:complexType>
<xs:sequence>
<xs:element ref:"fh:name" />
<xs:element ref:"fh:semester" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="title" type="xs:string"/>
<xs:element name="semester" type="xs:string"/>
Extended XML file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<lecturelist>
xmlns="http://www.my-fh.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.my-fh.com
file:lecturelist1.xsd">
<lecture>
<name>maths</name>
<semester>1</semester>
</lecture>
<teacher>
<name>steinberg</name>
<age>55</age>
</teacher>
</lecturelist>
I tried this:
Code: Select all
]<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.my-fh.com"
xmlns:fh="http://www.my-fh.com"
xmlns:fb="http://www.my-fb.com"
>
<xs:element name="lecturelist">
<xs:complexType>
<xs:sequence>
<xs:element ref="fh:lecture" maxOccurs="unbounded" />
<xs:element ref="fb:teacher" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="lecture">
<xs:complexType>
<xs:sequence>
<xs:element ref:"fh:name" />
<xs:element ref:"fh:semester" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="teacher">
<xs:complexType>
<xs:sequence>
<xs:element ref:"fb:name" />
<xs:element ref:"fb:age" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="title" type="xs:string"/>
<xs:element name="semester" type="xs:string"/>
Thank you for your help!
Kind regards,
Troix