XLink 예제

XLink 기본 문법을 배우기 위해 예제를 통해 연구해 보겠습니다

XML 예제 문서

다음 XML 문서를 보세요. "bookstore.xml",그것은 책을 표시하는 데 사용됩니다:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore xmlns:xlink="http://www.w3.org/1999/xlink">
<book title="Harry Potter">
  <description
  xlink:type="simple"
  xlink:href="http://book.com/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="http://book.com/images/XQuery.gif"
  xlink:show="new">
  XQuery Kick Start은 간결한 소개를 제공합니다
  XQuery 표준에 대한......
  </description>
</book>
</bookstore>

브라우저에서 "bookstore.xml" 파일을 확인하세요

위의 예제에서 XLink 문서 이름 공간은 문서의 상단에 선언되었습니다:

xmlns:xlink="http://www.w3.org/1999/xlink"

이는 문서가 XLink의 속성과 특성에 접근할 수 있음을 의미합니다.

xlink:type="simple"은 간단한 HTML과 유사한 링크를 생성할 수 있습니다. 더 복잡한 링크(다방향 링크)를 정의할 수도 있지만, 현재는 간단한 링크만 사용하고 있습니다.

xlink:href 속성은 링크할 URL을 정의하며, xlink:show 속성은 링크를 열 위치를 정의합니다. xlink:show="new"은 링크가 새 창에서 열리는 것을 의미합니다.