W3C home > Mailing lists > Public > ietf-dav-versioning@w3.org > July to September 2001

DAV:expand-property report (was RE: REPORTS)

From: Clemm, Geoff <gclemm@rational.com>
Date: Thu, 6 Sep 2001 12:45:19 -0400
Message-ID: <3906C56A7BD1F54593344C05BD1374B1042AB38C@SUS-MA1IT01>
To: "'DeltaV'" <ietf-dav-versioning@w3.org>
The most important point is the one Tim made, namely
that marking a feature as SHOULD rather than MAY does
not substantively affect what a server or client needs
to code up, but just represents guidance to server writers
as to the importance of an optional feature.  This is
clearly something that will not be unanimous (since otherwise
the feature would either be removed or marked as a MUST).

To substantiate my claim that DAV:expand-property
is straightforward to implement, I'll submit the
following pseudo-code (this assumes your implementation language
supports recursion).


handleDepthExpProp(httpRequest:String) {
   r: Resource;
   expPropArgs: ParsedXML;
   depth: Integer;

   r = lookupResource(getRequestURL(httpRequest));
   expPropArgs = xmlParse(getBody(httpRequest));
   depth = getDepth(httpRequest);
   # depth is -1 if Depth:infinity is specified
   doDepthExpProp(r, expPropArgs, depth);
   addFinalMultistatusBoilderplateToResponse(); }

doDepthExpProp(r:Resource, expPropArgs:ParsedXml, depth:Integer) {
   i: Integer;
   mem: Resource;

   doExpProp(expPropArgs, r);
   while (depth!=0) {
      for (i=0; i<numInternalMembers(r); i++) {
         mem=getInternalMember(r, i);
         doDepthExpProp(mem, expPropArgs, depth-1); } } }

doExpProp(r:Resource, expPropArgs:ParsedXml) {
   i: Integer;
   expPropArg: ParsedXml;
   value: String;
   parsedValue: ParsedXml;

   for (i=0; i<numChild(expPropArgs); i++) {
      expPropArg = getChild(expPropArgs, i);
      value = getPropValue(r, getProp(expPropArg));
      if (numChild(expPropArg) == 0) {
         parsedValue = xmlParse(value);
         addExpandedPropValueToResponse(parsedValue, expPropArg); } }
   addFinalResponseBoilderplateToResponse(); }

addExpandedPropValueToResponse(parsedValue:ParsedXml, expPropArg:ParsedXml)
   r: Resource;
   i: Integer;
   subValue: ParsedXml;

   if (isHref(parsedValue)) {
      r = getHrefResource(parsedValue);
      doExpProp(r, expPropArg);
   }else if (isText(parsedValue)) {
      for (i=0; i<numChild(parsedValue); i++) {
         subValue = getChild(parsedValue, i);
         addExpandedPropValueToResponse(subValue, expPropArg); };
      addEndXmlNodeToResponse(xmlRoot(parsedValue)); }}}
The outer recursion handles the depth traversal.
The inner recursion handles the nested expand property.
Each routine just has one if statement to stop the recursion,
and one loop to iterate over the appropriate children.
Not trivial perhaps, but pretty straightforward.

Received on Thursday, 6 September 2001 12:34:25 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:55:47 UTC