SlideShare a Scribd company logo
“หนึ่งหน่วยกลุ่ม” (Group 1)
Selected Topics in Computer Engineering II
XSLT, Xpath
Xqueries
Try to use
XSLT
XSLT = XSL Transformations
XSLT is a language for transforming XML documents into XHTML
documents or to other XML documents.
XSLT
<xsl:template>
XML File XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Movie.xsl"?>
<film>
<movie>
<name>Always</name>
<types>
<type>Drama</type>
<type>Romance</type>
</types>
<stars>
<name_actor>So Ji-seob</name_actor>
<name_actor>Han Hyo-joo</name_actor>
</stars>
<director>Song Il-Gon</director>
<date>
<day>2</day>
<month>Feb</month>
<year>2012</year>
</date>
</movie>
.
.
.
</film>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<table border="1">
<tr bgcolor="#0055EE">
<th>type</th>
<th>star</th>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT
Output
XSLT
<xsl:value-of>
XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<table border="1">
<tr bgcolor="#0055EE">
<th>types</th>
<th>stars</th>
</tr>
<tr>
<td><xsl:value-of select="film/movie/types"/></td>
<td><xsl:value-of select="film/movie/stars"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT
Output
XSLT
<xsl:for-each>
XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<table border="1">
<tr bgcolor="#0055EE">
<th>types</th>
<th>stars</th>
</tr>
<xsl:for-each select="film/movie">
<tr>
<td><xsl:value-of select="types"/></td>
<td><xsl:value-of select="stars"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT
Output
XSLT
<xsl:sort>
XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<table border="1">
<tr bgcolor="#0055EE">
<th>types</th>
<th>stars</th>
</tr>
<xsl:for-each select="film/movie">
<xsl:sort select="types"/>
<tr>
<td><xsl:value-of select="types"/></td>
<td><xsl:value-of select="stars"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT
Output
XSLT
<xsl:if>
XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<table border="1">
<tr bgcolor="#0055EE">
<th>types</th>
</tr>
<xsl:for-each select="film/movie">
<xsl:if test="date/year > 2016 ">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT
Output
XSLT
<xsl:choose>
XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<table border="1">
<tr bgcolor="#0055EE">
<th>types</th>
</tr>
<xsl:for-each select="film/movie">
<tr>
<xsl:choose>
<xsl:when test="date/year > 2016 ">
<td bgcolor="#ff00ff">
<xsl:value-of select="name"/>
</td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="name"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT
Output
XSLT
<xsl:apply-templates>
XSL File (Movie.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Movie</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="movie">
<p>
<xsl:apply-templates select="name"/>
<xsl:apply-templates select="types"/>
</p>
</xsl:template>
<xsl:template match="name">
Name: <span style="color:#ff0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="types">
Types: <span style="color:#00ff00">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>
XSLT
Output
Xpath
What is XPath?
• XPath เป็น syntax ในการกาหนดส่วนต่างๆของ XML
• XPath ใช้ระบบ path ในการนาทางและเข้าถึงในไฟล์ XML
• XPath ประกอบไปด้วย library ของฟังก์ชั่นพื้นฐาน
• XPath เป็น element หลัก (major element) ของ XSLT
• XPath เป็นที่แนะนาของ W3C
Xpath
XPath Terminology
Nodes
ใน XPath จะมี node อยู่ 7 ชนิดคือ : element, attribute, text, namespace,
processing-instruction, comment, และ document nodes.
ตัวอย่าง ไฟล์ XML
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
Xpath
Node ในไฟล์ xml
<bookstore> (root element node)
<author>J K. Rowling</author> (element node)
lang="en" (attribute node)
Xpath
XPath Syntax
Selecting Nodes
Expression Description
nodename เลือกทุก node ที่ชื่อ "nodename"
/ เลือกจาก root node
// เลือก node ในไฟล์ XML เริ่มจาก node ปัจจุบันที่ตรงกับการคัดเลือก
โดยไม่สนว่า node ที่เลือกมาจากไหน
. เลือก node ปัจจุบัน
.. เลือก parent ของ node ปัจจุบัน
@ เลือก attribute
Xpath
ตัวอย่างการใช้งานและผลลัพธ์
Path Expression Result
bookstore เลือกทุก node ที่ชื่อ "bookstore"
/bookstore เลือก root element bookstore
bookstore/book เลือก book elements ทั้งหมดที่เป็น children ของ bookstore
//book เลือก book elements ทั้งหมดโดยไม่สนว่า elements มาจากไหน
bookstore//boo
k
เลือก book elements ทั้งหมดที่เป็น descendant ของ element
bookstore
//@lang เลือก attributes ทั้งหมดที่ชื่อ lang
Xpath
Predicates
Predicates ใช้หา node ที่มีคุณสมบัติจาเพาะ หรือมีคุณสมบัติต่างๆกันโดย Predicates จะต้อง
เรียกใช้ภายใน [ ] เท่านั้น
Path Expression Result
/bookstore/book[1] เลือก element book ตัวแรกที่เป็น child ของ element bookstore
/bookstore/book[last()] เลือก element book ตัวสุดท้ายที่เป็น child ของ element bookstore
/bookstore/book[last()-1] เลือก element book ตัวก่อนสุดท้ายที่เป็น child ของ element
bookstore
/bookstore/book[position()<3] เลือก element book สองตัวแรกที่เป็น child ของ element bookstore
//title[@lang] เลือก element title ทุกตัวที่มี attribute ชื่อ lang
//title[@lang='en'] เลือก element title ทุกตัวที่มี attribute ชื่อ lang และ lang = en
/bookstore/book[price>35.00] เลือก element book ทุกตัวที่เป็น child ของ element bookstore และมี
ค่าของ element price มากกว่า 35
/bookstore/book[price>35.00]/title เลือก element title ทุกตัวที่เป็น child ของ element book ที่มีค่าของ
element price มากกว่า 35 และเป็น child ของ element bookstore
Xpath
XPath Operators
Operator Description Example
| Computes two node-sets //book | //cd
+ Addition 6 + 4
- Subtraction 6 - 4
* Multiplication 6 * 4
div Division 8 div 4
= Equal price=9.80
!= Not equal price!=9.80
< Less than price<9.80
<= Less than or equal to price<=9.80
> Greater than price>9.80
>= Greater than or equal to price>=9.80
or or price=9.80 or price=9.70
and and price>9.00 and price<9.90
mod Modulus (division remainder) 5 mod 2
Xqueries
• XQuery คือภาษาที่ใช้ในการ Query ข้อมูลจากเอกสาร XML คล้ายกับ SQL
• Xquery ใช้ Xpath ในการเข้าถึงส่วนต่าง ๆ ของ xml แล้วทาการแปลงข้อมูลออกเป็นรูปแบบ
หรือโครงสร้างอื่น
• ใช้ฟังชั่น doc() ในการเรียก ไฟล์ xml มาเช่น
• doc("MovieAll_SPN.xml")
• แล้วใช้ path ในการเข้าถึง element ต่างๆ
• doc("MovieAll_SPN.xml")/film/movie
Xqueries
FLWOR
• For - selects a sequence of nodes
• Let - binds a sequence to a variable
• Where - filters the nodes
• Order by - sorts the nodes
• Return - what to return (gets evaluated once for every node)
Xqueries
ทดลองโค้ดโดยการใช้ร่วมกับ html
for $x in film/movie
return <li>{data($x/name)}</li>
Xqueries
ในการเปรียบเทียบนั้นจะใช้เครื่องหมาย
=, !=, <, <=, >, >= หรือ eq, ne, lt, le, gt, ge โดยจะแตกต่างกันที่ eq, ne, lt, le, gt, ge
จะใช้งานได้เมื่อมีแค่ค่าเดียวที่เป็นจริง
ทดลองโค้ดเรียกชื่อหนังที่มี Tom Hanks แสดง
for $x in film/movie
where $x//name_actor="Tom Hanks"
return $x/name
Xqueries
ผลลัพธ์
Xqueries
ทดลองโค้ดเรียกชื่อหนังที่ชนิด Adventure เรียงตามชื่อ
for $x in film/movie
where $x/types/type="Adventure"
order by $x/name
return $x/name
Xqueries
Reference
• XSL Tutorial
http://www.w3schools.com/xsl/
Members
Group1
นาย อภิวัฒธ์วงศ์โท๊ะ รหัสนักศึกษา 52-1116-530-2
นางสาว พัลลภา เขมรังสฤษฏ์รหัสนักศึกษา 56-
นางสาว อัญธิกา หนองบัว รหัสนักศึกษา 56-010126-
นาย ธีรวัฒน์ ผ่องสกุล รหัสนักศึกษา 56-010126-3015-
นาย ธนดล เตชะวัชรีกุล รหัสนักศึกษา 56-010126-
นาย ภูมมิฑล ไชยเชิดเกียรติ รหัสนักศึกษา 56-010116-
To try use XSL for display group XML file movies

More Related Content

Viewers also liked

How developers write documentation
How developers write documentationHow developers write documentation
How developers write documentation
Senthilkumar Gopal
 
Wikis 2008
Wikis 2008Wikis 2008
Wikis 2008
David Liziard
 
E-books and App::Pod2Epub
E-books and App::Pod2EpubE-books and App::Pod2Epub
E-books and App::Pod2Epub
Søren Lund
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
Dudy Ali
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
Søren Lund
 
Chapter 04 part 2 Tech. Writing 2014-2015
Chapter 04 part 2 Tech. Writing  2014-2015Chapter 04 part 2 Tech. Writing  2014-2015
Chapter 04 part 2 Tech. Writing 2014-2015
Magdi Saadawi
 
Project Documentation | Common Room Networks Foundation | 2003 - 2008
Project Documentation | Common Room Networks Foundation | 2003 - 2008Project Documentation | Common Room Networks Foundation | 2003 - 2008
Project Documentation | Common Room Networks Foundation | 2003 - 2008
Gustaff Harriman Iskandar
 
Wonderful World of Wikis
Wonderful World of WikisWonderful World of Wikis
Wonderful World of Wikis
Vicki Davis
 
Doxygen - Source Code Documentation Generator Tool
Doxygen -  Source Code Documentation Generator ToolDoxygen -  Source Code Documentation Generator Tool
Doxygen - Source Code Documentation Generator ToolGuo Albert
 
Introducción a la gestión de sistemas de información en la empresa. Universit...
Introducción a la gestión de sistemas de información en la empresa. Universit...Introducción a la gestión de sistemas de información en la empresa. Universit...
Introducción a la gestión de sistemas de información en la empresa. Universit...
Julio Iglesias Pascual
 
Docs as-code-missing.-manual
Docs as-code-missing.-manualDocs as-code-missing.-manual
Docs as-code-missing.-manual
Margaret Eker
 
Thinking of Documentation as Code [YUIConf 2013]
Thinking of Documentation as Code [YUIConf 2013]Thinking of Documentation as Code [YUIConf 2013]
Thinking of Documentation as Code [YUIConf 2013]
evangoer
 
Session 4
Session 4Session 4
XSLT 2010-03-03
XSLT 2010-03-03XSLT 2010-03-03
XSLT 2010-03-03
kmiyako
 
DITA getting started
DITA getting startedDITA getting started
DITA getting startedRaghu nath
 

Viewers also liked (20)

How developers write documentation
How developers write documentationHow developers write documentation
How developers write documentation
 
Wikis 2008
Wikis 2008Wikis 2008
Wikis 2008
 
E-books and App::Pod2Epub
E-books and App::Pod2EpubE-books and App::Pod2Epub
E-books and App::Pod2Epub
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Chapter 04 part 2 Tech. Writing 2014-2015
Chapter 04 part 2 Tech. Writing  2014-2015Chapter 04 part 2 Tech. Writing  2014-2015
Chapter 04 part 2 Tech. Writing 2014-2015
 
MSc dissertation np
MSc dissertation npMSc dissertation np
MSc dissertation np
 
Project Documentation | Common Room Networks Foundation | 2003 - 2008
Project Documentation | Common Room Networks Foundation | 2003 - 2008Project Documentation | Common Room Networks Foundation | 2003 - 2008
Project Documentation | Common Room Networks Foundation | 2003 - 2008
 
Wonderful World of Wikis
Wonderful World of WikisWonderful World of Wikis
Wonderful World of Wikis
 
Code documentation
Code documentationCode documentation
Code documentation
 
XSLT. Basic.
XSLT. Basic.XSLT. Basic.
XSLT. Basic.
 
Doxygen - Source Code Documentation Generator Tool
Doxygen -  Source Code Documentation Generator ToolDoxygen -  Source Code Documentation Generator Tool
Doxygen - Source Code Documentation Generator Tool
 
Introducción a la gestión de sistemas de información en la empresa. Universit...
Introducción a la gestión de sistemas de información en la empresa. Universit...Introducción a la gestión de sistemas de información en la empresa. Universit...
Introducción a la gestión de sistemas de información en la empresa. Universit...
 
Docs as-code-missing.-manual
Docs as-code-missing.-manualDocs as-code-missing.-manual
Docs as-code-missing.-manual
 
Thinking of Documentation as Code [YUIConf 2013]
Thinking of Documentation as Code [YUIConf 2013]Thinking of Documentation as Code [YUIConf 2013]
Thinking of Documentation as Code [YUIConf 2013]
 
Session 4
Session 4Session 4
Session 4
 
Doxygen
DoxygenDoxygen
Doxygen
 
XSLT 2010-03-03
XSLT 2010-03-03XSLT 2010-03-03
XSLT 2010-03-03
 
Introduction to DITA
Introduction to DITAIntroduction to DITA
Introduction to DITA
 
DITA getting started
DITA getting startedDITA getting started
DITA getting started
 

More from Aey Unthika

Assignmet 2 selectedtopic Topic in Computer Engineer
Assignmet 2 selectedtopic Topic in Computer EngineerAssignmet 2 selectedtopic Topic in Computer Engineer
Assignmet 2 selectedtopic Topic in Computer Engineer
Aey Unthika
 
Assignmet1 selectedtopic Topic in Computer Engineer
Assignmet1 selectedtopic Topic in Computer EngineerAssignmet1 selectedtopic Topic in Computer Engineer
Assignmet1 selectedtopic Topic in Computer Engineer
Aey Unthika
 
Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...
Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...
Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...
Aey Unthika
 
Try PostgreSQL on linux
Try PostgreSQL on linuxTry PostgreSQL on linux
Try PostgreSQL on linux
Aey Unthika
 
Example Database normal form
Example Database normal formExample Database normal form
Example Database normal form
Aey Unthika
 
Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)
Aey Unthika
 
Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3)
Aey Unthika
 

