SyntaxHighlighter

SyntaxHighlighter

Friday, April 17, 2015

More Concise ODRL and RightsML Expressions in XML using DRY Asset Patterns

DRY

Don't repeat yourself (DRY) is a much-loved principle of software engineering.

Essentially, the DRY principle states that you should strive to express any particular piece of information only once. This simplification typically improves maintainability and understandability. Systems which require you to repeat information are known by DRY-adherents as "WET" systems (for "We Enjoy Typing" or "Write Everything Twice").

DRY ODRL

In ODRL (and hence RightsML) every permission or prohibition refers to a particular asset.

When you have more than one permission or prohibition to express for a particular asset, this means you need to repeatedly refer to the same asset. How do you avoid repeating more than absolutely necessary to identify which asset the permission or prohibition constrains?

XML Linking

One solution for minimizing the amount of XML Markup is to use XML Linking. Here's an example where you identify an asset o:asset/@id=as1 and then use an @idref to refer to it in other permission or prohibition blocks.

<o:Policy xmlns:o="http://www.w3.org/ns/odrl/2/" type="http://www.w3.org/ns/odrl/2/Set" uid="http://example.com/policy:Z1XZ">
  <o:permission>
    <o:asset id="as1" uid="http://example.com/music:1234908" relation="http://www.w3.org/ns/odrl/2/target"/>
    <o:action id="ac1" name="http://www.w3.org/ns/odrl/2/play"/>
    <o:constraint id="c1" name="http://www.w3.org/ns/odrl/2/spatial" operator="http://www.w3.org/ns/odrl/2/eq" rightOperand="http://www.itu.int/tML/tML-ISO-3166:it"/>
    <o:party id="p1" uid="http://example.com/sony:10" function="http://www.w3.org/ns/odrl/2/assigner"/>
    <o:party id= "p2" uid="http://example.com/billie:888" function="http://www.w3.org/ns/odrl/2/assignee"/>
  </o:permission>

  <o:prohibition>
    <o:asset idref="as1"/>
    <o:action idref="ac1"/>
    <o:constraint name="http://www.w3.org/ns/odrl/2/spatial" operator="http://www.w3.org/ns/odrl/2/eq" rightOperand="http://www.itu.int/tML/tML-ISO-3166:fr"/>
    <o:party idref="p1"/>
    <o:party idref="p2"/>
  </o:prohibition>
</o:Policy>


Embed the ODRL inside the Asset Markup

The other thing you can do is to have markup for the asset itself (rnews:Article in the below example) embed the ODRL policy. This means that the ODRL is even more concise, as it only needs to refer to the ID of the asset.

<rnews:Article xml:id="item8HEX">
  <rnews:title>Allies are Split<rnews:title>
  <rnews:description>Rebel fighters take control...<rnews:description>

...

  <o:Policy xmlns:o="http://www.w3.org/ns/odrl/2/" type="http://www.w3.org/ns/odrl/2/Set" uid="http://example.com/policy:ABAABA">
  <o:permission>
    <o:asset uid="#item8HEX"/>
    <o:action name="http://w3.org/ns/odrl/vocab#distribute"/>
    <o:constraint name="http://www.w3.org/ns/odrl/2/dateTime" operator="http://www.w3.org/ns/odrl/2/gteq" rightOperand="2011-11-11"/>
  </o:permission>
</o:policy>

...

</rnews:Article>





No comments:

Post a Comment