Warnung: file_put_contents(/home/www/web1/html/php_dev/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/www/web1/html/php_dev/sys/lib.activity.php (Zeile 58)
XML Schema restriction für element UND attribut [Archiv] - PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr

- Ad -
php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
XML Schema restriction für element UND attribut


 
fightwithxml
29-12-2008, 19:31 
 
Moin, ich habe hier für eine kleine Testdatenbank den Typ Personen definiert. Dieser hat ein Element "telefon" mit Attribut typ (mobil|festnetz) und der Nummer (nur Zahlen und Abstände). Wie kann ich das Schema richtig definieren? Mein parser spuckt einen Fehler nach dem anderen aus...

Sollte etwa so aussehen:

...
<telefon typ="mobil">023 447 55 66</telefon>
...



<xs:complexType name="personen">
<xs:complexContent>
<xs:extension base="tiere">
<xs:sequence>
<xs:element name="telefon">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="xs:string">
<xs:pattern value="([ 0-9\+]+)" />
<xs:attribute name="typ">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="mobil|festnetz" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
...
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>


Im Moment meint XMLSpy dazu:


Die Basistyp-Definition 'xs:string' ist für die Complex Type Definition '{anonymous}', welche vom Typ 'simpleContent' ist, unzulässig.
Fehlerpfad: xs:schema / xs:complexType / xs:complexContent / xs:extension / xs:sequence / xs:element / xs:complexType
Details:
src-ct.2.1: Die Basistyp-Definition 'xs:string' ist für die Complex Type Definition '{anonymous}', welche vom Typ 'simpleContent' ist, unzulässig.

 
fightwithxml
20-01-2009, 15:14 
 
Habe es mittlerweile so gelöst:



<xs:complexType name="personen">
<xs:complexContent>
<xs:extension base="tiere">
<xs:sequence>
<xs:element name="telefon" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="telefon_type">

<xs:attribute name="typ">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="mobil|festnetz"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>

</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
...

<xs:simpleType name="telefon_type">
<xs:restriction base="xs:string">
<xs:pattern value="([ 0-9\+]*)"/>
</xs:restriction>
</xs:simpleType>



Ich hoffe das hilft jemandem.


Alle Zeitangaben in WEZ +2. Es ist jetzt 07:14 Uhr.