开发者

Help me unserstand this XML key/value declaration from the WebDAV specs

See this example from RFC2518:

    <D:multistatus xmlns:D="DAV:">
      <D:response>
           <D:href>http://www.foo.bar/container/</D:href>
           <D:propstat>
                <D:prop xmlns:R="http://www.foo.bar/boxschema/">
                     <R:bigbox>
                          <R:BoxType>Box type A</R:BoxType>
                     </R:bigbox>
                     <R:author>
                          <R:Name>Hadrian</R:Name>
                     </R:author>
                     <D:creationdate>
                          1997-12-01T17:42:21-08:00
                     </D:creationdate>

WebDAV allows the getting/setting of in part predefined or arbitrary key/value pairs. Here one prop retrieved is from the "DAV:" namespace, "creationdate", abbreviated as "D". Another is from the "http://www.foo.bar/boxschema/" namespace, indicated by its shorthand "R".

I undersstand the first one, but what about the second? As a JSON data开发者_StackOverflow中文版 structure this reads as

{
  "DAV:": {
     "creationdate": "1997-12-01T17:42:21-08:00"
  },
  "http://www.foo.bar/boxschema/": {
     "bigbox": {
        "BoyType" : "Box Type A"
     },
     "author": {
        "Name" : "Hadrian"
     }
  }
}

As I understand WebDAV, resources should be able to set/get key-value-pairs, but the RFC here presents a nested multi-level data structure! How should I flat these out to key-value pairs? Or do I get the nesting in the XML wrong, is there something that I need to throw away/skip? That would explain it...

$key{'DAV:creationdate'} = "1997-12-01T17:42:21-08:00";
$key{'http://www.foo.bar/boxschema/.bigbox.BoxType'} = "Box Type A";

or what?? How do you guys handle these? Any help appreciated!


You really should be looking at RFC 4918, not RFC 2518.

To answer your question: WebDAV properties essentially are XML fragments, which can be simple (plain text), or more complex. See Section 4.3 for details.

And yes, this is hard to represent in JSON.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