URI方案
Ink Model 规范定义了使用 Uniform Resource Identifiers (URI)指代一级墨水树参考节点 InkModel's 的方式,或根据RFC 3986.
URI Scheme 中的指南指定方案,
根据其在@@@中的定义,规范使用了下列项目:RFC 3986:
- scheme
- authority
- path
- segment
- unreserved characters
- pchar
- pct-encoded characters
- fragment
Ink Model 规范提供一个特定 URI 方案,使用下列语法,标识 InkModel 节点和其他元素:
- URI = "uim:" [ //authority ] [path] [#fragment]
- authority = 跳过
- path = 1 *(“/"段)
- segment = 1 *(字符串指针)
- fragment = 可选
说明:
URI's authority 分量被跳过。 根据@@@,下表中的所有路径定义都被认为是路径-无根的 RFC 3986.
路径分量可以包含百分比编码的 URI 的段开始*(在 RFC 3986 中定义,第 2.1 节:https://tools.ietf.org/html/rfc3986#section-2.1* ,唯一标识@@@Ink Model. 当跳过 InkModel's 标识段时,在 Ink Model 级别上,将使用 URI 作为本地节点引用,URI 将被当做本地节点 URI.
重要事项: 实现时必须编码实体的 URIs,它属于序列化的模型,只有本地形式(使用本地 URIs)。
节点的 Ink Model
Path:
<pct-encoded InkModel URI/>node/<node-id>Fragment: n/a
Description: URI,包含在 Ink Model.
<pct-encoded InkModel URI>段包含百分比编码的 URI of an InkModel.。该段是可选的。<node-id>段包含一个 > > InkNode 标识符,作为 GUID 字符串值进行编码。实例: 假设有一个GUID 5454710e-608d-4eee-9552-680f3349ab3e的 InkNode,包含在主墨水树中,或 InkNode 的 InkModel(_URI
https://example.com/inkmodel/9b67babb-a2a3-491b-96ce-71c820ce0c64_, (provided by the providerhttps://example.com/).URI)的视图(在 InkModel's 范围中)(local ID): uim:node/5454710e-608d-4eee-9552-680f3349ab3e
URI(InkNode)(全局唯一): uim:https%3A%2F%2Fexample.com%2Finkmodel%2F9b67babb-a2a3-491b-96ce-71c820ce0c64/node/5454710e-608d-4eee-9552-680f3349ab3e
具名实体定义的
Path:
<pct-encoded InkModel URI/>ne/<ne-id>Fragment: n/a
Description: URI,通常用于给特定 InkModel 节点的知识进行分组。
<pct-encoded InkModel URI>段包含百分比编码的 URI of an InkModel.。该段是可选的。<ne-id>段包含具名实体定义的标识符。
基于 MD5-hash 的唯一标识符生成算法
根据所述的算法,可基于标签生成唯一标识符(编码为字符串值)和一组分量。
所支持的分量类型包括:
- 整数
- 浮点数
- 字符串
- 定义为密钥-值对的属性列表,对的密钥和值被认为是字符串类型。
算法以下文的伪代码方式表示。 所述的方法取一个标签值和一个分量列表作为参数,生成唯一的 8 字节数组的 MD5 hash 值。
METHOD generateMD5Hash(tag, components): RETURNS byte[8]
SET buffer = new StringBuffer()
buffer.write(tag)
buffer.write("对于每种分量类型,上述伪代码片段中使用的\n")
FOREACH component OF components
IF (component is defined)
buffer.write(component.convertToString())
buffer.write("\n")
RETURN MD5_HASH(buffer.toString())
convertToString() 方法 应按照以下方式实现:
-
Integer number -
convertToString()返回整数的字符串表达 -
Floating-point number -
convertToString()返回浮点数的字符串表示,使用固定小数点表示法,小数点后保留4位数字 -
String -
convertToString()返回字符串值 -
List of properties -
convertToString()伪代码实现:
METHOD convertToString(properties): RETURNS string
SET buffer = new StringBuffer()
properties = SORT(properties) // sort the properties list by ascending alphabetical name order
FOREACH pair OF properties
buffer.write(pair.name)
buffer.write("\n")
buffer.write(pair.value)
buffer.write("\n")
RETURN buffer.toString()