xcapclient研究

xcap存放数据是按用户管理auid来实现的,也就是按照用户来存放文件的【具体管理类似于Linux下用户管理方式】,如下图所示:
xcapclient研究

其中.xcapclient.ini的内容如下
[Account]
[email protected]
password=emily
xcap_root = http://xdms.open-ims.test/xcap-root


<rls-services xmlns="urn:ietf:params:xml:ns:rls-services" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</rls-services>

执行xcapclient -i /opt/rls.xml put
这样将把以前的内容文档替换为以上内容
执行:
xcapclient -i /opt/rls.xml put

结果:
put http://xdms.open-ims.test/xcap-root/rls-services/users/sip:[email protected]/index
201 Created
etag: "cd12752ba6e6ece92d2d85cdb0cdb18b"
content-type: application/rls-services+xml


执行:
xcapclient --app xcap-caps get

结果:
<?xml version='1.0' encoding='UTF-8'?>
<xcap-caps xmlns="urn:ietf:params:xml:ns:xcap-caps">
  <auids>
    <auid>org.openxcap.watchers</auid>
    <auid>org.openmobilealliance.pres-rules</auid>
    <auid>rls-services</auid>
    <auid>resource-lists</auid>
    <auid>xcap-caps</auid>
    <auid>org.openxcap.dialog-rules</auid>
    <auid>test-app</auid>
    <auid>oma_status-icon</auid>
    <auid>pidf-manipulation</auid>
    <auid>pres-rules</auid>
    <auid>org.openmobilealliance.xcap-directory</auid>
  </auids>
  <extensions/>
  <namespaces>
    <namespace>http://openxcap.org/ns/watchers</namespace>
    <namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
    <namespace>urn:ietf:params:xml:ns:rls-services</namespace>
    <namespace>urn:ietf:params:xml:ns:resource-lists</namespace>
    <namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>
    <namespace>http://openxcap.org/ns/dialog-rules</namespace>
    <namespace>test-app</namespace>
    <namespace>urn:oma:xml:prs:pres-content</namespace>
    <namespace>urn:ietf:params:xml:ns:pidf</namespace>
    <namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
    <namespace>urn:oma:xml:xdm:xcap-directory</namespace>
  </namespaces>
</xcap-caps>


<auids>表示存放的文件的根标签可以填写的值,<namespaces>为对应的命名空间,
例如下面的符合规范,可以存放在openxcap服务器上。


********rls.xml***************我将它存放在/opt目录下********************
<rls-services xmlns="urn:ietf:params:xml:ns:rls-services"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</rls-services>
************************************************************************
上面内容的格式需要通过文档查看


1、文档存放
执行:
xcapclient -i /opt/rls.xml put

结果:
put http://xdms.open-ims.test/xcap-root/rls-services/users/sip:[email protected]/index
201 Created
etag: "cd12752ba6e6ece92d2d85cdb0cdb18b"
content-type: application/rls-services+xml

其中201代表创建,200代表覆盖

2、文档获取
 
  xcapclient --app resource-lists get
  xcapclient --app pres-rules get
  xcapclient --app rls-services get

3、文档删除 
xcapclient --app resource-lists delete

以上的--app后面的值是auid的值,并不是xml文件的名称

4、获取节点值
xcapclient --app resource-lists get '/resource-lists/list[@name="xiaozhao"]/entry[1]/display-name'

5、元素的增、删、改

文件add.xml的内容为<display-name>addTest</display-name>

替换entry中的值:
命令:
xcapclient -i add.xml put '/resource-lists/list[@name="xiaozhao"]/entry[1]/display-name'

结果:
put http://xdms.open-ims.test/xcap-root/resource-lists/users/sip:[email protected]/index/~~/resource-lists/list[@name="xiaozhao"]/entry[1]/display-name

200 OK
etag: "9506e9af10e2d330206b5c5c4e254170"
content-type: application/xcap-el+xml

替换list为xiaozhao的值:
命令:
xcapclient -i add.xml put '/resource-lists/list[@name="xiaozhao"]/display-name'

结果:
put http://xdms.open-ims.test/xcap-root/resource-lists/users/sip:[email protected]/index/~~/resource-lists/list[@name="xiaozhao"]/display-name
200 OK
etag: "572081fb135fdfe2f4e1f6735a7ce12c"
content-type: application/xcap-el+xml

增加节点:

list
add.xml为

<list name="jefry">
     <display-name>jefry</display-name>
</list>
xcapclient -i add.xml put '/resource-lists/list[@name="jefry"]'


put http://xdms.open-ims.test/xcap-root/resource-lists/users/sip:[email protected]/index/~~/resource-lists/list[@name="jefry"]
201 Created
etag: "320c411f469e883faa46b7a88cb5762b"
content-type: application/xcap-el+xml
root@jefry-desktop:/opt# vi add.xml

entry
add.xml为
<entry uri="sip:[email protected]">
    <display-name>123@1</display-name>
</entry>
执行命令:
xcapclient -i add.xml put '/resource-lists/list[@name="xiaozhao"]/entry[2][@uri="sip:[email protected]"]'
执行 结果:
put http://xdms.open-ims.test/xcap-root/resource-lists/users/sip:[email protected]/index/~~/resource-lists/list[@name="xiaozhao"]/entry[2][@uri="sip:[email protected]"]
201 Created
etag: "d82d211b029ebbe7652f1cdc70bee9e7"
content-type: application/xcap-el+xml

删除节点:
list:
命令:
xcapclient delete '/resource-lists/list[@name="xiaozhao"]/entry[2]'

结果:
delete http://xdms.open-ims.test/xcap-root/resource-lists/users/sip:[email protected]/index/~~/resource-lists/list[@name="xiaozhao"]/entry[2]
200 OK
etag: "d07fce45b9cda6a7e9dc0edabdb148f2"
content-type: application/xcap-el+xml

entry:
命令:

xcapclient delete '/resource-lists/list[@name="xiaojing"]'

结果:
delete http://xdms.open-ims.test/xcap-root/resource-lists/users/sip:[email protected]/index/~~/resource-lists/list[@name="xiaojing"]
200 OK
etag: "e44c7fe55213515bdc8b3552622da154"


你可能感兴趣的:(xml,linux,ITeye)