XML XSLT 1
XML XSLT 2
XML XSLT 3
XML XSLT 4
XML XSLT 5
<?xml version="1.0" encoding="iso-2022-jp"?> <listofnames category=" "> <lastupdate>2004.7.7</lastupdate> <member id="01"> <name> </name> <age>27</age> <address> </address> <misc> </misc> </member> <member id="02"> <name> </name> <age>37</age> <address> </address> <misc> </misc> </member> </listofnames> XML XSLT 6
<?xml version="1.0" encoding="iso-2022-jp"?> XML XSLT 7
< > </ > < = > </ > XML XSLT 8
XML XSLT 9 < > < > < > </ > < > </ > </ > < > < > </ > < > </ > </ > </ >
<h1><font color= red > </h1></font> <h1><font color= red > </font></h1> XML XSLT 10
<dt> <dd> <dt> </dt> <dd> </dd> <img src= picido.jpg ></img> <img src= picido.jpg /> XML XSLT 11
<img src=picido.jpg /> <img src= picido.jpg /> <h1> </H1> <h1> </h1> XML XSLT 12
<!-- --> <!-- --> XML XSLT 13
XML XSLT 14
<html> <head><title> </title></head> <body> <p>2004.7.7</p> <dt> <dd> <dd>27</dd> <dd> </dd> <dd> </dd> </dt> : </body> </html> XML XSLT 15
XML XSLT 16
XML XSLT 17
: : <member id="01"> <member id= 01 <name> </name> firstname= <age>27</age> lastname= > <address> </address> <age>27</age> <misc> </misc> <address> </address> </member> <misc> </misc> : </member> : XML XSLT 18
<!ELEMENT listofnames (lastupdate,member*)> <!ELEMENT lastupdate (#PCDATA)> <!ELEMENT member (name,age,address,misc)> <!ELEMENT name (#PCDATA)> <!ELEMENT age (#PCDATA)> <!ELEMENT address (#PCDATA)> <!ELEMENT misc (#PCDATA)> <!ATTLIST listofnames category CDATA #REQUIRED> <!ATTLIST member id CDATA #REQUIRED> : <member id="01"> <name> </name> <age>27</age> <address> </address> <misc> </misc> </member> : : <member id= 01 firstname= lastname= > <age>27</age> <address> </address> <misc> </misc> </member> : XML XSLT 19
XML XSLT 20
XML XSLT 21
XML XSLT 22
xmlwork ch2 books.xml books.xsl ch3 XML XSLT 23
xmlwork ch2 books.xml books.xsl XML XSLT 24
<?xml version="1.0" encoding="iso-2022-jp"?> <?xml-stylesheet type="text/xsl" href="books.xsl"?> <books category=" "> <owner> </owner> <book isbn="isbn4-7981-0439-6"> <title>10 Jakarta </title> <author> </author> <price>2800</price> </book> <book isbn="isbn4-7973-1318-8"> <title> Linux/UNIX </title> <author> </author> <price>4100</price> </book> <book isbn="isbn4-7973-1857-0"> <title> Java </title> <author> </author> <price>2400</price> </book> </books> XML XSLT 25
XML XSLT 26
1:<?xml version="1.0" encoding="iso-2022-jp"?> 2:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl /Transform version="1.0"> 3: <xsl:output method="html" encoding="iso-2022-jp" /> 4: <xsl:template match="/"> 5: <html> 6: <head> 7: <title><xsl:value-of select="books/@category" /></title> 8: </head> 9: <body> 10: <h1><xsl:value-of select="books/@category" /></h1> 11: <p>(<xsl:value-of select="books/owner" />)</p> 12: <table border="1"> 13: <tr><th><xsl:text>isbn </xsl:text></th> 14: <th><xsl:text> </xsl:text></th> 15: <th><xsl:text> </xsl:text></th> 16: <th><xsl:text> </xsl:text></th></tr> 17: </table> 18: </body> 19: </html> 20: </xsl:template> 21:</xsl:stylesheet> XML XSLT 27
% nkf -j books.xml>temp % mv temp books.xml XML XSLT 28
: 10: <book isbn="isbn4-7981-0439-6"> 11: <title>10 Jakarta <title> 12: <author> </author> 13: <price>2800</price> 14: </book> : </title> </title> XML XSLT 29
1:<?xml version="1.0" encoding="iso-2022-jp"?> 2:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999 /XSL/Transform version="1.0"> : 21:</xsl:stylesheet> 3: <xsl:output method="html" encoding="iso-2022-jp" /> XML XSLT 30
<xsl:template match= > : </xsl:template> <xsl:template match= > : </xsl:template> <xsl:template match= xxx"> </xsl:template> XML XSLT 31
/ match= / / / 4: <xsl:template match="/"> / 20: </xsl:template> <xsl:template match= / > XML XSLT 32
<xsl:text> 13: <tr><th><xsl:text>isbn </xsl:text></th> 14: <th><xsl:text> </xsl:text></th> 15: <th><xsl:text> </xsl:text></th> 16: <th><xsl:text> </xsl:text></th></tr> 13: <tr>isbn </th> XML XSLT 33
<xsl:value-of> <books category=" "> <owner> </owner> </books> 11: <p>(<xsl:value-of select="books/owner" />)</p> XML XSLT 34
<xsl:value-of> 11: <p>(<xsl:value-of select="books/owner" />)</p> <xsl:value-of> XML XSLT 35
<books category=" "> 10: <h1><xsl:value-of select="books/@category" /></h1> book category XML XSLT 36
<?xml version="1.0" encoding="iso-2022-jp"?> <?xml-stylesheet type="text/xsl" href="books.xsl"?> XML XSLT 37
xmlwork ch3 books.xml books.dtd emacs SGML XML XSLT 38
XML XSLT 39
1: <!ELEMENT books (owner,book*)> 2: <!ELEMENT book (title,author,price)> 3: <!ELEMENT owner (#PCDATA)> 4: <!ELEMENT title (#PCDATA)> 5: <!ELEMENT author (#PCDATA)> 6: <!ELEMENT price (#PCDATA)> 7: <!ATTLIST books category CDATA #IMPLIED> 8: <!ATTLIST book isbn CDATA #REQUIRED> <?xml version="1.0" encoding="iso-2022-jp"?> <!DOCTYPE books SYSTEM "books.dtd"> <?xml-stylesheet type="text/xsl... : XML XSLT 40
Parsing prolog...done XML XSLT 41
XML XSLT 42
XML XSLT 43
books category 1:<!ELEMENT books (owner,book*)> 2: <!ELEMENT book (title,author,price)> book title, author, price 6: <!ELEMENT price (#PCDATA)> 5: <!ELEMENT author (#PCDATA)> 4: <!ELEMENT title (#PCDATA)> 3: <!ELEMENT owner (#PCDATA)> 7: <!ATTLIST books category CDATA #IMPLIED> 8: <!ATTLIST book isbn CDATA #REQUIRED> onwer XML XSLT 44
1:<!ELEMENT books (owner,book*)> <!ELEMENT aaa (bbb ccc)> XML XSLT 45
3: <!ELEMENT owner (#PCDATA)> <!ELEMENT aaa (bbb,#pcdata)> <!ELEMENT aaa (bbb #PCDATA)*> <aaa> <bbb></bbb><bbb></bbb> </aaa> XML XSLT 46
XML XSLT 47
8: <!ATTLIST book isbn CDATA #REQUIRED> XML XSLT 48
XML XSLT 49
XML XSLT 50
XML XSLT 51
xmlwork ch4 books.xml books.xsl xsl XML XSLT 52
:( (2.1) ) <th><xsl:text> </xsl:text></th></tr> 19: <xsl:apply-templates select="books" /> </table> </body> </html> </xsl:template> 24:<xsl:template match="books"> 25: <xsl:for-each select="book"> 26: <xsl:sort select="price" data-type="text" order="ascending" /> 27: <tr><td><xsl:value-of select="@isbn" /></td> 28: <td><xsl:value-of select="title" /></td> 29: <td><xsl:value-of select="author" /></td> 30: <td><xsl:value-of select="price" /></td></tr> 31: </xsl:for-each> 32:</xsl:template> </xsl:stylesheet> XML XSLT 53
<html> <head> <META http-equiv="content-type" content="text/html; charset=iso-2022-jp"> <title> </title> </head> <body> <h1> </h1> <p> </p> <table border="1"> <tr><th>isbn </th><th> </th><th> </th><th> </th></tr> <tr><td>isbn4-7973-1857-0</td><td> Java </td> <td> </td><td><font color="red">2400</font></td></tr> <tr><td>isbn4-7981-0439-6</td><td>10 Jakarta </td> <td> </td><td><font color="red">2800</font></td></tr> <tr><td>isbn4-7973-1318-8</td><td> Linux/UNIX </td> <td> </td><td>4100</td></tr> </table> </body> </html> XML XSLT 54
4:<xsl:template match= / > : 19:<xsl:apply-templates select="books" /> 23:</xsl:template> 24:<xsl:template match= books > : 32:</xsl:template> XML XSLT 55
<xsl:applytemplates /> <html> <head> <META http-equiv="content-ty charset=iso-2022-jp"> <title> </title> </head> <body> <h1> </h1> <p> </p> <table border="1"> <tr><th>isbn </th><th> <tr><td>isbn4-7973-1857-0</t <td> </td><td><fo <tr><td>isbn4-7981-0439-6</t <td> </td><td><fon <tr><td>isbn4-7973-1318-8</ <td> </td><td>41 </table> </body> </html> 2 XML XSLT 56
<xsl:for-each> 24:<xsl:template match="books"> 25: <xsl:for-each select="book"> 31: </xsl:for-each> 32:</xsl:template> <xsl:for-each...> book <tr><td>isbn4-7973-1857-0</t <td> </td><td><fo <tr><td>isbn4-7981-0439-6</t <td> </td><td><fon </xsl:for-each> <tr><td>isbn4-7973-1318-8</ <td> </td><td>41 XML XSLT 57
<xsl:sort> price 26: <xsl:sort select="price" data-type="text" order="ascending" /> number <xsl:for-each...> <xsl:sort> price </xsl:for-each> <tr><td>isbn4-7973-1857-0</t <td> </td><td><fo <tr><td>isbn4-7981-0439-6</t <td> </td><td><fon <tr><td>isbn4-7973-1318-8</ <td> </td><td>41 XML XSLT 58
25: <xsl:for-each select="book"> 27: <tr><td><xsl:value-of select="@isbn" /></td> 28: <td><xsl:value-of select="title" /></td> : 31: </xsl:for-each> @isbn title XML XSLT 59
books book/title books title XML XSLT 60
XML XSLT 61
xmlwork ch5 books.xml books.xsl XML XSLT 62
<?xml version="1.0" encoding="iso-2022-jp"?> <!DOCTYPE books SYSTEM "books.dtd"> <?xml-stylesheet type="text/xsl" href="books.xsl"?> <books category=" "> <owner> </owner> <book isbn="isbn4-7981-0439-6"> <price>2800</price> <url>http://www.amazon.co.jp/exec/obidos/asin/xxx</url> </book> <book isbn="isbn4-7973-1318-8"> <price>4100</price> <url>http://www.amazon.co.jp/exec/obidos/asin/xxx</url> </book> <book isbn="isbn4-7973-1857-0"> <price>2400</price> <url>http://www.amazon.co.jp/exec/obidos/asin/xxx</url> </book> </books> XML XSLT 63
<?xml version="1.0" encoding="iso-2022-jp"?> :( ) <table border="1"> <tr> <th><xsl:text>isbn </xsl:text></th> <th><xsl:text> </xsl:text></th> <th><xsl:text> </xsl:text></th> <th><xsl:text> </xsl:text></th> </tr> <xsl:apply-templates select="books" /> 20: <tr><td colspan="2" /><th> </th> 21: <td><xsl:value-of select="sum(books//price) div count(books//price)" /></td></tr> </table> </body> </html> </xsl:template> XML XSLT 64
<xsl:template match="books"> <xsl:for-each select="book"> <xsl:sort select="price" data-type="text" order="ascending" /> <tr><td><xsl:value-of select="@isbn" /></td> 30: <td><xsl:element name="a"> 31: <xsl:attribute name="href"> 32: <xsl:value-of select="url" /> 33: </xsl:attribute> 34: <xsl:value-of select="title" /> 35: </xsl:element></td> 36: <td><xsl:value-of select="author" /></td> 37: <td><xsl:choose> 38: <xsl:when test="price[number(.) <=3000]"> 39: <font color="red"> <xsl:value-of select="price" /></font> 40: </xsl:when> 41: <xsl:otherwise> 42: <xsl:value-of select="price" /> 43: </xsl:otherwise> 44: </xsl:choose></td></tr> </xsl:for-each> </xsl:template> </xsl:stylesheet> XML XSLT 65
<a href= http://yyy > </a> <a href= <xsl:value-of select=... > > </a> XML XSLT 66
<xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select=..." /> </xsl:attribute> </xsl:element> <a href= <xsl:value-of...> > </a> XML XSLT 67
30: <td><xsl:element name="a"> 31: <xsl:attribute name="href"> 32: <xsl:value-of select="url" /> 33: </xsl:attribute> 34: <xsl:value-of select="title" /> 35: </xsl:element></td> <a href= http://www... > Java </a> XML XSLT 68
37: <td><xsl:choose> 38: <xsl:when test="price[number(.) <=3000]"> 39: <font color="red"> <xsl:value-of select="price" /></font> 40: </xsl:when> 41: <xsl:otherwise> 42: <xsl:value-of select="price" /> 43: </xsl:otherwise> 44: </xsl:choose></td></tr> 37:38: if("price[number(.) <=3000] ){ 39: <font color="red"> <xsl:value-of select="price" /></font> 40: } 41: else{ 42: <xsl:value-of select="price" /> 43:44: </xsl:otherwise> 44: } XML XSLT 69
<xsl:choose> <xsl:when test= "> </xsl:when> <xsl:when test= "> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose></td></tr> XML XSLT 70
38: <xsl:when test="price[number(.) <=3000]"> XML XSLT 71
=!= < > <= >= + - * div mod and or < < <= <= > > >= >= XML XSLT 72
*... // XML XSLT 73
XML XSLT 74
38: <xsl:when test="price[number(.) <=3000]"> price[. ] price[ number(.) <=3000 ] price[number(.) <=3000] XML XSLT 75
20: <tr><td colspan="2" /><th> </th> 21: <td><xsl:value-of select="sum(books//price) div count(books//price)" /></td></tr> books//price books//price count(books//price) div count(books//price) XML XSLT 76
XML XSLT 77
xmlwork ch6 books.xml comments.xsl XML XSLT 78
<?xml version="1.0" encoding="iso-2022-jp"?> <!DOCTYPE books SYSTEM "books.dtd"> <?xml-stylesheet type="text/xsl" href="comments.xsl"?> <books category=" "> <owner> </owner> <book isbn="isbn4-7981-0439-6"> : <cut>comp01.jpg</cut> <comment><keyword>struts</keyword> <ref addr="http://www.gifu-keizai.ac.jp/~ido"> </ref> </comment> </book> <book isbn="isbn4-7973-1318-8"> : <comment>windows <keyword>linux</keyword>!</comment> </book> <book isbn="isbn4-7973-1857-0"> : <cut>comp02.jpg</cut> <comment> <keyword>java</keyword> </comment> </book> </books> XML XSLT 79
1:<?xml version="1.0" encoding="iso-2022-jp"?> 2:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/ Transform" version="1.0"> 3: <xsl:output method="html" encoding="iso-2022-jp" /> 4: <xsl:template match="/"> 5: <html> 6: <head> 7: <title> </title> 8: </head> 9: <body> 10: <h1> </h1> 11: <xsl:apply-templates select="books" /> 12: </body> 13: </html> 14: </xsl:template> XML XSLT 80
15: <xsl:template match="books"> 16: <xsl:for-each select="book"> 17: <table border="0"> 18: <tr><td width="150"> 19: <xsl:element name="img"> 20: <xsl:attribute name="src"> 21: <xsl:value-of select="cut" /> 22: </xsl:attribute> 23: <xsl:attribute name="width">120</xsl:attribute> 24: <xsl:attribute name="height">150</xsl:attribute> 25: </xsl:element></td> 26: <td><dl><dt><xsl:number format="01" />. 27: <xsl:value-of select="title" /> 28: (<xsl:value-of select="author" />)</dt> 29: <dd><xsl:apply-templates select="comment" /> </dd></dl></td></tr> 30: </table> 31: <hr /> 32: </xsl:for-each> 33: </xsl:template> XML XSLT 81
34: <xsl:template match="keyword"> 35: <font color="red"><xsl:value-of select="." /></font> 36: </xsl:template> 37: <xsl:template match="text()"> 38: <xsl:value-of select="." /> 39: </xsl:template> 40:</xsl:stylesheet> XML XSLT 82
<img src= <xsl:value-of select= cut > width= 120 height= 150 /> 19: <xsl:element name="img"> 20: <xsl:attribute name="src"> 21: <xsl:value-of select="cut" /> 22: </xsl:attribute> 23: <xsl:attribute name="width">120</xsl:attribute> 24: <xsl:attribute name="height">150</xsl:attribute> 25: </xsl:element></td> XML XSLT 83
16: <xsl:for-each select="book"> : 26: <td><dl><dt><xsl:number format="01" />. : 32: </xsl:for-each> XML XSLT 84
: <xsl:apply-templates select="books" /> <xsl:template match= books > : </xsl:template> 29: <dd><xsl:apply-templates select="comment" /> 34: <xsl:template match="keyword"> : 36: </xsl:template> 37: <xsl:template match="text()"> : 39: </xsl:template> XML XSLT 85
XML XSLT 86
34: <xsl:template match="keyword"> 35: <font color="red"><xsl:value-of select="." /> </font> 36: </xsl:template> 37: <xsl:template match="text()"> 38: <xsl:value-of select="." /> 39: </xsl:template> <comment> <keyword>java</keyword> </comment> Java XML XSLT 87
xmlwork ch7 books.xml comments.xsl XML XSLT 88
<?xml version="1.0" encoding="iso-2022-jp"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/ Transform" version="1.0"> <xsl:output method="html" encoding="iso-2022-jp" /> <xsl:template match="/"> <html> <head> <title> </title> </head> <body> <h1> </h1> <xsl:apply-templates select="books" /> </body> </html> </xsl:template> XML XSLT 89
<xsl:template match="books"> <xsl:for-each select="book"> <table border="0"> <tr><td width="150"> <xsl:element name="img"> <xsl:attribute name="src"> <xsl:value-of select="cut" /> </xsl:attribute> <xsl:attribute name="width">120</xsl:attribute> <xsl:attribute name="height">150</xsl:attribute> </xsl:element></td> <td><dl><dt><xsl:number format="01" />. <xsl:value-of select="title" /> (<xsl:value-of select="author" />)</dt> <dd><xsl:apply-templates select="comment" /></dd> 30: <xsl:if test="price[number(.) >=3000]"> 31: <dd> ( 32: <xsl:value-of select="format-number(price,'#,###')" /> 33: ) </dd> 34: </xsl:if> </dl></td></tr> </table> <hr /> </xsl:for-each> </xsl:template> XML XSLT 90
<xsl:template match="keyword"> <font color="red"><xsl:value-of select="." /></font> </xsl:template> 43: <xsl:template match="ref"> 44: <xsl:element name="a"> 45: <xsl:attribute name="href"> 46: <xsl:value-of select="@addr" /> 47: </xsl:attribute> 48: <xsl:value-of select="." /> 49: </xsl:element> 50: </xsl:template> <xsl:template match="text()"> <xsl:value-of select="." /> </xsl:template> </xsl:stylesheet> XML XSLT 91
<xsl:if test= "> </xsl:if> 30: <xsl:if test="price[number(.) >=3000]"> 31: <dd> ( 32: <xsl:value-of select="format-number(price,'#,###')" /> 33: ) </dd> 34: </xsl:if> XML XSLT 92
32: <xsl:value-of select="format-number(price,'#,###')" /> 4,100 <xsl:value-of select="price" /> 4100 XML XSLT 93
43: <xsl:template match="ref"> 44: <xsl:element name="a"> 45: <xsl:attribute name="href"> 46: <xsl:value-of select="@addr" /> 47: </xsl:attribute> 48: <xsl:value-of select="." /> 49: </xsl:element> 50: </xsl:template> <comment>... <ref addr="http://www.gifukeizai.ac.jp/~ido"> </ref> </comment>... XML XSLT 94
XML XSLT 95