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

Work1 #43

Open
wants to merge 14 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
10 changes: 10 additions & 0 deletions books.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!ELEMENT bookstore (book*)>
<!ELEMENT book (title,author+,year,price)>
<!ATTLIST book category CDATA #REQUIRED
cover (hardback|paperback) #IMPLIED
>
<!ELEMENT title (#PCDATA)>
<!ATTLIST title lang CDATA "en">
<!ELEMENT author (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT price (#PCDATA)>
12 changes: 12 additions & 0 deletions books.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<!DOCTYPE bookstore [
<!ELEMENT bookstore (book*)>
<!ELEMENT book (title,author+,year,price)>
<!ATTLIST book category CDATA #REQUIRED
cover (hardback|paperback) #IMPLIED
>
<!ELEMENT title (#PCDATA)>
<!ATTLIST title lang CDATA "en">
<!ELEMENT author (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT price (#PCDATA)>
]
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
Expand Down
86 changes: 86 additions & 0 deletions books.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

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

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

<xs:complexType name="bookType">

<xs:sequence>

<xs:element name="title">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="titleType">
<xs:minLength value="2"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:element name="author" minOccurs="1" 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" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="hardback"/>
<xs:enumeration value="paperback"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>

</xs:complexType>

<!-- type for title to define attribute-->
<xs:complexType name="titleType">
<xs:simpleContent>
<xs:extension base="xs:string">
<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: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" encoding="UTF-8"?>
<!DOCTYPE student SYSTEM "student.dtd">
<student fullname="Turilov Maxim Alekseevich" group="К5-362"/>
1 change: 1 addition & 0 deletions task16
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book
1 change: 1 addition & 0 deletions task17
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book[@cover]
1 change: 1 addition & 0 deletions task18
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book[child::year=2003]
1 change: 1 addition & 0 deletions task19
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//book[child::price >= 30 and child::price < 40]
15 changes: 15 additions & 0 deletions task20
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//book">
<xsl:value-of select="title"/> <xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
15 changes: 15 additions & 0 deletions task20.xls
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//book">
<xsl:value-of select="title"/> <xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
16 changes: 16 additions & 0 deletions task21.xls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//book">
<xsl:sort select="price"/>
<xsl:value-of select="title"/> <xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
20 changes: 20 additions & 0 deletions task22.xls
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//book">
<xsl:value-of select="title"/>
<xsl:if test="count(author) &gt; 1">
<xsl:text>*</xsl:text>
</xsl:if>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

31 changes: 31 additions & 0 deletions task23.xls
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//book">
<xsl:value-of select="title"/>
<xsl:choose>
<xsl:when test="price &gt; 30">
<xsl:text>&gt;30</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="price &lt; 30">
<xsl:text>&lt;30</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>=30</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
27 changes: 27 additions & 0 deletions task24.xls
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<html>
<body>
<xsl:text>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#xa;&lt;library&gt;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&lt;/library&gt;</xsl:text>
</body>
</html>
</xsl:template>

<xsl:template match="book">
<xsl:text>&lt;book title="</xsl:text><xsl:value-of select="title"/><xsl:text>" year="</xsl:text><xsl:value-of select="year"/><xsl:text>"&gt;</xsl:text>
<xsl:apply-templates select="author"/>
<xsl:text>&lt;/book&gt;</xsl:text>
</xsl:template>

<xsl:template match="author">
<xsl:text>&lt;author name="</xsl:text><xsl:value-of select="."/><xsl:text>"&gt;</xsl:text>
<xsl:text>&lt;/author&gt;</xsl:text>
</xsl:template>

</xsl:stylesheet>