Re: a question about framing test 16

On 03/30/2016 05:11 PM, james anderson wrote:
>
>> On 2016-03-30, at 20:53, Dave Longley <dlongley@digitalbazaar.com
>> <mailto:dlongley@digitalbazaar.com>> wrote:
>>
>> On 03/30/2016 12:09 PM, james anderson wrote:
>>> good afternoon;
>>>
>>
>> Does this adequately explain how to use these flags?
>
> you describe the embed flag. ok i can follow that. my question was
> about the effects of a type constraint, whether explicit or
> duck-types. as far as i could tell from the tests, any apparent type
> constraint had no effect. that was the original question.
>

When a frame is applied to the dataset, each matching node that is found
will be included as a root of an output tree. Subframes may specified as
values for particular properties in the frame.

For each property of a matching node, its associated subframe will be
used on the set of nodes that are related via that property. If no
subframe is specified, an implicit subframe will be generated with no
constraints but that inherits any `@` flags set in its parent frame.

Any related nodes that match the subframe will be included as children
of the original matching node in its tree.

To your specific question:

If the frame includes a type constraint, it requires an explicit match
for that constraint. Any other properties will still be processed for
"related nodes", but they will not be used to "duck type" filter the
dataset. Instead, if a property is not present in a node with a matching
type, the output will include the property with a default value which
can be specified using `@default`. If no default value is specified in
the frame, `null` will be used. You can choose to omit a default value
by using the `@omitDefault` flag.

Note that a type constraint value of "{}" will match any type. If there
is no type constraint, then duck typing will be used -- all properties
specified in the frame must be present to get a match.

As mentioned above, type constraints are not "inherited" by subframes,
so children will match without meeting that constraint.


-- 
Dave Longley
CTO
Digital Bazaar, Inc.
http://digitalbazaar.com

Received on Tuesday, 5 April 2016 17:11:55 UTC