More from Aey Unthika (7)

Assignmet 2 selectedtopic Topic in Computer Engineer
Assignmet 2 selectedtopic Topic in Computer EngineerAssignmet 2 selectedtopic Topic in Computer Engineer
Assignmet 2 selectedtopic Topic in Computer Engineer
 
Assignmet1 selectedtopic Topic in Computer Engineer
Assignmet1 selectedtopic Topic in Computer EngineerAssignmet1 selectedtopic Topic in Computer Engineer
Assignmet1 selectedtopic Topic in Computer Engineer
 
Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...
Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...
Assignmet1:Start by finding web services using SOAP and WSDL on the Internet/...
 
Try PostgreSQL on linux
Try PostgreSQL on linuxTry PostgreSQL on linux
Try PostgreSQL on linux
 
Example Database normal form
Example Database normal formExample Database normal form
Example Database normal form
 
Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)
 
Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3)
 

Recently uploaded

atwordfamily words with Thai translationtx
atwordfamily words with Thai translationtxatwordfamily words with Thai translationtx
atwordfamily words with Thai translationtx
Bangkok, Thailand
 
การเขียนข้อเสนอโครงการวิจัย (Research Proposal)
การเขียนข้อเสนอโครงการวิจัย (Research Proposal)การเขียนข้อเสนอโครงการวิจัย (Research Proposal)
การเขียนข้อเสนอโครงการวิจัย (Research Proposal)
Prachyanun Nilsook
 
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf
สุเมธี​​​​ ตี่พนมโอรัล / សុមេធី ទីភ្នំឱរ៉ាល់ (Sumedhi TyPhnomAoral)
 
