XML ၊ XLink နှင့် XPointer
XLink ကို XML စာရွက်စာတမ်းများတွင် ဟိုက်ပါလင့်ခ်များ ဖန်တီးရန် အသုံးပြုသည်။
|
XLink Browser ပံ့ပိုးမှု
XML စာရွက်စာတမ်းများတွင် XLink အတွက်ဘရောက်ဆာပံ့ပိုးမှုမရှိပါ။
သို့သော်၊ အဓိကဘရောက်ဆာများအားလုံးသည် SVG တွင် XLinks ကို ပံ့ပိုးသည် ။
XLink Syntax
HTML တွင်၊ <a> ဒြပ်စင်သည် ဟိုက်ပါလင့်ခ်ကို သတ်မှတ်သည်။ သို့သော်၊ ၎င်းသည် XML တွင်အလုပ်လုပ်ပုံမဟုတ်ပါ။ XML စာရွက်စာတမ်းများတွင် သင်အလိုရှိသော မည်သည့်ဒြပ်စင်အမည်များကိုမဆို သုံးနိုင်သည် - ထို့ကြောင့် XML စာရွက်စာတမ်းများတွင် မည်သည့်လင့်ခ်ဒြပ်စင်များကို ခေါ်မည်ကို ဘရောက်ဆာများက ခန့်မှန်းရန် မဖြစ်နိုင်ပေ။
အောက်တွင် XLink ကိုအသုံးပြုပုံသည် XML စာရွက်စာတမ်းရှိလင့်ခ်များကိုဖန်တီးရန်ရိုးရှင်းသောဥပမာတစ်ခုဖြစ်သည်။
<?xml version="1.0" encoding="UTF-8"?>
<homepages xmlns:xlink="http://www.w3.org/1999/xlink">
<homepage xlink:type="simple"
xlink:href="https://www.w3schools.com">Visit W3Schools</homepage>
<homepage xlink:type="simple"
xlink:href="http://www.w3.org">Visit W3C</homepage>
</homepages>
XLink အင်္ဂါရပ်များသို့ ဝင်ရောက်ခွင့်ရရန် ကျွန်ုပ်တို့သည် XLink namespace ကို ကြေညာရပါမည်။ XLink namespace သည် "http://www.w3.org/1999/xlink" ဖြစ်သည်။
<homepage> ဒြပ်စင်များရှိ xlink:type နှင့် xlink:href ရည်ညွှန်းချက်များသည် XLink namespace မှ လာပါသည်။
xlink:type="simple" သည် ရိုးရှင်းသော "HTML-like" လင့်ခ်တစ်ခုကို ဖန်တီးသည် (ဆိုလိုသည်မှာ "ထိုသို့သွားရန် ဤနေရာကိုနှိပ်ပါ")။
xlink:href ရည်ညွှန်းချက်သည် ချိတ်ဆက်ရန် URL ကို သတ်မှတ်သည်။
XLink ဥပမာ
အောက်ပါ XML စာရွက်စာတမ်းတွင် XLink အင်္ဂါရပ်များပါရှိသည်။
<?xml version="1.0" encoding="UTF-8"?>
<bookstore xmlns:xlink="http://www.w3.org/1999/xlink">
<book title="Harry Potter">
<description
xlink:type="simple"
xlink:href="/images/HPotter.gif"
xlink:show="new">
As his fifth year at Hogwarts School of Witchcraft and
Wizardry approaches, 15-year-old Harry Potter is.......
</description>
</book>
<book title="XQuery Kick Start">
<description
xlink:type="simple"
xlink:href="/images/XQuery.gif"
xlink:show="new">
XQuery Kick Start delivers a concise introduction
to the XQuery standard.......
</description>
</book>
</bookstore>
ဥပမာ ရှင်းပြထားသည်
- XLink namespace ကို စာရွက်စာတမ်း၏ထိပ်တွင် ကြေငြာထားသည် (xmlns:xlink="http://www.w3.org/1999/xlink")
- xlink:type="simple" သည် ရိုးရှင်းသော "HTML-like" လင့်ခ်တစ်ခုကို ဖန်တီးသည်။
- xlink:href ရည်ညွှန်းချက်သည် ချိတ်ဆက်ရန် URL ကို သတ်မှတ်သည် (ဤကိစ္စတွင် - ပုံတစ်ခု)
- xlink:show="new" သည် လင့်ခ်ကို ဝင်းဒိုးအသစ်တစ်ခုတွင် ဖွင့်သင့်သည်ဟု သတ်မှတ်သည်။
XLink - ရှေ့ဆက်သွားပါ။
အထက်ဖော်ပြပါ ဥပမာတွင် ကျွန်ုပ်တို့သည် ရိုးရှင်းသော XLink များကို သရုပ်ပြထားပါသည်။ သီးခြားစာမျက်နှာများအစား ဝေးလံခေါင်သီသောနေရာများကို အရင်းအမြစ်များအဖြစ် အသုံးပြုသည့်အခါ XLink သည် ပိုမိုစိတ်ဝင်စားစရာကောင်းလာသည်။
xlink:show attribute ကို "embed" ဟု သတ်မှတ်ပါက၊ လင့်ခ်ချိတ်ထားသော အရင်းအမြစ်ကို စာမျက်နှာအတွင်းတွင် စီမံဆောင်ရွက်သင့်ပါသည်။ ၎င်းသည် အခြားသော XML စာရွက်စာတမ်း ဖြစ်နိုင်သည်ဟု သင်ယူဆသောအခါ၊ ဥပမာ၊ XML စာရွက်စာတမ်းများ၏ အထက်တန်းကို တည်ဆောက်နိုင်သည်။
အရင်းအမြစ်ပေါ်လာသည့်အခါတွင် xlink:actuate attribute ဖြင့်လည်း သင်သတ်မှတ်နိုင်ပါသည်။
XLink ရည်ညွှန်းချက်
Attribute | Value | Description |
---|---|---|
xlink:actuate | onLoad onRequest other none |
Defines when the linked resource is read and shown:
|
xlink:href | URL | Specifies the URL to link to |
xlink:show | embed new replace other none |
Specifies where to open the link. Default is "replace" |
xlink:type | simple extended locator arc resource title none |
Specifies the type of link |
XPointer
|
XPointer Browser ပံ့ပိုးမှု
XPointer အတွက် ဘရောက်ဆာ ပံ့ပိုးမှု မရှိပါ။ သို့သော် XPointer ကို အခြားသော XML ဘာသာစကားများတွင် အသုံးပြုသည်။
XPointer ဥပမာ
ဤဥပမာတွင်၊ ကျွန်ုပ်တို့သည် အခြားသောစာရွက်စာတမ်း၏ သီးခြားအစိတ်အပိုင်းတစ်ခုကိုညွှန်ပြရန် XLink နှင့်တွဲဖက်၍ XPointer ကိုအသုံးပြုပါမည်။
ပစ်မှတ် XML စာရွက်စာတမ်း (ကျွန်ုပ်တို့ချိတ်ဆက်နေသောစာရွက်စာတမ်း) ကိုကြည့်ရှုခြင်းဖြင့် စတင်ပါမည်။
<?xml version="1.0" encoding="UTF-8"?>
<dogbreeds>
<dog breed="Rottweiler" id="Rottweiler">
<picture url="https://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="https://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>
အထက်ဖော်ပြပါ XML စာရွက်စာတမ်းသည် ဒြပ်စင်တစ်ခုစီတွင် id attribute ကိုအသုံးပြုကြောင်း သတိပြုပါ။
ထို့ကြောင့်၊ စာရွက်စာတမ်းတစ်ခုလုံး (XLink ကဲ့သို့) ချိတ်ဆက်မည့်အစား XPointer သည် သင့်အား စာရွက်စာတမ်း၏ သီးခြားအစိတ်အပိုင်းများသို့ လင့်ခ်ချိတ်ရန် ခွင့်ပြုသည်။ စာမျက်နှာတစ်ခု၏ သီးခြားအစိတ်အပိုင်းတစ်ခုသို့ လင့်ခ်ချိတ်ရန်၊ ဤကဲ့သို့သော xlink:href ရည်ညွှန်းချက်ရှိ URL ပြီးနောက် နံပါတ်သင်္ကေတ (#) နှင့် XPointer စကားရပ်ကို ပေါင်းထည့်ပါ- xlink:href="https://dog.com/dogbreeds.xml #xpointer(id('Rottweiler')))"။ စကားရပ်သည် "Rottweiler" ၏ ID တန်ဖိုးဖြင့် ပစ်မှတ်စာရွက်စာတမ်းရှိ အစိတ်အပိုင်းကို ရည်ညွှန်းသည်။
XPointer သည် id တစ်ခုနှင့် ဒြပ်စင်တစ်ခုသို့ ချိတ်ဆက်ရန်အတွက် အတိုကောက်နည်းလမ်းကိုလည်း ခွင့်ပြုသည်။ ဤကဲ့သို့သော id ၏တန်ဖိုးကို သင်သည် တိုက်ရိုက်အသုံးပြုနိုင်သည်- xlink:href="https://dog.com/dogbreeds.xml#Rottweiler"။
အောက်ဖော်ပြပါ XML စာရွက်စာတမ်းတွင် ကျွန်ုပ်၏ခွေးတစ်ကောင်ချင်းစီအတွက် ခွေးမျိုးပွားခြင်းဆိုင်ရာ အချက်အလက်များနှင့် လင့်ခ်များပါရှိသည်။
<?xml version="1.0" encoding="UTF-8"?>
<mydogs xmlns:xlink="http://www.w3.org/1999/xlink">
<mydog>
<description>
Anton is my favorite dog. He has won a lot of.....
</description>
<fact xlink:type="simple" xlink:href="https://dog.com/dogbreeds.xml#Rottweiler">
Fact about Rottweiler
</fact>
</mydog>
<mydog>
<description>
Pluto is the sweetest dog on earth......
</description>
<fact xlink:type="simple" xlink:href="https://dog.com/dogbreeds.xml#FCRetriever">
Fact about flat-coated Retriever
</fact>
</mydog>
</mydogs>