1 / 24

Fejlett programozási technikák II.

Fejlett programozási technikák II. Juhos István juhos@inf.u-szeged.hu www.inf.u-szeged.hu/~juhos. 9. DTD. Document Type Definition www.w3.org/TR/REC-xml. DTD Deklaráció. Belső <!DOCTYPE root-element [element-declarations]> Külső <!DOCTYPE root-element SYSTEM "filename">. DTD Kategóriák.

baka
Download Presentation

Fejlett programozási technikák II.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fejlett programozási technikák II. Juhos Istvánjuhos@inf.u-szeged.huwww.inf.u-szeged.hu/~juhos 9

  2. DTD Document Type Definition www.w3.org/TR/REC-xml

  3. DTD Deklaráció • Belső <!DOCTYPE root-element [element-declarations]> • Külső <!DOCTYPE root-element SYSTEM "filename">

  4. DTD Kategóriák • Elements(tag nevek, pl. body) • Attributes (pl. bgcolor=„blue”) • Entities(&ent_név;) • PCDATA(parsed character data, általános szöveg) • CDATA(NOT be parsed character data, [!CDATA[…]])

  5. DTD Element <!ELEMENT elemnév kategória> <!ELEMENT elemnév (elem. tartalom)> (elem. tartalom): EMPTY ANY (#PCDATA) (tagnév) (szabályok)

  6. DTD Szabályok • <!ELEMENT elemnév (szabályok)> <!ELEMENT note (#PCDATA,ez,ésez+,(emez|vagyemez)*)> • Tag előfordulások ? - 0 vagy 1 + - min. 1 * - 0 vagy több

  7. DTD Attribútumok <!ATTLIST tagnév attrnév1 CDATA #REQUIRED attrnév2 (ez|vagyez)#IMPLIED attrnév2 (emez|vagyemez) ”alapért” >

  8. DTD Példa 1kliens_form.xml 1kliens_form.dtd dist\validate 1kliens_form.xml csinaljunk valami formai hibat az xml-ben pl. szakok –> xszakok dist\validate 1kliens_form.xml

  9. XMLSchema XMLSchema www.w3c.org

  10. XMLSchema hivatkozásés definíció XML fájlban <gyökér_tagnév xmlns:xsi=„http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=„fajlnev.xsd"> XSD fajlban <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  11. XMLSchema Element • Egyszerű típus <!ELEMENT tagnév (#PCDATA)> <xs:element name=„tagnév" type="xs:etípus"/>

  12. XMLSchema Element • Összetett típus <!ELEMENT tagnév (mástag , mégmás)> <xs:element name=„tagnév"> <xs:complexType> <xs:sequence> <xs:element name=„mástag" type="xs:etípus"/> <xs:element name=„mégmás" type="xs:etípus"/> </xs:sequence> </xs:complexType> </xs:element>

  13. XMLSchema Elemhivatkozás <xs:complexType name=„tagnév"> <xs:complexContent> <xs:extension base=„másiktagnév"> <xs:sequence> <xs:element name="address" type="xs:string"/> <xs:element ref=“egymasiktagnev"/> ...

  14. Definiált adattípusok • xs:string • xs:decimal • xs:integer • xs:boolean • xs:date • xs:time <xs:element name="color" type="xs:string" default="red"/> <xs:element name="color" type="xs:string" fixed="red"/>

  15. XMLSchema Attribútumok <xs:attribute name=„attrnév" type=„típus"/>

  16. XMLSchema Attribútum Opciók <xs:attribute name="lang" type="xs:string" default="EN"/> <xs:attribute name="lang" type="xs:string" fixed="EN"/> <xs:attribute name="lang" type="xs:string" use="optional"/> <xs:attribute name="lang" type="xs:string" use=„required"/>

  17. XMLSchema Megszorítások <xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> </xs:element>

  18. XMLSchema Megszorítások XMLSchema Típusdefiníció <xs:element name="car" type="carType"/> <xs:simpleType name="carType"> <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction> </xs:simpleType>

  19. Constraint Description enumeration Defines a list of acceptable values fractionDigits Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero length Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero maxExclusive Specifies the upper bounds for numeric values (the value must be less than this value) maxInclusive Specifies the upper bounds for numeric values (the value must be less than or equal to this value) maxLength Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero minExclusive Specifies the lower bounds for numeric values (the value must be greater than this value) minInclusive Specifies the lower bounds for numeric values (the value must be greater than or equal to this value) minLength Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero pattern Defines the exact sequence of characters that are acceptable totalDigits Specifies the exact number of digits allowed. Must be greater than zero whiteSpace Specifies how white space (line feeds, tabs, spaces, and carriage returns) are handled

  20. XMLSchema Indikátorok • Sorrendi: • All • Choice • Sequence <xs:all>...</xs:all> • Előfordulási • maxOccurs • minOccurs <xs:element name="child_name" type="xs:string" minOccurs="0" maxOccurs="5"/>

  21. XMLSchema Indikátorok • Csoport • Group name • attributeGroup name

  22. XMLSchema • Példa 2BookStore.xml 2BookStore.xsd HF: Definiáljunk egy „x” nevű névteret és korlátozzuk az egyik Date tag-et erre a névtérre, majd nézzük meg egy validáló programmal az eredményt.

  23. XMLSchema • HF Feladat A kliens_form.xml-hez definiáljunk a kliens_form.xsd sémát.

  24. Hasznos linkek • http://java.sun.com/xml • http://www.apache.org • http://www.w3school.com

More Related