1 / 10

XML คืออะไร

XML คืออะไร. ย่อมาจาก eXtensible Markup Language เป็นชุดภาษาย่อยของภาษา SGML – Standard Generalized Markup Language ภาษา Markup ที่ใช้อธิบายหรือพรรณนาข้อมูลที่จัดเก็บ ภาษามาตรฐานสำหรับการแลกเปลี่ยนข้อมูลบนเครือข่ายอินเทอร์เน็ต. XML คืออะไร.

lok
Download Presentation

XML คืออะไร

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML คืออะไร • ย่อมาจาก eXtensible Markup Language • เป็นชุดภาษาย่อยของภาษา SGML – Standard Generalized Markup Language • ภาษา Markup ที่ใช้อธิบายหรือพรรณนาข้อมูลที่จัดเก็บ • ภาษามาตรฐานสำหรับการแลกเปลี่ยนข้อมูลบนเครือข่ายอินเทอร์เน็ต

  2. XML คืออะไร • ทำการ Markup โดยสามารถกำหนดป้ายเครื่องหมาย หรือ แท็ก (tag) ได้เอง เพื่อกำหนดข้อมูลที่ต้องการอธิบาย • ใช้ Document Type Definition (DTD) or an XML Schema ในการอธิบายลักษณะโครงสร้างข้อมูล • ถูกออกแบบให้มีลักษณะที่สามารถอธิบาย หรือพรรณนาข้อมูลที่จัดเก็บได้ด้วยตนเอง (Self Describing) โดยใช้ DTD หรือ Schema

  3. มาตรฐานต่างๆที่เกี่ยวข้องกับ XML • Namespaceสำหรับช่วยในการกำหนดขอบเขตให้กับชื่อของ elementและ attributeเพื่อหลีกเลี่ยงการถูกเรียกซ้ำ • XSL (Extensible Stylesheet Language) เป็นภาษาในการกำหนด style sheets ให้กับ XML data สำหรับการนำเสนอเป็นเว็บบราวเซอร์หรือสื่อนำเสนออื่นๆ • XLink เป็นการปรับปรุงการเชื่อมโยงใน HTML โดยสนับสนุนการเชื่อมโยงแบบสองทาง, แบบหนึ่งต่อหลายแห่ง และแบบแยกตามประเภท XLink มีพื้นฐานการทำงานแบบ HyTime • RDF เป็น Metadata สำหรับเอกสาร XML คล้ายกับ Metadata tags ของ HTML เช่น ผู้แต่ง, ลิขสิทธิ์และวันที่จัดพิมพ์

  4. มาตรฐานต่างๆที่เกี่ยวข้องกับ XML (ต่อ) • XSchema เข้ามาแทนที่ DTD สำหรับการกำหนดประเภทของข้อมูล ของ XML • XQL เป็นส่วนขยายของ XSL สำหรับใช้อ้างถึงและกลั่นกรองส่วนที่เป็น element และ text ของเอกสาร ช่วยกำหนดรูปแบบที่ชัดเจน เข้าใจง่ายในการเข้าถึง element

  5. การนำ XML ไปใช้ • สร้างเอกสาร XML เพื่อจัดเก็บข้อมูล • สร้างเอกสาร DTD/XML Schema เพื่อนิยามความหมายและกำหนดโครงสร้าง ของข้อมูลที่จัดเก็บ • สร้างเอกสาร XSL เพื่อกำหนดข้อมูลที่ต้องการและรูปแบบ (formatting) ใน การนำเสนอ • เขียนโปรแกรม/สคริปท์ เพื่อวิเคราะห์และแยกแยะ (parsing) โครงสร้างและประมวลผลเอกสาร XML

  6. XML Schema • <schema> เป็น root element ของทุก XML Schema ซึ่งอาจจะมี attribute บางอย่างได้ • <?xml version="1.0"?> • <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">... ...</xs:schema>

  7. XML Schema คำอธิบาย attribute • xmlns:xs="http://www.w3.org/2001/XMLSchema" เป็นการบอกให้ทราบว่า element และ data type ที่ใช้ใน schema มาจาก "http://www.w3.org/2001/XMLSchema" และเมื่อเรียกใช้จะต้องขึ้นต้นด้วย xs: • targetNamespace="http://www.w3schools.com" เป็นการประกาศ namespace ของ schema เมื่อนำในเอกสาร xml จะต้องอ้างอิง namspace ที่กำหนดไว้ • xmlns="http://www.w3schools.com" เป็นการประกาศค่า default ของ namespace ให้กับ schema • elementFormDefault="qualified" เป็นการกำหนดว่าเอกสาร xml ที่นำ element ของ schema นี้ไปใช้ จะต้องแสดง namespace ของ schema

  8. การกำหนดข้อบังคับให้ประเภทข้อมูล

  9. ตัวอย่าง • กำหนดค่าอายุ ต้องมีค่าระหว่าง 0-100 ปี • <xs:element name="age"> • <xs:simpleType> • <xs:restriction base="xs:integer"> • <xs:minInclusive value="0"/> • <xs:maxInclusive value="100"/> • </xs:restriction> • </xs:simpleType> • </xs:element>

  10. ตัวอย่าง ตัวอย่าง libarary.xml

More Related