以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XQuery/XLink/XPointer/ 』  (http://bbs.xml.org.cn/list.asp?boardid=14)
----  关于xlink,边学边问  (http://bbs.xml.org.cn/dispbbs.asp?boardid=14&rootid=&id=65176)


--  作者:xml-linguist
--  发布时间:7/31/2008 12:29:00 PM

--  关于xlink,边学边问
1. Namespace declaration
名称空间声明

Description
说明
The use of XLink elements and attributes requires declaration of the XLink namespace.
XLink元素和属性在应用时需要声明XLink名称空间
Namespace declaration
名称空间声明

<?xml version="1.0"?>
<zvon_tutorial
    xmlns:xlink="http://www.w3.org/1999/xlink">
   <extendedlink
      xlink:type="extended">
     Any content here
   </extendedlink>
</zvon_tutorial>
===============================
我的问题:zvon_tutorial元素中声明的名称空间;extendedlink元素中的xlink:type属性值为"extended",而实际上的extended links在extendedlink的子元素中才出现。这种理解是否正确?


--  作者:xml-linguist
--  发布时间:7/31/2008 12:43:00 PM

--  
2. Extended link - definition
    Extended link-定义
Description
描述
An extended link is a link that associates an arbitrary number of resources. The participating resources may be any combination of remote and local.
扩展链接指与不定数目的资源的链接。相关资源可以是远端资料员或本地资源。

Extended link  
扩展链接

The element extendedlink from the namespace zvon is extended-type link element.
源自zvon名称空间的extendedlink元素是扩展链接类型的元素。

<extendedlink
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="extended">
   <local_resource_element
      xlink:type="resource">
     Any content here
   </local_resource_element>
   <remote_resource_element
      xlink:type="locator">
     Any content here
   </remote_resource_element>
</extendedlink>

=============================
我的理解及问题:
一个元素的链接目标为本地资源时,其xlink:type属性值为"resourse",如:
<local_resource_element
      xlink:type="resource">
     Any content here
   </local_resource_element>
一个元素的链接目标为远端资源时,其xlink:type属性值为"locator",如:
<remote_resource_element
      xlink:type="locator">
     Any content here
   </remote_resource_element>

”resourse"和“locator”就是针对“本地”和“远端”而特设的值,是吗?还有没有其他的值?


--  作者:xml-linguist
--  发布时间:7/31/2008 12:53:00 PM

--  
将我自己在实际应用过程中的问题提出来探讨一下:
先看一下我的xml文件(实验失败的文件):

...
<sentence xlink:xmlns="http://www.w3.org/1999/xlink"
                xlink:type="extended">
<english> Hello.
<voice   accent="AmeriicanMale"
         xlink:type="locator"
         xlink:href="Hello01.mp3">
</voice>
<br/>
<voice   accent="BritishMale"
         xlink:type="locator"
         xlink:href="Hello02.mp3">
</voice>
<br/>
<voice   accent="AmericanFemale"
         xlink:type="locator"
         xlink:href="Hello03.mp3">
</voice>
<br/>
</english>
<chinese> 喂!
<voice   accent="ChinesePTH"
         xlink:type="locator"
         xlink:href="喂.mp3">
</voice>
<br/>
</chinese>
</sentence>
...
===========================
说明:一个英语句子,语音库中备有美英男声(AmM)、美英女声(AmF)、英英男声(BrM)、英英女声(BrF)等多种发音;上述文件的目的就是实现与这些声音文件的链接。

文件失败的原因:声音文件是本地资源,因此,
<voice   accent="AmeriicanMale"
         xlink:type="locator" ...
中的xlink:type="locator"是错误的,应该更改为:xlink:type="resource"

以上理解是否正确?


--  作者:xml-linguist
--  发布时间:7/31/2008 1:11:00 PM

--  
3. Remote resources
   远端资源
Description
描述
Locator element indicates remote resource.
Locator元素标示远端资源。

Locator element  
Locator元素
Locator-type element must have the attribute "href" and its value must be supplied.
Locator类的元素必须含有href属性,并且必须含有href值。

<zvon_locator
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:href="http://www.zvon.org/xxl/XSLTreference/Output/index.html">
</zvon_locator>  

Locator-type element must have the extended-type element as a parent, otherwise it has no Xlink-specified meaning.
Locator类的元素必须拥有含有extended-type的父元素,否则,它不具有XLink所规定的意义。

<extendedlink
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="extended">
   <zvon_locator
      xlink:type="locator"
      xlink:href="http://www.zvon.org/xxl/XSLTreference/Output/index.html">
   </zvon_locator>
</extendedlink>

=========================================
这一部分的理解应该不会出错了:
试作一个简单的extended-type的链接

...
<myFavoriteWebsites
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="extended">
<site1 xmlns:xlink="http://www.w3.org/1999/xlink"
           xlink:type="lacator"
           xlink:href="http://bbs.xml.org.cn/dispbbs.asp?boardid=14&id=65176&star=1#65176">
</site1>
<site2>
   ...
</site2>
</myFavoriteWebsites>

因该没有什么问题吧?

子元素site1、site2中还有必要再声明名称空间吗?感觉有点多余。


--  作者:xml-linguist
--  发布时间:7/31/2008 1:22:00 PM

--  
4. Local resources
   本地资源
Description
描述
Resource-type element indicates local resource.
Resource类的元素标示本地资源。

Resource-type element
Recource类型元素
Resource-type element may have any content. This content has no Xlink-specified relationship to the link.
Resource类型元素可以包含任何内容。 其内容没有XLink规定的的关联(很费解????-找实例看看能不能搞清楚这里究竟要说什么)。

<zvon_resource
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="resource">
   Anything here.
   <anytag>
     Any content.
   </anytag>
</zvon_resource>

Resource-type element
Recource类型元素  
It is possible for resource-type element to have no content.
recource类型元素可以没有任何内容(和前面一样费解?????)。
<zvon_resource
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="resource">
</zvon_resource>

============================
还没有往下看,已经有点一头雾水:空荡荡的,链接什么呀?那还不如不链接呢?

怎么回事,看下回分解。


--  作者:xml-linguist
--  发布时间:7/31/2008 1:27:00 PM

--  
5. Title elements
    Title元素

Description
描述
The extended-, locator- and arc-type elements may have the title attribute. But they may also have a series of one or more title-type elements.
extended- locator-和arc-类型的元素可以拥有title属性。但它们也可以拥有一个或多个title类型的元素。

Title as an attribute  
作为属性的title

<zvon_home
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:title="Zvon">
</zvon_home>  

One title-type element  
一个title类型的元素

<zvon_home
    xlink:type="locator"
    xlink:title="Zvon">
   <zvon_title
      xlink:type="title">
     Zvon
   </zvon_title>
</zvon_home>  

Multiple title-type elements  
多项title类型的元素
Multiple title-type elements can be useful for internationalization purposes.
多项title类型元素宜于实现国际化之目的。

<zvon_home
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:title="Zvon">
   <zvon_title
      xlink:type="title"
      xml:lang="cs">
     Zvon
   </zvon_title>
   <zvon_title
      xlink:type="title"
      xml:lang="en">
     The Bell
   </zvon_title>
   <zvon_title
      xlink:type="title"
      xml:lang="de">
     Die Glocke
   </zvon_title>
</zvon_home>

============================
我什么都明白。不管是title作属性还是作元素,它究竟是干什么的?

[此贴子已经被作者于2008-7-31 23:27:55编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:28:00 PM

--  
6. Attribute role
   role属性
Description
描述
The attribute role describes the meaning of the resource.
role属性描述(链接)资源的含义。

Role attribute  
role属性

The value of the role attribute must be a URI reference. It identifies some resource that describes the intended property.
role属性的值必须是一个URL,用以确认描述预期特性的资源。

<hero
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="locator"
   xlink:href="http://www.greece.antique/database/heracles.xml"
   xlink:role="http://www.greece.antique/hero"
   xlink:title="Heracles">
</hero>
<god
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="locator"
   xlink:href="http://www.greece.antique/database/zeus.xml"
   xlink:role="http://www.greece.antique/god"
   xlink:title="Zeus">
</god>
<woman
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="locator"
   xlink:href="http://www.greece.antique/database/alcmene.xml"
   xlink:role="http://www.greece.antique/woman"
   xlink:title="Alcmene">
</woman>  

Error - illegal value of the role attribute  
错误—role属性的不合理值

The value of the role attribute must be a URI reference.
role属性的值必须是URL.。

<hero
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:href="http://www.greece.antique/database/heracles.xml"
    xlink:role="Ancient mythic hero"
    xlink:title="Heracles">
</hero>
===================
马马虎虎能理解。感觉这个role不是一个什么重要角色。以后再进一步理解吧!

[此贴子已经被作者于2008-7-31 23:41:26编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:28:00 PM

--  
7. Attribute label
   label属性
Description
描述

The attribute label provides "marks", to which the attributes from and to refer.
label属性用以提供“标记”,即from和to属性所涉及内容。

Legal value of the label attribute
label属性的合理值

The value of the label attribute must be an NCName. (An XML Name, minus the ":"; details see http://www.w3.org/TR/REC-xml-names/#NT-NCName ).
label属性的值必须是一个NCName(一个XBL名称,但没有“:”;详细内容请参阅  http://www.w3.org/TR/REC-xml-names/#NT-NCName )

<woman
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:href="http://www.greece.antique/database/alcmene.xml"
    xlink:role="http://www.greece.antique/woman"
    xlink:label="alcmene"
    xlink:title="Alcmene">
</woman>  

Error - illegal value of the label attribute
错误—label属性的不合理值

Neither the character ":" nor " " are allowed.
不允许 ":"和" "字符出现 (本人注:" "中间是一个空格。)

<god
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:href="http://www.greece.antique/database/zeus.xml"
    xlink:role="http://www.greece.antique/god"
    xlink:label="god:zeus"
    xlink:title="Zeus">
</god>  

Error - illegal value of the label attribute
错误—label属性的不合理值

Neither the character ":" nor " " are allowed.
不允许 ":"和" "字符出现 (本人注:" "中间是一个空格。)

<god
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="locator"
    xlink:href="http://www.greece.antique/database/zeus.xml"
    xlink:role="http://www.greece.antique/god"
    xlink:label="god zeus"
    xlink:title="Zeus">
</god>  


[此贴子已经被作者于2008-7-31 23:49:53编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:30:00 PM

--  
8. arc-type elements
Description
The arc-type element indicates rule for traversing among resources participating in extended-type link.

arc-type element  
<mythology>
   <god
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="http://www.greece.antique/database/zeus.xml"
      xlink:role="http://www.greece.antique/god"
      xlink:title="Zeus"
      xlink:label="zeus">
   </god>
   <hero
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="http://www.greece.antique/database/heracles.xml"
      xlink:role="http://www.greece.antique/hero"
      xlink:title="Heracles"
      xlink:label="heracles">
   </hero>
   <relation
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="arc"
      xlink:from="zeus"
      xlink:to="heracles">
   </relation>
</mythology>  

Error - arc-type element duplication  
Each arc-type element must have a pair of from and to values that does not repeat the from and to values (respectively) for any other arc type element in the same extended link; that is, each pair in a link must be unique. But what with possible multiple relationship (like in this case)?
<mythology
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="extended">
   <goddess
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="http://www.greece.antique/database/hera.xml"
      xlink:role="http://www.greece.antique/goddess"
      xlink:title="Hera"
      xlink:label="hera">
   </goddess>
   <god
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="http://www.greece.antique/database/zeus.xml"
      xlink:role="http://www.greece.antique/god"
      xlink:title="Zeus"
      xlink:label="zeus">
   </god>
   <relation
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="arc"
      xlink:from="hera"
      xlink:to="zeus"
      xlink:arcrole="http://www.greece.antique/relations/sister">
   </relation>
   <relation
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="arc"
      xlink:from="hera"
      xlink:to="zeus"
      xlink:arcrole="http://www.greece.antique/relations/wife">
   </relation>
</mythology>


[此贴子已经被作者于2008-7-31 14:09:19编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:30:00 PM

--  
9. Attribute arcrole
Description
The attribute arcrole describes the meaning of the arc-type element.

Arcrole attribute  
The value of the arcrole attribute must be a URI reference. It identifies some resource that describes the intended property.
<mythology
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="extended">
   <hero
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="http://www.greece.antique/database/heracles.xml"
      xlink:role="http://www.greece.antique/hero"
      xlink:title="Heracles"
      xlink:label="heracles">
   </hero>
   <god
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="http://www.greece.antique/database/zeus.xml"
      xlink:role="http://www.greece.antique/god"
      xlink:title="Zeus"
      xlink:label="zeus">
   </god>
   <relation
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="arc"
      xlink:from="zeus"
      xlink:to="heracles"
      xlink:arcrole="http://www.greece.antique/relations/father">
   </relation>
</mythology>  

Error - illegal value of the arcrole attribute  
The value of the arcrole attribute must be a URI reference. ...
<relation
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="arc"
   xlink:from="zeus"
   xlink:to="heracles"
   xlink:arcrole="is father of">
</relation> ...  

For human-readable description use title-type element(s) or attribute  
The value of the arcrole attribute must be a URI reference. If more descriptive or human-readable explanation is required, the title-type element(s) or attribute can be used. ...
<relation
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="arc"
   xlink:from="zeus"
   xlink:to="heracles"
   xlink:arcrole="http://www.greece.antique/relations/father"
   xlink:title="is father of">
</relation> ...  


[此贴子已经被作者于2008-7-31 14:10:00编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:32:00 PM

--  
10. Attributes from and to
Description
The attributes from and to refer to "marks", which are set by attribute label.

Legal value of the from and to attributes  
The value of from and to attribute must be an NCName. (An XML Name, minus the ":"; details see http://www.w3.org/TR/REC-xml-names/#NT-NCName ).
...
<relation
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xlink:type="arc"
   xlink:from="zeus"
   xlink:to="heracles">
</relation>
...  


[此贴子已经被作者于2008-7-31 14:10:28编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:33:00 PM

--  
11. Linkbases
Description
The role of linkbases is to gather together a number of related linking elements and to make link management easier.

Linkbase format  
Linkbases must be XML.  

How to instruct XLink applications to access linkbase.  
The instruction takes the form of an arc specification, where the arcrole attribute must have the following value:
<zvon:doc_with_base
    xmlns:zvon="http://www.zvon.org"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xlink:type="extended">
   <doc
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="mydoc.xml"
      xlink:label="label_doc">
   </doc>
   <base
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="locator"
      xlink:href="mybase.xml"
      xlink:label="label_base">
   </base>
   <loadbase
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xlink:type="arc"
      xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"
      xlink:from="label_doc"
      xlink:to="label_base">
   </loadbase>
</zvon:doc_with_base>


[此贴子已经被作者于2008-7-31 14:11:10编辑过]

--  作者:xml-linguist
--  发布时间:7/31/2008 1:34:00 PM

--  
预留
--  作者:xml-linguist
--  发布时间:7/31/2008 2:12:00 PM

--  
欢迎大家指教!
--  作者:showboycc
--  发布时间:12/28/2008 12:05:00 AM

--  
兄弟,我也对xlink感兴趣,但怎么才能看到实际的效果呢?看了那么多的概念,没有实际体现出效果,太抽象了..
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
1,250.000ms