Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 KB | None | 0 0
  1. //plik XML-Schema zawierający deklarację elementów takich, że element główny o nazwie pracownik będzie zawierał
  2. elementy: imie, nazwisko, wiek, data_urodzenia, pensja w podanej kolejności.
  3.  
  4.  
  5. <xsd:element name="pracownik">
  6.  
  7. <xsd:complexType>
  8.  
  9. <xsd:sequence>
  10.  
  11. <xsd:element name="imie" type= "xsd:string"/>
  12.  
  13. <xsd:element name="nazwisko" type= "xsd:string"/>
  14.  
  15. <xsd:element name="wiek" type= "xsd:integer"/>
  16.  
  17. <xsd:element name="data_urodzenia" type="xsd:date"/>
  18.  
  19. <xsd:element name="pensja" type="xsd:integer"/>
  20.  
  21. </xsd:sequence>
  22.  
  23. </xsd:complexType>
  24.  
  25. </xsd:element>
  26.  
  27. ///plik XML-Schema zawierający deklarację elementów takich, że element główny o nazwie zamowienie będzie zawierał elementy:
  28. cena - występuje dokładnie raz.
  29. adres - może raz, ale nie musi wystąpić.
  30. kontakt - może wystąpić wiele razy, ale nie musi.
  31. towar - występuje conajmniej raz i możę wystąpić maksymalnie 12 razy.
  32.  
  33.  
  34. xsd:element name="zamowienie">
  35.  
  36. <xsd:complexType>
  37.  
  38. <xsd:sequence>
  39.  
  40. <xsd:element name="cena" type= "xsd:float" maxOccurs="1"/>
  41.  
  42. <xsd:element name="adres" type="xsd:string" maxOccurs="1"/>
  43.  
  44. <xsd:element name="kontakt" type="xsd:string" maxOccurs="unbounded"/>
  45.  
  46. <xsd:element name="towar" type="xsd:string" minOccurs="1" maxOccurs="12" />
  47.  
  48. </xsd:sequence>
  49.  
  50. </xsd:complexType>
  51.  
  52. </xsd:element>
  53. ////plik XML-Schema zawierający deklarację elementów takich, że element główny o nazwie szkola, będzie zawierał 3 elementy o nazwie nauczyciel lub element o nazwie dyrektor i 2 elementy o nazwie wicedyrektor.
  54.  
  55. <xsd:complexType>
  56.  
  57. <xsd:sequence>
  58.  
  59. <xsd:choice>
  60.  
  61. <xsd:element name="nauczyciel" type= "xsd:string" minOccurs="3" maxOccurs="3"/>
  62.  
  63. <xsd:element name="dyrektor" type= "xsd:string"/>
  64.  
  65. </xsd:choice>
  66.  
  67. <xsd:element name="wicedyrektor" type="xsd:string" minOccurs="2" maxOccurs="2"/>
  68.  
  69. </xsd:sequence>
  70.  
  71. </xsd:complexType>
  72.  
  73. //XML-Schema zawierający deklarację elementów takich, że element główny o nazwie kolor, będzie zawierał elementy o nazwie czerwony, zielony, niebieski kolejności, które będą zawierać liczbę naturalną z przedziału: 0 - 255.
  74.  
  75. <xsd:element name="kolor">
  76.  
  77. <xsd:complexType>
  78.  
  79. <xsd:sequence>
  80.  
  81. <xsd:element name="czerwony" type="typ_kolor"/>
  82.  
  83. <xsd:element name="zielony" type="typ_kolor"/>
  84.  
  85. <xsd:element name="niebieski" type="typ_kolor"/>
  86.  
  87. </xsd:sequence>
  88.  
  89. </xsd:complexType>
  90.  
  91. </xsd:element>
  92.  
  93. <xsd:simpleType name="typ_kolor">
  94.  
  95. <xsd:restriction base="xsd:integer">
  96.  
  97. <xsd:maxInclusive value="256" />
  98.  
  99. <xsd:minInclusive value="0" />
  100.  
  101. </xsd:restriction>
  102. </xsd:simpleType>
  103.  
  104. ///Stwórz plik XML-Schema zawierający deklarację elementów takich, że element główny o nazwie osoba, który będzie zawierał:
  105. element imie o długości minimalnej 3 i maksymalnej 20.
  106. element nazwisko o długości minimalnej 3 i maksymalnej 30.
  107. element numer o długości równej 6.
  108. atrybut plec, który może przyjąc wartość "kobieta" lub "mężczyzna"
  109.  
  110. <xsd:element name="osoba" type="typ_osoba" />
  111.  
  112. <xsd:complexType name="typ_osoba">
  113.  
  114. <xsd:sequence>
  115.  
  116. <xsd:element name="imie" type="typ_imie"/>
  117.  
  118. <xsd:element name="nazwisko" type="typ_nazwisko" />
  119.  
  120. <xsd:element name="numer" type="typ_numer" />
  121.  
  122. <xsd:element name="plec" type="typ_plec"/>
  123.  
  124. </xsd:sequence>
  125. </xsd:complexType>
  126.  
  127.  
  128.  
  129. <xsd:simpleType name="typ_imie">
  130.  
  131. <xsd:restriction base="xsd:string">
  132.  
  133. <xsd:minLength value="3" />
  134.  
  135. <xsd:maxLength value="20" />
  136.  
  137. </xsd:restriction>
  138.  
  139. </xsd:simpleType>
  140.  
  141.  
  142.  
  143. <xsd:simpleType name="typ_nazwisko">
  144.  
  145. <xsd:restriction base="xsd:string">
  146.  
  147. <xsd:minLength value="3" />
  148.  
  149. <xsd:maxLength value="30" />
  150.  
  151. </xsd:restriction>
  152.  
  153. </xsd:simpleType>
  154.  
  155.  
  156.  
  157.  
  158. <xsd:simpleType name="typ_numer">
  159.  
  160. <xsd:restriction base="xsd:string">
  161.  
  162. <xsd:length value="6" />
  163.  
  164. </xsd:restriction>
  165.  
  166. </xsd:simpleType>
  167.  
  168.  
  169.  
  170. <xsd:simpleType name="typ_plec">
  171.  
  172. <xsd:restriction base="xsd:string">
  173.  
  174. <xsd:pattern value="mezczyzna|kobieta" />
  175.  
  176. </xsd:restriction>
  177.  
  178. </xsd:simpleType>
  179.  
  180. //////XML-Schema zawierający deklarację elementu głównego o nazwie cena, który będzie zawierał cenę
  181. Część całkowita i dziesiętna musi być odzielona kropką (.). Cena musi być liczbą dodatnią lub równa zero,
  182. która zawiera 2 miejsca po przecinku.
  183.  
  184.  
  185. <xsd:element name="cena" type="typ_cena" />
  186.  
  187. <xsd:complexType name="typ_cena">
  188.  
  189. <xsd:sequence>
  190.  
  191. <xsd:element name="cena2" type="typ_cena2" />
  192.  
  193. </xsd:sequence>
  194. </xsd:complexType>
  195.  
  196. <xsd:simpleType name="typ_cena2">
  197.  
  198. <xsd:restriction base="xsd:string">
  199.  
  200. <xsd:pattern value="[0-9]{2}\.[0-9]{2}" />
  201.  
  202. </xsd:restriction>
  203.  
  204. </xsd:simpleType>
  205.  
  206. </xsd:schema>
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214. ///Stwórz plik XML-Schema zawierający deklarację elementu głównego o nazwie telefon,
  215. który będzie zawierał definicję numeru telefonu w trzech formatach: 000-000-000, +48 000 000 000, (58) 000 00 00.
  216.  
  217. <xsd:element name="numer_telefonu" type="typ_numer_telefonu" />
  218.  
  219. <xsd:complexType name="typ_numer_telefonu">
  220.  
  221. <xsd:sequence>
  222.  
  223. <xsd:element name="numer" type="typ_numer"/>
  224.  
  225. </xsd:sequence>
  226. </xsd:complexType>
  227.  
  228. <xsd:simpleType name="typ_numer">
  229.  
  230. <xsd:restriction base="xsd:string">
  231.  
  232. <xsd:whiteSpace value="replace"/>
  233.  
  234. <xsd:pattern value="[0-9]{3}\-[0-9]{3}\-[0-9]{3}|\+[0-9]{2} [0-9]{3} [0-9]{3} [0-9]{3}|\([0-9]{2}\) [0-9]{3} [0-9]{2} [0-9]{2}" />
  235.  
  236. </xsd:restriction>
  237.  
  238. </xsd:simpleType>
  239.  
  240. ////dane na temat pracowników i uczniów w szkole. Plik powinien zawierać 3 elementy: nauczyciele, uczniowe, pozostali,
  241. które będą zwierać odpowiednie dane na temat osób (elementy osoba przechowujące dane osobowe). Utwórz oraz wykorzystaj globalny element osoba oraz aaaatrybut plec.
  242.  
  243. <xsd:element name="ludzie">
  244.  
  245. <xsd:complexType>
  246.  
  247. <xsd:sequence>
  248.  
  249. <xsd:element name="uczniowie" type="typ_uczniowie"/>
  250.  
  251. <xsd:element name="nauczyciele" type="typ_nauczyciele"/>
  252.  
  253. <xsd:element name="pozostali" type="typ_pozostali"/>
  254.  
  255. </xsd:sequence>
  256. </xsd:complexType>
  257.  
  258. </xsd:element>
  259.  
  260. <xsd:complexType name="typ_uczniowie">
  261.  
  262. <xsd:sequence>
  263.  
  264. <xsd:element ref="osoba" />
  265.  
  266. </xsd:sequence>
  267.  
  268. </xsd:complexType>
  269.  
  270.  
  271. <xsd:complexType name="typ_nauczyciele">
  272.  
  273. <xsd:sequence>
  274.  
  275. <xsd:element ref="osoba" />
  276.  
  277. </xsd:sequence>
  278.  
  279. </xsd:complexType>
  280.  
  281. <xsd:complexType name="typ_pozostali">
  282.  
  283. <xsd:sequence>
  284.  
  285. <xsd:element ref="osoba" />
  286.  
  287. </xsd:sequence>
  288. </xsd:complexType>
  289.  
  290.  
  291. <xsd:element name="osoba" type="typ_osoba"/>
  292.  
  293.  
  294. <xsd:complexType name="typ_osoba">
  295.  
  296. <xsd:sequence>
  297.  
  298. <xsd:element name="imie"/>
  299.  
  300. <xsd:element name="nazwisko"/>
  301.  
  302. </xsd:sequence>
  303.  
  304. <xsd:attribute name="plec" />
  305.  
  306. </xsd:complexType>
  307.  
  308.  
  309. Język ścieżek XML
  310. //wypisze dane osób, które są kobietami. - /lista/osoba[@plec='k']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement