Добавил:
Кафедра ВТ Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Краденные лабы / 8308ДовженкоАЕ_лр1

.pdf
Скачиваний:
2
Добавлен:
08.04.2023
Размер:
549.24 Кб
Скачать

ПРИЛОЖЕНИЕ А

input.xml

<?xml version="1.0" encoding="WINDOWS-1251"?> <?xml-stylesheet type='text/xsl' href='transformer.xsl'?> <main>

<!--1--> <library>

<book>Название книги</book> <color>red</color>

</library>

<!--2--> <root2>

<XXX id="x1"> <BBB id="b1"/> <BBB id="b2"/>

</XXX>

<AAA id="a2"> <BBB id="b3"/> <BBB id="b4"/> <CCC id="c1">

<DDD id="d1"/> </CCC>

<BBB id="b5"> <CCC id="c2"/>

</BBB> </AAA>

</root2>

<!--3--> <employees>

<employee id="js0034"> Joe Smith</employee> <employee id="ma0012"> Marry Ann</employee>

</employees>

<!--4--> <root4>

<AAA id="a1"> <BBB id="b1"/> <BBB id="b2"/>

</AAA>

<AAA id="a2"> <BBB id="b3"/> <BBB id="b4"/> <CCC id="c1">

<DDD id="d1"/> </CCC>

<BBB id="b5"> <CCC id="c2"/>

</BBB> </AAA>

</root4>

<!--5--> <root5>

<AAA id="a1"> <BBB id="b1"/>

11

<BBB id="b2"/> </AAA>

<AAA id="a2"> <BBB id="b3"/> <BBB id="b4"/> <CCC id="c1">

<DDD id="d1"/> </CCC>

<BBB id="b5"> <CCC id="c2"/>

</BBB> </AAA>

</root5>

<!--6--> <root6>

<color>blue</color> <color>navy</color> <color>yellow</color> <color>green</color> <color>lime</color> <color>red</color>

</root6>

<!--7--> <list>

<entry name="A"/> <entry name="B"/> <entry name="C"/> <entry name="D"/>

</list>

</main>

12

ПРИЛОЖЕНИЕ Б

output.html

<html> <head>

<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="UTF-8">

</head> <body> <h1>

<b> Лабораторная работа 1 </b> </h1>

<br> <hr>

<h2>Задание 1</h2>

<font color="red">Название книги</font> <br>

<hr>

<h2>Задание 2</h2> <p>XXX id=x1</p> <p>AAA id=a2</p> <br>

<hr>

<h2>Задание 3</h2> <b><i>js0034</i></b>

Joe Smith<br> <b><i>ma0012</i></b>

Marry Ann<br>

<br> <hr>

<h2>Задание 4</h2>

<table border="1" cellpadding="6"> <tr>

<th colspan="2">Axis: child</th> </tr>

<tr> <th>Element</th><th>Node-set</th> </tr>

<tr>

<td>AAA id = a1</td><td></td> </tr>

<tr>

<td>BBB id = b1</td><td>a1</td> </tr>

<tr>

<td>BBB id = b2</td><td>a1</td> </tr>

<tr>

<td>AAA id = a2</td><td></td> </tr>

<tr>

<td>BBB id = b3</td><td>a2</td> </tr>

<tr>

<td>BBB id = b4</td><td>a2</td> </tr>

<tr>

<td>CCC id = c1</td><td>a2</td> </tr>

<tr>

13

<td>DDD id = d1</td><td>c1</td> </tr>

<tr>

<td>BBB id = b5</td><td>a2</td> </tr>

<tr>

<td>CCC id = c2</td><td>b5</td> </tr>

</table> <br> <hr>

<h2>Задание 5</h2>

<font color="red">BBB id=b1<br> </font><font color="red">BBB id=b2<br> </font><font color="red">BBB id=b3<br> </font><font color="red">BBB id=b4<br> </font><font color="red">BBB id=b5<br> </font><font color="blue">CCC id=c1<br> </font><font color="blue">CCC id=c2<br> </font><font color="green">DDD id=d1<br> </font>

<br> <hr>

<h2>Задание 6</h2> <TABLE>

<TR>

<TD style="color:blue">blue</TD> </TR>

</TABLE>

<TABLE> <TR>

<TD style="color:navy">navy</TD> </TR>

</TABLE>

<TABLE> <TR>

<TD style="color:yellow">yellow</TD> </TR>

</TABLE>

<TABLE> <TR>

<TD style="color:green">green</TD> </TR>

</TABLE>

<TABLE> <TR>

<TD style="color:lime">lime</TD> </TR>

</TABLE>

<TABLE> <TR>

<TD style="color:red">red</TD> </TR>

</TABLE> <br> <hr>

<h2>Задание 7</h2> <p>A, B, C, D.</p> </body>

</html>

14

ПРИЛОЖЕНИЕ В

transformer.xsl

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match="/">

<html> <head>

<meta charset="UTF-8"></meta> </head>

<body>

<h1><b> Лабораторная работа 1 </b></h1>

<br/><hr/>

<h2>Задание 1</h2> <font>

<xsl:attribute name="color"> <xsl:value-of select="//library/color"/>

</xsl:attribute>

<xsl:value-of select="//library/book"/>

</font>

<br/><hr/>

<h2>Задание 2</h2>

<xsl:for-each select="//root2/*">

<p><xsl:value-of select="name()"/> id=<xsl:value-of select="./@id"/></p>

</xsl:for-each>

<br/><hr/>

<h2>Задание 3</h2>

<xsl:for-each select="//employees/*"> <b><i><xsl:value-of select="./@id"/> </i></b> <xsl:value-of select="."/><br/>

</xsl:for-each>

<br/><hr/>

<h2>Задание 4</h2>

<table border="1" cellpadding="6"> <tr><th colspan="2">Axis: child</th></tr>

<tr><th>Element</th><th>Node-set</th></tr>

<xsl:for-each select="//root4//*">

<tr>

<td><xsl:value-of select="name()"/> id = <xsl:value-of select="./@id"/></td> <td><xsl:value-of select="../@id"/></td>

</tr>

</xsl:for-each>

</table> <br/><hr/>

<h2>Задание 5</h2>

<xsl:for-each select="//root5//BBB">

<font color="red">

<xsl:value-of select="name()"/> id=<xsl:value-of select="./@id"/><br/> </font>

</xsl:for-each>

15

<xsl:for-each select="//root5//CCC">

<font color="blue">

<xsl:value-of select="name()"/> id=<xsl:value-of select="./@id"/><br/> </font>

</xsl:for-each>

<xsl:for-each select="//root5//DDD">

<font color="green">

<xsl:value-of select="name()"/> id=<xsl:value-of select="./@id"/><br/> </font>

</xsl:for-each>

<br/><hr/>

<h2>Задание 6</h2>

<xsl:for-each select="//root6/color">

<TABLE>

<TR> <TD>

<xsl:attribute name="style">color:<xsl:value-of select="."/></xsl:attribute> <xsl:value-of select="."/>

</TD> </TR>

</TABLE>

</xsl:for-each>

<br/><hr/>

<h2>Задание 7</h2> <p>

<xsl:for-each select="//entry"> <xsl:value-of select="./@name"/>

<xsl:if test="last() != position()">, </xsl:if> <xsl:if test="last() = position()">.</xsl:if>

</xsl:for-each>

</p>

</body> </html>

</xsl:template> </xsl:stylesheet>

16