Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   XML (https://www.delphipraxis.net/46-xml/)
-   -   XML-Schema Attribute bei simplen Datentypen (https://www.delphipraxis.net/115549-xml-schema-attribute-bei-simplen-datentypen.html)

engel90 13. Jun 2008 20:26


XML-Schema Attribute bei simplen Datentypen
 
Hallo liebe DPler,
ich erstelle zur Zeit eine Art Datenbankprogramm, welches XML-Dateien abspeichert. Für diese XML-Dateien möchte ich Schemata erstellen. Dabei bin ich folgendes Problem gestossen:

ich möchte innerhalb des Rootelementes eine Element mit dem namen "phonenumber" erstellen. Dieses Element soll das Attribut "type" enthalten welches ein Enumerationstyp ist und festlegt ob es eine private oder geschäftliche Telefonnummer ist.

So soll es am Ende aussehen:
XML-Code:
<root>
  <phonenumber type="">+451135361145</phonenumber>
</root>
Bis jetzt bin ich beim entsprechenden Schemateil soweit:
XML-Code:
<xsd:simpleType name="phonenumber">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[+]?[0-9]+"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="phonenumbertype">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="private"/>
    <xsd:enumeration value="business"/>
  </xsd:restriction>
</xsd:simpleType>
Nun komm ich jedoch nicht weiter, da ich nicht weiß, wie ich dem simpletype "phonenumber" das Attribute "type" hinzufügen kann.
Ein einfaches "<xsd:attribute name="type" type="phonenumbertype"/>" funktioniert irgendwie nicht.

MfG
engel90

engel90 14. Jun 2008 19:17

Re: XML-Schema Attribute bei simplen Datentypen
 
ok das problem hat sich gelöst.

es geht folgendermaßen:
XML-Code:
<xsd:complexType name="phonenumberstructure">
  <xsd:simpleContent>
    <xsd:extension base="xsd:string">
      <xsd:attribute name="type" type="phonenumbertype"/>
    </xsd:extension>
  </xsd:simpleContent>
</xsd:complexType>


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:07 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz