[XML/XSL] DTD in XSD-Schema (Adressbuch)

Dieses Thema im Forum "Webentwicklung" wurde erstellt von Dolciume, 21. Februar 2012 .

Schlagworte:
  1. 21. Februar 2012
    DTD in XSD-Schema (Adressbuch)

    Hallo Leute ,

    ich habe hier eine Übung und möchte die so genau wie möglich haben. Dabei spielen Reihenfolge, Bezeichnung, Genauigkeit, Ordnung etc. eine wichtige Rolle.

    Ich habe es mal so weit wie möglich gemacht, jedoch kann dort sicher noch etwas verbessern werden.

    Nun seid ihr gefragt. Tipps & Verbesserungen nehme ich gerne an!

    DTD
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!ELEMENT adressbuch (bezeichnung, adresse*)>
    
    <!ELEMENT bezeichnung (#PCDATA)>
    
    <!-- Adresse -->
    <!ELEMENT adresse (vorname, nachname, emailadressen, telefonnummern, anschriften, notiz)>
    <!ATTLIST adresse
     id ID #REQUIRED
    >
    <!ELEMENT vorname (#PCDATA)>
    <!ELEMENT nachname (#PCDATA)>
    <!ELEMENT emailadressen (email+)>
    <!ELEMENT telefonnummern (telefon+)>
    <!ELEMENT anschriften (anschrift+)>
    <!ELEMENT notiz (#PCDATA)>
    
    <!ENTITY % kind "(office|privat)">
    
    <!-- Email Adresse -->
    <!ELEMENT email (#PCDATA | alias)*>
    <!ATTLIST email
     typ %kind; #REQUIRED
    >
    <!ELEMENT alias (#PCDATA)>
    
    <!-- Telefonnummern -->
    <!ELEMENT telefon (#PCDATA)>
    <!ATTLIST telefon
     typ %kind; #REQUIRED
     land CDATA #IMPLIED
     vorwahl CDATA #REQUIRED
    >
    
    <!-- Anschriften -->
    
    <!ELEMENT anschrift (strasse, plz, ort, land)>
    <!ATTLIST anschrift
     typ %kind; #REQUIRED
    >
    <!ELEMENT land (#PCDATA)>
    <!ELEMENT ort (#PCDATA)>
    <!ELEMENT plz (#PCDATA)>
    <!ELEMENT strasse (#PCDATA)>
    <!ATTLIST strasse
     nr CDATA #REQUIRED
    >
    <!ENTITY at "@">
    


    XSD-Schema
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLschema" elementFormDefault="qualified">
     <xsd:annotation>
     <xsd:documentation xml:lang="de"> 
     Uebung!
     </xsd:documentation>
     </xsd:annotation>
     
     
     <!-- Wurzelelement -->
     <xsd:element name="adressbuch" type="adressbuchTyp"/>
     
     
     <!-- Adressbuch -->
     <xsd:complexType name="adressbuchTyp">
     <xsd:sequence>
     <xsd:element name="bezeichnung" type="xsd:string"/>
     <xsd:element name="adresse" ref="adresseTyp" minOccurs="1" maxOccurs="unbounded"/>
     </xsd:sequence>
     </xsd:complexType>
     
     
     <!-- Adresse -->
     <xsd:complexType name="adresseTyp">
     <xsd:sequence>
     <xsd:element name="vorname" type="xsd:string" />
     <xsd:element name="nachname" type="xsd:string" />
     <xsd:element name="emailadressen" type="emailadressenTyp" />
     <xsd:element name="telefonnummern" type="telefonnummernTyp" />
     <xsd:element name="anschriften" type="anschriftTyp"/>
     <xsd:element name="notiz" type="xsd:string "/>
     </xsd:sequence>
     <xsd:attribute name="id" type="xsd:ID" use="required" />
     </xsd:complexType>
     
     
     <!-- Entity typ-->
     <xsd:attribute name="typ" use="required" />
     <xsd:simpleType>
     <xsd:restriction base="xsd:string">
     <xsd:enumeration value="office" />
     <xsd:enumeration value="privat" />
     </xsd:restriction>
     </xsd:simpleType>
     
     
     <!-- Email Adresse -->
     <xsd:complexType name="emailadressenType">
     <xsd:element name="email" maxOccurs="unbounded" />
     <xsd:simpleType>
     <xsd:restriction base="xsd:string">
     <xsd:pattern value="\[a-zA-Z0-9]+@aifb.uni-karlsruhe.de" />
     </xsd:restriction>
     </xsd:simpleType>
     <xsd:attribute ref="typ" />
     </xsd:complexType>
     
     
     <!-- Telefonnummern -->
     <xsd:complexType name="telefonnummernType">
     <xsd:element ref="telefon" maxOccurs="unbounded" />
     </xsd:complexType>
     
     
     <!-- Telefonnummer -->
     <xsd:complexType name="telefon">
     <xsd:simpleContent>
     <xsd:extension base="xsd:string">
     <xsd:attribute ref="typ" />
     <xsd:attribute name="land" use="optional" />
     <xsd:attribute name="vorwahl" use="required" />
     <xsd:simpleType>
     <xsd:restriction base="xsd:positiveInteger">
     <xsd:minLength value="4" />
     <xsd:maxLength value="7" />
     </xsd:restriction>
     </xsd:simpleType>
     </xsd:extension>
     </xsd:simpleContent> 
     </xsd:complexType>
     
     
     <!-- Anschriften -->
     <xsd:complexType name="anschriftenType">
     <xsd:sequence>
     <xsd:element name="strasse" type="strasseType" />
     <xsd:element name="plz" type="xsd:positiveInteger" />
     <xsd:element name="ort" type="xsd:string" />
     <xsd:element name="land" type="xsd:string" />
     </xsd:sequence>
     </xsd:complexType>
     
     
     <!-- Strasse -->
     <xsd:complexType name="strasseType">
     <xsd:simpleContent>
     <xsd:extension base="xsd:string">
     <xsd:attribute name="nr" base="xsd:string" use="required" />
     </xsd:extension>
     </xsd:simpleContent>
     </xsd:complexType>
     
     
    </xsd:schema>
    

    Vielen Dank!
     
  2. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.