4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf
4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf
4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf
สุเมธี​​​​ ตี่พนมโอรัล / សុមេធី ទីភ្នំឱរ៉ាល់ (Sumedhi TyPhnomAoral)
 
งานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdf
งานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdfงานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdf
งานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdf
Faculty of BuddhismMahachulalongkornrajavidyalaya Roi Et Buddhist College
 
ภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนา
ภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนาภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนา
ภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนา
Faculty of BuddhismMahachulalongkornrajavidyalaya Roi Et Buddhist College
 
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf
สุเมธี​​​​ ตี่พนมโอรัล / សុមេធី ទីភ្នំឱរ៉ាល់ (Sumedhi TyPhnomAoral)
 
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf
สุเมธี​​​​ ตี่พนมโอรัล / សុមេធី ទីភ្នំឱរ៉ាល់ (Sumedhi TyPhnomAoral)
 
แนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdf
แนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdfแนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdf
แนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdf
Faculty of BuddhismMahachulalongkornrajavidyalaya Roi Et Buddhist College
 
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf
สุเมธี​​​​ ตี่พนมโอรัล / សុមេធី ទីភ្នំឱរ៉ាល់ (Sumedhi TyPhnomAoral)
 

Recently uploaded (10)

atwordfamily words with Thai translationtx
atwordfamily words with Thai translationtxatwordfamily words with Thai translationtx
atwordfamily words with Thai translationtx
 
