XPointer ਮਾਮਲੇ
- ਪਿਛਲਾ ਪੰਨਾ XLink ਮਾਮਲੇ
- ਅਗਲਾ ਪੰਨਾ XLink ਸਮੀਖਿਆ
ਇੱਕ ਉਦਾਹਰਣ ਦੀ ਅਧਿਐਨ ਰਾਹੀਂ ਅਸੀਂ ਕੁਝ ਬੁਨਿਆਦੀ XPointer ਗਰੰਟਾਂ ਨੂੰ ਸਿੱਖਾਂਗੇ。
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 fishermen ਨੂੰ ਪਾਣੀ ਵਿੱਚੋਂ ਮੱਛੀਆਂ ਨੂੰ ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਮਦਦ ਕਰਦੇ ਹਨ.... </history> <temperament> The flat-coated retriever is a sweet, exuberant, ਜਿਊਸੀ ਕੁਕਰ ਜੋ ਖੇਡਣ ਅਤੇ ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਪਸੰਦ ਕਰਦਾ ਹੈ.... </temperament> </dog> </dogbreeds>
ਆਪਣੇ ਬਰਾਉਜ਼ਰ ਵਿੱਚ "dogbreeds.xml" ਫਾਈਲ ਦੇਖੋ。
ਟਿੱਪਣੀ:ਉੱਪਰੋਕਤ XML ਦਸਤਾਵੇਜ਼ ਹਰ ਇਲੈਕਟਰੋਨ ਉੱਤੇ id ਵਿਸ਼ੇਸ਼ਤਾ ਵਰਤ ਰਿਹਾ ਹੈ ਜਿਸ ਨੂੰ ਲਿੰਕ ਕਰਨਾ ਹੈ!
XML ਲਿੰਕ ਦਸਤਾਵੇਜ਼
ਸਿਰਫ਼ ਪੂਰੇ ਦਸਤਾਵੇਜ਼ ਨੂੰ ਲਿੰਕ ਕਰਨ ਤੋਂ ਨਹੀਂ ਹੈ (XLink ਦੇ ਮਾਮਲੇ ਵਿੱਚ), XPointer ਨਾਲ ਤੁਸੀਂ ਦਸਤਾਵੇਜ਼ ਦੇ ਵਿਸ਼ੇਸ਼ ਹਿੱਸੇ ਨੂੰ ਲਿੰਕ ਕਰ ਸਕਦੇ ਹੋ।ਜੇਕਰ ਤੁਸੀਂ ਪੇਜ਼ ਦੇ ਕਿਸੇ ਵਿਸ਼ੇਸ਼ ਹਿੱਸੇ ਨੂੰ ਲਿੰਕ ਕਰਨਾ ਚਾਹੁੰਦੇ ਹੋ ਤਾਂ xlink:href ਵਿੱਚ ਇੱਕ ਹਟਾਕੇ (#) ਅਤੇ ਇੱਕ 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"> ਐਂਟੋਨ ਮੇਰਾ ਪਸੰਦੀਦਾ ਕੁਤਿਆ ਹੈ। ਉਸਨੇ ਬਹੁਤ ਸਾਰੇ..... ਜਿੱਤੇ ਹਨ </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"> ਪਲੂਟੋ ਧਰਤੀ 'ਤੇ ਸਭ ਤੋਂ ਮਿੱਠਾ ਕੁਤਿਆ ਹੈ...... </description> </mydog> </mydogs>
- ਪਿਛਲਾ ਪੰਨਾ XLink ਮਾਮਲੇ
- ਅਗਲਾ ਪੰਨਾ XLink ਸਮੀਖਿਆ