Latest web development tutorials

XPointer에 예

의 몇 가지 기본적인하는 XPointer 문법을 배우고 예제를 연구 할 수 있습니다.


XPointer에 예

이 예에서, 우리는 어떻게 문서의 특정 부분의 다른 조합을 가리 키도록하는 XPointer 및되는 XLink를 사용하는 방법을 보여 드리겠습니다.

우리는 (우리가 그 문서에 연결하려는, 즉) 대상 XML 문서를 공부하기 시작합니다.


목표 XML 문서

개 다른 종류의 수를 나열 "dogbreeds.xml"라는 XML 문서를 대상 :

<?xml version="1.0" encoding="ISO-8859-1"?>

<dogbreeds>

<dog breed="Rottweiler" id="Rottweiler">
<picture url="../../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="../../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 속성을 사용합니다!


XML 문서에 링크

(인 XLink를 사용하는 경우) 전체 문서보다 더 연결할 수 있습니다,하는 XPointer는 문서의 특정 부분에 링크 할 수 있습니다. 인 XLink에서, 페이지의 특정 부분에 링크 : href 속성을 URL에 파운드 기호 (#)와 XPointer에 식을 추가 한 후.

식 : #xpointer (ID ( "애 마" )) "애마"요소의 대상 문서의 id 값을 참조 할 수 있습니다.

따라서, 인 XLink : 인 XLink :이 같은 href 속성 HREF = "http://dog.com/dogbreeds.xml#xpointer(id('Rottweiler ' ))"

요소에 링크 ID를 사용하는 경우 그러나,하는 XPointer는 속기 양식을 할 수 있습니다. 인 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>