การเขียนข้อเสนอโครงการวิจัย (Research Proposal)
การเขียนข้อเสนอโครงการวิจัย (Research Proposal)การเขียนข้อเสนอโครงการวิจัย (Research Proposal)
การเขียนข้อเสนอโครงการวิจัย (Research Proposal)
 
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค ป.ธ.3 (2500-2567).pdf
 
4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf
4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf
4_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลไทยเป็นมคธ ประโยค ป.ธ.4 (2505-2567).pdf
 
งานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdf
งานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdfงานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdf
งานนำเสนอ ภาษากับการสื่อสาร เพื่อการพัฒนา.pdf
 
ภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนา
ภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนาภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนา
ภาษาอังกฤษเพื่อการปฏิบัติกรรมฐานในพระพุทธศาสนา
 
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา แปลมคธเป็นไทย ประโยค 1-2 (2510-2567).pdf
 
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf
3_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา สัมพันธ์ไทย ประโยค ป.ธ.3 (2500-2567).pdf
 
แนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdf
แนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdfแนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdf
แนวความเชื่อ วิธีการปฎิบัติ พระพุทธศาสนามหายาน.pdf
 
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf
1-2_ปัญหาและเฉลยข้อสอบบาลีสนามหลวง วิชา บาลีไวยากรณ์ ประโยค 1-2 (2511-2567).pdf
 

