Inno: XML Schema

Beitrag lesen

Heyho Leute,
ich habe mich mal etwas mehr mit cem XML Schema befasst
und nun bin ich auf ein Problem gestoßen, dass
ich nicht zu lösen weiß, daher hoffe ich auf eure Hilfe.

Folgende XML soll einem Schema unterliegen:

  
<?xml version='1.0'?>  
<?xml-stylesheet type="text/css" href="http://css.adiolis.com/application.css"?>  
  
<application key="Wiki" xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="application.xsd">  
  
	<information>  
		<version>1.00</version>  
		<name>Wiki Application</name>  
		<date>2009-10-07</date>  
		  
		<description>Das Wiki System besitzt komfortable Funktionen, die ermöglichen, dass mehrere Nutzer an Artikeln arbeiten können.</description>  
		  
		<author>Peter Lustig</author>  
		<authorEmail>PeterLustig@zdf.de</authorEmail>  
		<authorWebsite>PeterLustig.zdf.de</authorWebsite>  
		  
		<direction>ACS/Wiki/</direction>  
		<controller class="Wiki_Controller">Controller.php</controller>  
	</information>  
	  
	<requires>  
		<module minversion="1.0">Database</module>  
		<module minversion="1.1">Template</module>  
		<file>Adiolis.php</file>  
	</requires>  
	  
</application>  

Folgende Elemente müssen nicht in der XML definiert sein:

<authorEmail>PeterLustig@zdf.de</authorEmail>  
<authorWebsite>PeterLustig.zdf.de</authorWebsite>  
<module minversion="1.1">Template</module>  
<file>Adiolis.php</file>  

Die Kindelemente von requires besitzen keine bestimmt anzahl und reihenfolge.

Nun gut, hatte schon viele Ansätze, hab letztendlich vieles vereinfacht, aber letztendlich muss es doch eine lösung geben.

Der einfache Ansatz von mir sieht so aus:

  
<?xml version="1.0"?>  
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">  
  
	<xs:element name="application" type="application"/>  
	  
	<xs:complexType name="application">	  
		<xs:sequence>		  
			<xs:element name="information" type="information"/>  
			<xs:element name="requires" type="requires"/>  
		</xs:sequence>  
		<xs:attribute name="name" type="xs:string" use="required" />	  
	</xs:complexType>  
	  
	  
	<xs:complexType name="requires">  
		<xs:sequence>	  
			<xs:element name="file" type="xs:string"/>  
			<xs:element name="module" type="xs:string"/>  
		</xs:sequence>  
		<xs:attribute name="minversion" type="xs:decimal" default="1.0"/>  
	</xs:complexType>  
			  
	<xs:complexType name="information">  
		<xs:all>  
			<xs:element name="name" type="xs:string"/>  
			<xs:element name="version" type="xs:decimal"/>  
			<xs:element name="date" type="xs:date"/>  
			<xs:element name="description" type="xs:string"/>  
			<xs:element name="author" type="xs:string"/>  
			<xs:element name="authorEmail" type="xs:string"/>  
			<xs:element name="authorWebsite" type="xs:string"/>  
			<xs:element name="direction" type="xs:string"/>	  
			<xs:element name="controller" type="controller" />  
		</xs:all>  
	</xs:complexType>  
	  
	  
	<xs:simpleType name="controller">  
 		<xs:restriction base="xs:string"/>  
	</xs:simpleType>	  
	<xs:attribute name="class" type="xs:string" />  
	  
</xs:schema>  

Was fehlt:

  • Attribut class funktioniert nicht, wie er soll
  • authorEmail, authorWebsite sind required
  • Kindelemnte von requires sind nicht beliebig

Hoffe ihr hilft mir in den 3 Punkten weiter.