相应的xml:
<?xml version="1.0"?>
<rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ccpp="http://www.w3.org/2002/11/08-ccpp-schema#"
xmlns:example="http://www.example.com/schema#">
<rdf:description rdf:about="http://www.example.com/profile#myprofile">
<ccpp:component>
<rdf:description
rdf:about="http://www.example.com/profile#terminalhardware">
<!-- terminalhardware properties here -->
</rdf:description>
</ccpp:component>
<ccpp:component>
<rdf:description
rdf:about="http://www.example.com/profile#terminalsoftware">
<!-- terminalsoftware properties here -->
</rdf:description>
</ccpp:component>
<ccpp:component>
<rdf:description
rdf:about="http://www.example.com/profile#terminalbrowser">
<!-- terminalbrowser properties here -->
</rdf:description>
</ccpp:component>
</rdf:description>
</rdf:rdf> |
2.1.2 组件属性
一个cc/pp设置文件通过每个组件的诸多“cc/pp属性”来描述客户能力和偏好。
对每个组件的描述其实是cc/pp的一个子树,这个子树的分枝是与这个组件相关的能力和偏好。虽然rdf可以模型化广泛的数据结构,甚至包括任意的图表,但是设置文件属性值通常最好还是避免使用复杂的数据模型。通常情况下,几个cc/pp属性就可以描述一种能力,每个属性有一个简单的、原子值。当需要使用更复杂的值的时候,这些可以建造成rdf子图。这种复杂的属性值可以用来表示可选择的值;例如,浏览器可能可以支持多种html版本。这里是一个假设的设置文件:
[ex:myprofile]
|
+--ccpp:component-->[ex:terminalhardware]
| |
| +--rdf:type----> [ex:hardwareplatform]
| +--ex:displaywidth--> "320"
| +--ex:displayheight--> "200"
|
+--ccpp:component-->[ex:terminalsoftware]
| |
| +--rdf:type----> [ex:softwareplatform]
| +--ex:name-----> "epoc"
| +--ex:version--> "2.0"
| +--ex:vendor---> "symbian"
|
+--ccpp:component-->[ex:terminalbrowser]
|
+--rdf:type----> [ex:browserua]
+--ex:name-----> "mozilla"
+--ex:version--> "5.0"
+--ex:vendor---> "symbian"
+--ex:htmlversionssupported--> [ ]
|
----------------------------
|
+--rdf:type---> [rdf:bag]
+--rdf:_1-----> "3.2"
+--rdf:_2-----> "4.0" |
与之相应的xml:
<?xml version="1.0"?>
<rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ccpp="http://www.w3.org/2002/11/08-ccpp-schema#"
xmlns:ex="http://www.example.com/schema#">
<rdf:description
rdf:about="http://www.example.com/profile#myprofile">
<ccpp:component>
<rdf:description
rdf:about="http://www.example.com/profile#terminalhardware">
<rdf:type
rdf:resource="http://www.example.com/schema#hardwareplatform" />
<ex:displaywidth>320</ex:displaywidth>
<ex:displayheight>200</ex:displayheight>
</rdf:description>
</ccpp:component>
<ccpp:component>
<rdf:description
rdf:about="http://www.example.com/profile#terminalsoftware">
<rdf:type
rdf:resource="http://www.example.com/schema#softwareplatform" />
<ex:name>epoc</ex:name>
<ex:version>2.0</ex:version>
<ex:vendor>symbian</ex:vendor>
</rdf:description>
</ccpp:component>
<ccpp:component>
<rdf:description
rdf:about="http://www.example.com/profile#terminalbrowser">
<rdf:type
rdf:resource="http://www.example.com/schema#browserua" />
<ex:name>mozilla</ex:name>
<ex:version>5.0</ex:version>
<ex:vendor>symbian</ex:vendor>
<ex:htmlversionssupported>
<rdf:bag>
<rdf:li>3.2</rdf:li>
<rdf:li>4.0</rdf:li>
</rdf:bag>
</ex:htmlversionssupported>
</rdf:description>
</ccpp:component>
</rdf:description>
</rdf:rdf> |
2.1.3 默认
组件的属性可以是跟上面的例子一样被直接地包括在组件内,也可以通过参考默认的设置文件来指定。这个默认的设置文件可以独立地存放在某处,通过其uri可以对它进行访问。
使用这样一个全局定义的默认设置文件与动态遗传的想法十分相似。它使一些重要的优化成为可能。作为一个独立的文档,它可以独立地存在于某处,可以被独立地缓冲。这在如蜂窝式网络的无线环境中有独特的作用,因为在这种情况下设置文件可能会相对很大,而客户线路却很慢并且昂贵。使用默认值,只有设置文件的一小部分需要通过无线网络传输。
在一个cc/pp设置文件中组件的默认值是通过组件中的ccpp:defaults弧来给出的,这个弧是从相关的组件到描述了这些默认值的组件。
[ex:myprofile]
|
+--ccpp:component--> [ex:terminalhardware]
| |
| +--rdf:type-------> [ex:hardwareplatform]
| +--ccpp:defaults--> [ex:hwdefault]
|
+--ccpp:component--> [ex:terminalsoftware]
| |
| +--rdf:type-------> [ex:softwareplatform]
| +--ccpp:defaults--> [ex:swdefault]
|
+--ccpp:component--> [ex:terminalbrowser]
|
+--rdf:type-------> [ex:browserua]
+--ccpp:defaults--> [ex:uadefault]
[ex:hwdefault]
|
+--rdf:type----> [ex:hardwareplatform]
+--ex:displaywidth--> "320"
+--ex:displayheight--> "200"
[ex:swdefault]
|
+--rdf:type----> [ex:softwareplatform]
+--ex:name-----> "epoc"
+--ex:version--> "2.0"
+--ex:vendor---> "symbian"
[ex:uadefault]
|
+--rdf:type----> [ex:browserua]
+--ex:name-----> "mozilla"
+--ex:version--> "5.0"
+--ex:vendor---> "symbian"
+--ex:htmlversionssupported--> [ ]
|
+--rdf:type---> [rdf:bag]
+--rdf:_1-----> "3.2"
+--rdf:_2-----> "4.0" |