HTML XPointer ການສອນ

ພວກເຮົາຈະຮຽນພາສານຳການນຳໃຊ້ XPointer ທີ່ຫນັງຈາກການສຶກສາອິດສະຫລະການພິມສະແດງ.

HTML XPointer ການສອນ

ໃນກໍລະນີນີ້ພວກເຮົາຈະສະແດງໃຫ້ເຫັນວິທີການໃຊ້ XPointer ແລະ XLink ເພື່ອຍິນຍານສ່ວນຫນວງອື່ນຂອງເອກະສານອື່ນ.

ພວກເຮົາຈະເລີ່ມການສຶກສາເອກະສານ XML ທີ່ເປັນເປົ້າໝາຍ (ຄືກັບເວັບໄຊທີ່ພວກເຮົາຈະເຊື່ອມຕໍ່).

ເອກະສານ XML

ເອກະສານ XML ທີ່ເປັນເປົ້າໝາຍ "dogbreeds.xml" ແມ່ນກຳລັງລະບຸນັກໂຕສັນຊາດການຍາດຫລາຍຊັບຊັ້ນ:

<?xml version="1.0" encoding="ISO-8859-1"?>
<dogbreeds>
<dog breed="Rottweiler" id="Rottweiler">
  <picture url="http://dog.com/rottweiler.gif" />
  <history>
  The Rottweiler's ancestors were probably Roman
  drover dogs.....
  </history>
  <temperament>
  Confident, bold, alert and imposing, the Rottweiler
  is a popular choice for its ability to protect....
  </temperament>
</dog>
<dog breed="FCRetriever" id="FCRetriever">
  <picture url="http://dog.com/fcretriever.gif" />
  <history>
  One of the earliest uses of retrieving dogs was to
  help fishermen retrieve fish from the water....
  </history>
  <temperament>
  The flat-coated retriever is a sweet, exuberant,
  lively dog that loves to play and retrieve....
  </temperament>
</dog>
</dogbreeds>

ກວດສອບ "dogbreeds.xml" ໃນບູລາມຂອງທ່ານ

ຄວາມຄິດ:ເອກະສານ XML ທີ່ກ່າວກ່າວໄວ້ມີ id ຜະລິດຈະຢູ່ໃນປະກອບສະຖານທີ່ທີ່ພວກເຮົາຕ້ອງເຊື່ອມຕໍ່.

ເອກະສານພາບການເຊື່ອມຕໍ່

ບໍ່ພຽງແຕ່ສາມາດເຊື່ອມຕໍ່ໄປທັງເອກະສານທັງໝົດ (ເມື່ອນຳໃຊ້ XLink), XPointer ອາດອ້າງຕໍ່ບາງສ່ວນຂອງເອກະສານ. ຖ້າຕ້ອງອ້າງຕໍ່ບາງສ່ວນຂອງເວັບໄຊ, ຂໍ້ສະເໜີ xlink:href ທີ່ຕາມ URL ສະເໜີ # ແລະ XPointer ປະສານ.

ຄຳສັບປະສານ:#xpointer(id("Rottweiler")) ສາມາດອ້າງຫາປະກອບສະຖານທີ່ທີ່ມີ id ຄວາມຄິດ "Rottweiler" ໃນເອກະສານເປົ້າຫນັງ.

ຍ້ອນນັ້ນ xlink:href ຜະລິດຈະຄືກັນນັ້ນ:xlink:href="http://dog.com/dogbreeds.xml#xpointer(id('Rottweiler'))"

ແຕ່ວ່າເມື່ອນຳໃຊ້ id ເພື່ອຫນຸ່ງໃສ່ປະກອບສອງຫນື່ງໃດ XPointer ອາດນຳໃຊ້ຮູບແບບການຫນຸ່ງຫນື່ງ. ທ່ານສາມາດໃຊ້ຄູ່ມູນຂອງ id ທັງໝົດ ຄືກັບນັ້ນ:xlink:href="http://dog.com/dogbreeds.xml#Rottweiler"

XML ເອກະສານທີ່ລົງມາທີ່ສາມາດອ້າງອີງຂໍ້ມູນສາຍພັນຂອງພະຍາກອນດັ່ງກ່າວທັງໝົດ ທີ່ຈະອ້າງອີງຜ່ານ XLink และ XPointer:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mydogs xmlns:xlink="http://www.w3.org/1999/xlink">
<mydog xlink:type="simple"
  xlink:href="http://dog.com/dogbreeds.xml#Rottweiler">
  <description xlink:type="simple"
  xlink:href="http://myweb.com/mydogs/anton.gif">
  Anton is my favorite dog. He has won a lot of.....
  </description>
</mydog>
<mydog xlink:type="simple"
  xlink:href="http://dog.com/dogbreeds.xml#FCRetriever">
  <description xlink:type="simple"
  xlink:href="http://myweb.com/mydogs/pluto.gif">
  Pluto is the sweetest dog on earth......
  </description>
</mydog>
</mydogs>