rasmuslh
11-28-2005, 01:55 PM
Hi
I am trying to make two schemas. One general schema with some complextypes which are to be extented in more specific schemas which includes the general schema.
However, I cant get the extension base element to work.
This is a sample of my xml-dokument:
<?xml version="1.0" encoding="UTF-8"?>
<xpnml xmlns="http://www.itu.dk/people/rlh" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.itu.dk/people/rlh
samlet_schema.xsd">
<place id="p1" name="start">
<tokens>
<token tokenid="1" caseid="1">
<name>
<firstname>Rasmus</firstname>
<lastname>Henningsen</lastname>
</name>
<adress>Testvej</adress>
<cpr>270569-1111</cpr>
<tel>26357377</tel>
</token>
</tokens>
</place>
<place id="p2" name="start">
<tokens>
<token tokenid="5" caseid="1">
<approved>true</approved>
<revivedBy>herdis</revivedBy>
</token>
<token tokenid="6" caseid="2">
<ribers>true</ribers>
</token>
</tokens>
</place>
The place element have one tokens element which may have several token elements. The only thing that token elements have in common is the attributtes tokenid and caseid.
Here is a sample of my generel schema:
<xs:complexType name="place">
<xs:sequence>
<xs:element name="tokens" type="tokens"/>
</xs:sequence>
<xs:attribute name="id" type="p_id" use="required"/>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
<xs:complexType name="tokens">
<xs:sequence>
<xs:element name="token" type="tokenplace" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tokenplace">
<xs:attribute name="tokenid" type="xs:integer" use="required"/>
<xs:attribute name="caseid" type="xs:integer" use="required"/>
</xs:complexType>
Here is a sample of my specific schema:
<xs:complexType name="tokenplace1">
<xs:complexContent>
<xs:extension base="tokenplace">
<xs:sequence>
<xs:element name="name" type="name"/>
<xs:element name="adress" type="xs:string"/>
<xs:element name="cpr" type="cpr"/>
<xs:element name="tel" type="tel"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="cpr">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{6}-[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="tel">
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9]{8}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="name">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Currently the type definitions are in the same document so it is not an include problem. When I try to validate against the schema the parser say that no content is allowed in element token which I dont understand since token has been extended in my opinion. Really hope someone can help since I am pretty much stuck with this. :chomp:
Rasmus
I am trying to make two schemas. One general schema with some complextypes which are to be extented in more specific schemas which includes the general schema.
However, I cant get the extension base element to work.
This is a sample of my xml-dokument:
<?xml version="1.0" encoding="UTF-8"?>
<xpnml xmlns="http://www.itu.dk/people/rlh" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.itu.dk/people/rlh
samlet_schema.xsd">
<place id="p1" name="start">
<tokens>
<token tokenid="1" caseid="1">
<name>
<firstname>Rasmus</firstname>
<lastname>Henningsen</lastname>
</name>
<adress>Testvej</adress>
<cpr>270569-1111</cpr>
<tel>26357377</tel>
</token>
</tokens>
</place>
<place id="p2" name="start">
<tokens>
<token tokenid="5" caseid="1">
<approved>true</approved>
<revivedBy>herdis</revivedBy>
</token>
<token tokenid="6" caseid="2">
<ribers>true</ribers>
</token>
</tokens>
</place>
The place element have one tokens element which may have several token elements. The only thing that token elements have in common is the attributtes tokenid and caseid.
Here is a sample of my generel schema:
<xs:complexType name="place">
<xs:sequence>
<xs:element name="tokens" type="tokens"/>
</xs:sequence>
<xs:attribute name="id" type="p_id" use="required"/>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
<xs:complexType name="tokens">
<xs:sequence>
<xs:element name="token" type="tokenplace" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tokenplace">
<xs:attribute name="tokenid" type="xs:integer" use="required"/>
<xs:attribute name="caseid" type="xs:integer" use="required"/>
</xs:complexType>
Here is a sample of my specific schema:
<xs:complexType name="tokenplace1">
<xs:complexContent>
<xs:extension base="tokenplace">
<xs:sequence>
<xs:element name="name" type="name"/>
<xs:element name="adress" type="xs:string"/>
<xs:element name="cpr" type="cpr"/>
<xs:element name="tel" type="tel"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="cpr">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{6}-[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="tel">
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9]{8}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="name">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Currently the type definitions are in the same document so it is not an include problem. When I try to validate against the schema the parser say that no content is allowed in element token which I dont understand since token has been extended in my opinion. Really hope someone can help since I am pretty much stuck with this. :chomp:
Rasmus