To try use XSL for display group XML file movies

  • 1. “หนึ่งหน่วยกลุ่ม” (Group 1) Selected Topics in Computer Engineering II XSLT, Xpath Xqueries Try to use
  • 2. XSLT XSLT = XSL Transformations XSLT is a language for transforming XML documents into XHTML documents or to other XML documents.
  • 3. XSLT <xsl:template> XML File XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Movie.xsl"?> <film> <movie> <name>Always</name> <types> <type>Drama</type> <type>Romance</type> </types> <stars> <name_actor>So Ji-seob</name_actor> <name_actor>Han Hyo-joo</name_actor> </stars> <director>Song Il-Gon</director> <date> <day>2</day> <month>Feb</month> <year>2012</year> </date> </movie> . . . </film> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Movie</h2> <table border="1"> <tr bgcolor="#0055EE"> <th>type</th> <th>star</th> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 5. XSLT <xsl:value-of> XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Movie</h2> <table border="1"> <tr bgcolor="#0055EE"> <th>types</th> <th>stars</th> </tr> <tr> <td><xsl:value-of select="film/movie/types"/></td> <td><xsl:value-of select="film/movie/stars"/></td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 7. XSLT <xsl:for-each> XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Movie</h2> <table border="1"> <tr bgcolor="#0055EE"> <th>types</th> <th>stars</th> </tr> <xsl:for-each select="film/movie"> <tr> <td><xsl:value-of select="types"/></td> <td><xsl:value-of select="stars"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 9. XSLT <xsl:sort> XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Movie</h2> <table border="1"> <tr bgcolor="#0055EE"> <th>types</th> <th>stars</th> </tr> <xsl:for-each select="film/movie"> <xsl:sort select="types"/> <tr> <td><xsl:value-of select="types"/></td> <td><xsl:value-of select="stars"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 11. XSLT <xsl:if> XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Movie</h2> <table border="1"> <tr bgcolor="#0055EE"> <th>types</th> </tr> <xsl:for-each select="film/movie"> <xsl:if test="date/year > 2016 "> <tr> <td><xsl:value-of select="name"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 13. XSLT <xsl:choose> XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="/"> <html> <body> <h2>Movie</h2> <table border="1"> <tr bgcolor="#0055EE"> <th>types</th> </tr> <xsl:for-each select="film/movie"> <tr> <xsl:choose> <xsl:when test="date/year > 2016 "> <td bgcolor="#ff00ff"> <xsl:value-of select="name"/> </td> </xsl:when> <xsl:otherwise> <td><xsl:value-of select="name"/></td> </xsl:otherwise> </xsl:choose> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
  • 15. XSLT <xsl:apply-templates> XSL File (Movie.xsl) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Movie</h2> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="movie"> <p> <xsl:apply-templates select="name"/> <xsl:apply-templates select="types"/> </p> </xsl:template> <xsl:template match="name"> Name: <span style="color:#ff0000"> <xsl:value-of select="."/></span> <br /> </xsl:template> <xsl:template match="types"> Types: <span style="color:#00ff00"> <xsl:value-of select="."/></span> <br /> </xsl:template> </xsl:stylesheet>
  • 17. Xpath What is XPath? • XPath เป็น syntax ในการกาหนดส่วนต่างๆของ XML • XPath ใช้ระบบ path ในการนาทางและเข้าถึงในไฟล์ XML • XPath ประกอบไปด้วย library ของฟังก์ชั่นพื้นฐาน • XPath เป็น element หลัก (major element) ของ XSLT • XPath เป็นที่แนะนาของ W3C
  • 18. Xpath XPath Terminology Nodes ใน XPath จะมี node อยู่ 7 ชนิดคือ : element, attribute, text, namespace, processing-instruction, comment, และ document nodes. ตัวอย่าง ไฟล์ XML <?xml version="1.0" encoding="UTF-8"?> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
  • 19. Xpath Node ในไฟล์ xml <bookstore> (root element node) <author>J K. Rowling</author> (element node) lang="en" (attribute node)
  • 20. Xpath XPath Syntax Selecting Nodes Expression Description nodename เลือกทุก node ที่ชื่อ "nodename" / เลือกจาก root node // เลือก node ในไฟล์ XML เริ่มจาก node ปัจจุบันที่ตรงกับการคัดเลือก โดยไม่สนว่า node ที่เลือกมาจากไหน . เลือก node ปัจจุบัน .. เลือก parent ของ node ปัจจุบัน @ เลือก attribute
  • 21. Xpath ตัวอย่างการใช้งานและผลลัพธ์ Path Expression Result bookstore เลือกทุก node ที่ชื่อ "bookstore" /bookstore เลือก root element bookstore bookstore/book เลือก book elements ทั้งหมดที่เป็น children ของ bookstore //book เลือก book elements ทั้งหมดโดยไม่สนว่า elements มาจากไหน bookstore//boo k เลือก book elements ทั้งหมดที่เป็น descendant ของ element bookstore //@lang เลือก attributes ทั้งหมดที่ชื่อ lang
  • 22. Xpath Predicates Predicates ใช้หา node ที่มีคุณสมบัติจาเพาะ หรือมีคุณสมบัติต่างๆกันโดย Predicates จะต้อง เรียกใช้ภายใน [ ] เท่านั้น Path Expression Result /bookstore/book[1] เลือก element book ตัวแรกที่เป็น child ของ element bookstore /bookstore/book[last()] เลือก element book ตัวสุดท้ายที่เป็น child ของ element bookstore /bookstore/book[last()-1] เลือก element book ตัวก่อนสุดท้ายที่เป็น child ของ element bookstore /bookstore/book[position()<3] เลือก element book สองตัวแรกที่เป็น child ของ element bookstore //title[@lang] เลือก element title ทุกตัวที่มี attribute ชื่อ lang //title[@lang='en'] เลือก element title ทุกตัวที่มี attribute ชื่อ lang และ lang = en /bookstore/book[price>35.00] เลือก element book ทุกตัวที่เป็น child ของ element bookstore และมี ค่าของ element price มากกว่า 35 /bookstore/book[price>35.00]/title เลือก element title ทุกตัวที่เป็น child ของ element book ที่มีค่าของ element price มากกว่า 35 และเป็น child ของ element bookstore
  • 23. Xpath XPath Operators Operator Description Example | Computes two node-sets //book | //cd + Addition 6 + 4 - Subtraction 6 - 4 * Multiplication 6 * 4 div Division 8 div 4 = Equal price=9.80 != Not equal price!=9.80 < Less than price<9.80 <= Less than or equal to price<=9.80 > Greater than price>9.80 >= Greater than or equal to price>=9.80 or or price=9.80 or price=9.70 and and price>9.00 and price<9.90 mod Modulus (division remainder) 5 mod 2
  • 24. Xqueries • XQuery คือภาษาที่ใช้ในการ Query ข้อมูลจากเอกสาร XML คล้ายกับ SQL • Xquery ใช้ Xpath ในการเข้าถึงส่วนต่าง ๆ ของ xml แล้วทาการแปลงข้อมูลออกเป็นรูปแบบ หรือโครงสร้างอื่น • ใช้ฟังชั่น doc() ในการเรียก ไฟล์ xml มาเช่น • doc("MovieAll_SPN.xml") • แล้วใช้ path ในการเข้าถึง element ต่างๆ • doc("MovieAll_SPN.xml")/film/movie
  • 25. Xqueries FLWOR • For - selects a sequence of nodes • Let - binds a sequence to a variable • Where - filters the nodes • Order by - sorts the nodes • Return - what to return (gets evaluated once for every node)
  • 27. Xqueries ในการเปรียบเทียบนั้นจะใช้เครื่องหมาย =, !=, <, <=, >, >= หรือ eq, ne, lt, le, gt, ge โดยจะแตกต่างกันที่ eq, ne, lt, le, gt, ge จะใช้งานได้เมื่อมีแค่ค่าเดียวที่เป็นจริง ทดลองโค้ดเรียกชื่อหนังที่มี Tom Hanks แสดง for $x in film/movie where $x//name_actor="Tom Hanks" return $x/name
  • 32. Members Group1 นาย อภิวัฒธ์วงศ์โท๊ะ รหัสนักศึกษา 52-1116-530-2 นางสาว พัลลภา เขมรังสฤษฏ์รหัสนักศึกษา 56- นางสาว อัญธิกา หนองบัว รหัสนักศึกษา 56-010126- นาย ธีรวัฒน์ ผ่องสกุล รหัสนักศึกษา 56-010126-3015- นาย ธนดล เตชะวัชรีกุล รหัสนักศึกษา 56-010126- นาย ภูมมิฑล ไชยเชิดเกียรติ รหัสนักศึกษา 56-010116-