Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21.10.2014 #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions books.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!ELEMENT bookstore (book*)>
<!ELEMENT bookstore (title)>
<!ELEMENT bookstore (year)>
<!ELEMENT bookstore (price)>
<!ELEMENT bookstore (author+)>
<!ATTLIST title lang CDATA #REQUIRED>
<!ATTLIST book category CDATA #REQUIRED>
<!ATTLIST book cover CDATA #IMPLIED>
<!ATTLIST book cover (hardback|paperback) "hardback">
<!ATTLIST title lang CDATA "en">


11 changes: 11 additions & 0 deletions books.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<!DOCTYPE bookstore [
<!ELEMENT bookstore (book*)>
<!ELEMENT book (title)>
<!ELEMENT book (author+)>
<!ELEMENT book (year)>
<!ELEMENT book (price)>

<!ATTLIST book category CDATA #REQUIRED>
<!ATTLIST book cover (paperback | hardback) #IMPLIED>
<!ATTLIST title lang CDATA "en">
]>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
Expand Down
64 changes: 64 additions & 0 deletions books.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:simpleType name="auth">
<xs:restriction base="xs:string">
<xs:minLength value="2"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="cov">
<xs:restriction base="xs:string">
<xs:enumeration value="hardback"/>
<xs:enumeration value="paperback"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="langu">
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="price">
<xs:restriction base="xs:float">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="year">
<xs:restriction base="xs:short">
<xs:minInclusive value="1900"/>
<xs:maxInclusive value="2014"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="bok">
<xs:sequence>
<xs:element name="title">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="lang" name="lang" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element type="auth" name="author" maxOccurs="unbounded" minOccurs="0"/>
<xs:element type="year" name="year"/>
<xs:element type="price" name="price"/>
</xs:sequence>
<xs:attribute type="xs:string" name="category" use="required"/>
<xs:attribute type="cov" name="cover" use="optional"/>
</xs:complexType>

<xs:complexType name="store">
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded" minOccurs="0" type="bok" />
</xs:sequence>
</xs:complexType>

<xs:element name="bookstore" type="store" />

</xs:schema>
71 changes: 71 additions & 0 deletions example.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:complexType name="BookStoreType">
<xs:sequence>
<xs:element name="book" type="BookType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:simpleType name="TitleType">
<xs:restriction base="xs:string">
<xs:minLength value="2"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="BookType">
<xs:sequence>
<xs:element name="title">
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="TitleType">
<xs:attribute name="lang" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="author" maxOccurs="unbounded">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="2"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="year">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1900"/>
<xs:maxInclusive value="2014"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="price">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="category" type="xs:string" use="required"/>
<xs:attribute name="cover">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="hardback"/>
<xs:enumeration value="paperback"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>

<xs:element name="bookstore" type="BookStoreType"/>

</xs:schema>
3 changes: 3 additions & 0 deletions student.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0"?>
<!DOCTYPE student SYSTEM "student.dtd">
<student> Skok Daria </student>
1 change: 1 addition & 0 deletions task16.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book
1 change: 1 addition & 0 deletions task17.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book[@cover]
1 change: 1 addition & 0 deletions task18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book[@year=2003]
1 change: 1 addition & 0 deletions task19.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book[@price>=30 and @price<40]
10 changes: 10 additions & 0 deletions task20.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="//book">
<xsl:value-of select="title"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>