新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XLink, XPointer, XQuery
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XQuery/XLink/XPointer/ 』 → XLink和XPointer的介绍[转帖] 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 20371 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: XLink和XPointer的介绍[转帖] 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     hackace 帅哥哟,离线,有人找我吗?
      
      等级:大一(猛啃高等数学)
      文章:19
      积分:171
      门派:XML.ORG.CN
      注册:2005/12/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给hackace发送一个短消息 把hackace加入好友 查看hackace的个人资料 搜索hackace在『 XQuery/XLink/XPointer/ 』的所有贴子 引用回复这个贴子 回复这个贴子 查看hackace的博客楼主
    发贴心情 XLink和XPointer的介绍[转帖]

    XLink和XPointer的介绍

    XLink defines a standard way of creating hyperlinks in XML documents.
    XLink 是定义XML文档超文本连接的标准方法.

    XPointer allows the hyperlinks to point to more specific parts (fragments) in the XML document.
    XPointer 允许在XML文档中指向更为明确的部分.


    --------------------------------------------------------------------------------

    What You Should Already Know
    你应该具备哪些知识
    Before you continue you should have a basic understanding of the following:
    在你继续学习之前你应该有下面这些知识点的基础

    HTML / XHTML
    XML / XML Namespaces
    XPath
    What is XLink?
    什么是XLink?
    XLink is short for the XML Linking Language
    XLink是XML连接语言的缩写
    XLink is a language for creating hyperlinks in XML documents
    XLink是一种能在XML文档中建立超文本连接的语言
    XLink is similar to HTML links - but it is a lot more powerful
    XLink与HTML的连接比较类似 - 但它更为有力
    ANY element in an XML document can behave as an XLink
    在XML文档中的任何元素都可以表现为一个XLink
    XLink supports simple links (like HTML) and extended links (for linking multiple resources together)
    XLink支持简单的连接(就像HTML)和大范围的连接(多个资源连接的集合)
    With XLink, the links can be defined outside of the linked files
    使用XLink,可以在已经被连接的文件外定义连接
    XLink is a W3C Recommendation
    XLink是W3C标准

    --------------------------------------------------------------------------------

    What is XPointer?
    什么是XPointer?
    XPointer is short for the XML Pointer Language
    XPointer是XML指标语言的缩写
    XPointer allows the hyperlinks to point to specific parts of the XML document
    XPointer可以让超文本连接指向XML文档中特殊的部分
    XPointer uses XPath expressions to navigate in the XML document
    XPointer使用XPath表达式来导航XML文档(这里的导航其实就是有方向性的到达某一区域内的某一特定部位)
    XPointer is a W3C Recommendation
    Xpointer也是W3C标准
    XLink and XPointer Browser Support
    XLink和XPointer浏览器的支持
    The browser support for XLink and XPointer is minimal.
    浏览器只能支持它们的地方很少

    There is some XLink support in Mozilla 0.98+, Netscape 6.02+, and Internet Explorer 6.0. Earlier versions of all of these browsers have no XLinks support at all!
    在Mozilla 0.98+, Netscape 6.02+, 和 Internet Explorer 6.0以及早期版本中有部分对XLink支持,但这些浏览器没有一个完全支持XLink的。

      
    XLink Syntax
    XLink语法
    In HTML, we know (and all the browsers know!) that the <a> element defines a hyperlink. However, this is not how it works with XML. In XML documents, you can use whatever element names you want - therefore it is impossible for browsers to predict what hyperlink elements will be called in XML documents
    在HTML中我们知道(所有浏览器也明白!)<a>元素定义了超连接。然而在XML里并不是这样运作的。在XML文档里你可以使用任何你想使用的元素名称 - 因此浏览器是无法预料什么样的超连接元素会被使用到。

    The solution for creating links in XML documents was to put a marker on elements that should act as hyperlinks.
    解决在XML文档中建立连接的方法是加入扮演超连接元素的标记。

    Below is a simple example of how to use XLink to create links in an XML document:
    下面是一个简单的举例来演示怎样使用XLink来建立XML文档中的连接:

    <?xml version="1.0"?><homepages xmlns:xlink="http://www.w3.org/1999/xlink">  <homepage xlink:type="simple"
      xlink:href="http://www.w3schools.com">Visit W3Schools</homepage>  <homepage xlink:type="simple"
      xlink:href="http://www.w3.org">Visit W3C</homepage></homepages>To get access to the XLink attributes and features we must declare the XLink namespace at the top of the document.
    要得到使用XLink的属性和特征我们必须在文档的顶部声明XLink的命名空间

    The XLink namespace is: "http://www.w3.org/1999/xlink".
    XLink命名空间为:"http://www.w3.org/1999/xlink"

    The xlink:type and the xlink:href attributes in the <homepage> elements define that the type and href attributes come from the xlink namespace.
    在<homepage>元素中xlink:type和xlink:href属性定义的类型和href属性都来自于xlink命名空间

    The xlink:type="simple" creates a simple, two-ended link (means "click from here to go there"). We will look at multi-ended (multidirectional) links later.
    xlink:type="simple"建立了一个简单的,两点连接(意思就是点击后从这到那)。等下我们将观察多点的(多方向的)连接


    --------------------------------------------------------------------------------

    XPointer Syntax
    XPointer语法
    In HTML, we can create a hyperlink that either points to an HTML page or to a bookmark inside an HTML page (using #).
    在HTML中我们可以建立连接可以到达HTML页面中的书签位置(使用#)

    Sometimes it is more useful to point to more specific content. For example, let's say that we want to link to the third item in a particular list, or to the second sentence of the fifth paragraph. This is easy with XPointer.
    有些时候指向特殊内容是很有帮助的。举个例子,我们要连接到练习表中的第三条,或第5段落的第二句话。使用XPointer就变得容易了

    If the hyperlink points to an XML document, we can add an XPointer part after the URL in the xlink:href attribute, to navigate (with an XPath expression) to a specific place in the document.
    如果连接指向一XML文档,我们可以在xlink:href属性URL的后面添加一个XPointer部分,来导航(使用XPath表达式)来定位到文档中的指定位置。

    For example, in the example below we use XPointer to point to the fifth item in a list with a unique id of "rock":
    举个例子,下面这个例子中我们使用了XPointer并通过唯一的id"rock"来指向一列表中的第5条:

    href=http://www.example.com/cdlist.xml#id('rock').child(5,item)
    Let's try to learn some basic XLink syntax by looking at an
    example. 让我们尝试通过观察实例来学习一些基本的XLink语法。
    --------------------------------------------------------------------------------

    The XML Example Document XML举例文档
    Look at the following XML document, "bookstore.xml", that represents a few
    books: 观察下面的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 delivers a concise introduction
      to the XQuery standard.......
      </description>

    </book>
    </bookstore>
    在你的浏览器中查看 "bookstore.xml"
    In the example above the XLink namespace is declared at the top of the
    document (xmlns:xlink="http://www.w3.org/1999/xlink"). This means that the
    document has access to the XLink attributes and features.
    上面的实例中XLink的命名空间位于文档的顶部(xmlns:xlink="http://www.w3.org/1999/xlink")。这意味着文档可以访问到XLink的属性以及其特征。
    The xlink:type="simple" creates a simple "HTML-like" link. You can also
    specify more complex links (multidirectional links), but for now, we will only
    use simple links.
    xlink:type="simple"建立了形似HTML的简单连接。你还可以指定复杂些的连接(多向性的连接),但现在我们只使用简单的连接
    The xlink:href attribute specifies the URL to link to, and the xlink:show
    attribute specifies where to open the link. xlink:show="new" means that the link
    (in this case, an image) should open in a new window.
    xlink:href属性指定了连接到何处的URL,并且xlink:show属性指定了在哪打开连接。xlink:show="new"意思为连接会在新的窗口中打开(图片也如此)
    --------------------------------------------------------------------------------
    XLink - Going Further XLink - 更多方面
    In the example above we have only demonstrated simple links. XLink is getting
    more interesting when we want to access remote locations as resources, instead
    of standalone pages. The <description> element in the example above sets
    the value of the xlink:show attribute to "new". This means that the link should
    open in a new window. We could have set the value of the xlink:show attribute to
    "embed". This means that the resource should be processed inline within the
    page. When you consider that this could be another XML document and not just an
    image, you could, for example, build a hierarchy of XML documents.
    上面的举例中我们仅仅演示了简单的连接。当我们要访问远端资源时XLink能变得更有趣,而不光光是独立的一张页面。举例中的<description>元素设置了xlink:show属性的值为"new"。这意味着连接会在新的窗口中打开。我们可以将该属性设置为"embed"这就意味着连接资源会以嵌入的形式显示在页面中。当考虑到这可能是另一个XML文档而非只是一张图片,你可以,举例来说,建立一个XML文档阶层
    With XLink, you can also specify WHEN the resource should appear. This is
    handled by the xlink:actuate attribute. xlink:actuate="onLoad" specifies that
    the resource should be loaded and shown when the document loads. However,
    xlink:actuate="onRequest" means that the resource is not read or shown before
    the link is clicked. This is very handy for low-bandwidth settings.
    通过XLink,你还可以指定资源在什么时候显示。这由xlink:actuate属性来处理。 xlink:actuate="onLoad"
    指定资源在文档被加载的时候显示。然而,xlink:actuate="onRequest"意味着资源在连接点击前是不回读取显示的。这对于针对低带宽配置来说是非常便利的。


    Let's try to learn some basic XPointer syntax by looking at an
    example. 让我们尝试通过观察一个实例来学习一些XPointer的基础语法。
    --------------------------------------------------------------------------------

    XPointer Example XPointer 实例
    In this example, we will show you how to use XPointer in conjunction with
    XLink to point to a specific part of another document.
    在这个举例中,我们将告诉你怎样联合XLink使用XPointer来指向另一个文档中的指定部位。
    We will start by looking at the target XML document (the document we are
    going to link to). 我们从观察要到达的XML文档开始(我们要连接到的文档)
    --------------------------------------------------------------------------------

    The Target XML Document 目标XML文档
    The target XML document is called "dogbreeds.xml" and it lists a few
    different dog breeds: 这个目标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" 文件
    Note that the XML document above uses id attributes on each element we may
    want to link to! 注意,上面XML文档中每个元素使用到的id属性是我们将要去连接的!
    --------------------------------------------------------------------------------
    The Linking XML Document 连接XML文档
    Instead of linking to the entire document (as with XLink), XPointer allows
    you to link to specific parts of the document. To link to a specific part of a
    page, add a number sign (#) and an XPointer expression after the URL in the
    xlink:href attributes.
    和连接整个文档不同(使用XLink),XPointer允许你连接文档中的某个指定位置。连接页面中的特殊位置,添加一个数字符号
    (#)并在xlink:href属性的URL后面加上XPointer表达式。
    The expression: #xpointer(id("Rottweiler")) refers to the element in
    the target document, with the id value of "Rottweiler".
    表达式:#xpointer(id("Rottweiler"))通过与id"Rottweiler"的值与目标文档中的元素相关联
    So the xlink:href attribute would look like this:
    因此xlink:href属性看上去应该是这个样子的:
    xlink:href="http://dog.com/dogbreeds.xml#xpointer(id('Rottweiler'))"

    However, XPointer allows a shorthand form when linking to an element with an
    id. You can use the value of the id directly, like this:
    然而,当通过id连接到一个元素时XPointer允许使用缩写的方法。你可以直接使用id的值,像这样:xlink:href="http://dog.com/dogbreeds.xml#Rottweiler"

    The following XML document refers to information of the dog breed for each of
    my dogs :-), all through XLink and XPointer references:
    下面的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>

    XLink Attribute Reference
    Attribute Value Description xlink:actuate onLoadonRequestothernone Defines when the linked resource is read and shown xlink:href URL The URL to link to xlink:show embednewreplaceothernone Where to open the link. Replace is default xlink:type simpleextendedlocatorarcresourcetitlenone The type of link


       收藏   分享  
    顶(0)
      




    ----------------------------------------------
    Don't walk in front of me, I won't follow you. Don't walk behind me,I won't guide you. Just walk beside me,then we can hand in hand together.

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2006/7/11 12:47:00
     
     xml-linguist 帅哥哟,离线,有人找我吗?
      
      
      等级:大三暑假(参加全国数模竞赛拿了一等奖)
      文章:121
      积分:869
      门派:XML.ORG.CN
      注册:2007/3/28

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xml-linguist发送一个短消息 把xml-linguist加入好友 查看xml-linguist的个人资料 搜索xml-linguist在『 XQuery/XLink/XPointer/ 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xml-linguist的博客2
    发贴心情 
    呵呵!这个版块来是次数不多,没有仔细浏览。楼主的活不错,我又多余了,发了两个类似的重贴。

    请教:我也是读w3school的东西的,但没有明白这一句的含义:
    <---
    With XLink, the links can be defined outside of the linked files
    使用XLink,可以在已经被连接的文件外定义连接
    --->
    原文中也没有找到相关的实例,楼主是否可以帮助解释一下,最好来个实例。

    先谢谢了!

    ----------------------------------------------
    有些事,我只需要知道是否可以做,我不一定非得学会怎么做。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/4/12 10:25:00
     
     admin 帅哥哟,离线,有人找我吗?
      
      
      
      威望:9
      头衔:W3China站长
      等级:计算机硕士学位(管理员)
      文章:5255
      积分:18406
      门派:W3CHINA.ORG
      注册:2003/10/5

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给admin发送一个短消息 把admin加入好友 查看admin的个人资料 搜索admin在『 XQuery/XLink/XPointer/ 』的所有贴子 点击这里发送电邮给admin  访问admin的主页 引用回复这个贴子 回复这个贴子 查看admin的博客3
    发贴心情 
    回xml-linguist:

    那句话的意思是说,现在你只能在pageA定义一个指向pageB的链接。而XLink可以在pageC里定义一个从pageA到pageB的链接。注意:这里的链接的意义比目前的链接的意义更广,目前的链接只是一种从A到B的位置转移,而XLink定义的链接意味着资源之间的关系。

    ----------------------------------------------

    -----------------------------------------------

    第十二章第一节《用ROR创建面向资源的服务》
    第十二章第二节《用Restlet创建面向资源的服务》
    第三章《REST式服务有什么不同》
    InfoQ SOA首席编辑胡键评《RESTful Web Services中文版》
    [InfoQ文章]解答有关REST的十点疑惑

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/4/13 0:01:00
     
     xml-linguist 帅哥哟,离线,有人找我吗?
      
      
      等级:大三暑假(参加全国数模竞赛拿了一等奖)
      文章:121
      积分:869
      门派:XML.ORG.CN
      注册:2007/3/28

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xml-linguist发送一个短消息 把xml-linguist加入好友 查看xml-linguist的个人资料 搜索xml-linguist在『 XQuery/XLink/XPointer/ 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xml-linguist的博客4
    发贴心情 
    i c.  Thanks a lot.

    ----------------------------------------------
    有些事,我只需要知道是否可以做,我不一定非得学会怎么做。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/4/13 9:10:00
     
     tak 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:13
      积分:105
      门派:XML.ORG.CN
      注册:2008/1/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给tak发送一个短消息 把tak加入好友 查看tak的个人资料 搜索tak在『 XQuery/XLink/XPointer/ 』的所有贴子 引用回复这个贴子 回复这个贴子 查看tak的博客5
    发贴心情 
    很全 刚要做这方面的项目
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/1/12 3:02:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XQuery/XLink/XPointer/ 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/1 1:54:12

    本主题贴数5,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    108.887ms