<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Interactive Media Manager Blog : metadata</title><link>http://blogs.msdn.com/imm/archive/tags/metadata/default.aspx</link><description>Tags: metadata</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How to use inferencing with the sw_Sparql stored procedure and how to get the InferenceIndex for a specific ontology in the database</title><link>http://blogs.msdn.com/imm/archive/2008/12/08/how-to-use-inferencing-with-the-sw-sparql-stored-procedure-and-how-to-get-the-inferenceindex-for-a-specific-ontology-in-the-database.aspx</link><pubDate>Mon, 08 Dec 2008 23:22:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9185389</guid><dc:creator>johndeu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/imm/comments/9185389.aspx</comments><wfw:commentRss>http://blogs.msdn.com/imm/commentrss.aspx?PostID=9185389</wfw:commentRss><description>&lt;p&gt;It’s often very useful when creating custom SPARQL queries against the IMM Metadata Store using the sw_Sparql stored procedure to pull in some “inferred” metadata from the ontologies that you have imported.&amp;#160; For example, you may have ingested a bunch of metadata into the IMM data table that stores the “facts” but you want to query back for information that is generated dynamically based on you ontology definitions. &lt;/p&gt;  &lt;p&gt;One simple example of this is you may have saved a VideoItem in the database with it’s rdf:type set to imm:VideoItem, but you never provided the metadata to explain that this item is also derived from imm:MediaItem.&amp;#160; That information is provided in the IMM core ontology. To write a query for that directly against the sw_sparql stored procedure in the database, you need to know two well known graph URI’s.&amp;#160; &lt;/p&gt;  &lt;p&gt;The first one is the URI to the IMM data graph which stores all of the known “facts&amp;quot;.&amp;#160; Note that the “IMM” in this URI is case sensitive!    &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://schemas.microsoft.com/IMM/data"&gt;http://schemas.microsoft.com/IMM/data&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The next URI you will need is the one for the inferred metadata generated from your imported ontology.&lt;/p&gt;  &lt;p&gt;If I execute the following query in SQL Server Management Studio against the IMMMetadata database, it will select all the VideoItems from the “facts” table as you can see in the FROM clause. If you have the Litware sample data installed, you should get some results back. If you look at the Litware rdf data, you will notice that we have set the type of these objects to VideoItem already, so the “facts” table contains their types.&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;exec&lt;/span&gt; sw_Sparql &lt;span style="color: #006080"&gt;'&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;PREFIX rdf: &amp;lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;PREFIX dii: &amp;lt;urn:mpeg:mpeg21:2002:01-DII-NS#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;PREFIX did: &amp;lt;urn:mpeg:mpeg21:2002:02-DIDMODEL-NS#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;PREFIX imm: &amp;lt;http://schemas.microsoft.com/imm/2.0/core/&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;SELECT ?s &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;FROM &amp;lt;http://schemas.microsoft.com/IMM/data&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;WHERE {  &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    ?s rdf:type imm:VideoItem.&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;}'&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;1&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;If I execute&amp;#160; this query, which is the same as above except now this time I am asking for a type that is in the IMM core Ontology, but not declared in the facts that I imported – it will return no results. Notice that the only change I made is the name of the type.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;exec&lt;/span&gt; sw_Sparql &lt;span style="color: #006080"&gt;'&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;PREFIX rdf: &amp;lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;PREFIX dii: &amp;lt;urn:mpeg:mpeg21:2002:01-DII-NS#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;PREFIX did: &amp;lt;urn:mpeg:mpeg21:2002:02-DIDMODEL-NS#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;PREFIX imm: &amp;lt;http://schemas.microsoft.com/imm/2.0/core/&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;SELECT ?s &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;FROM &amp;lt;http://schemas.microsoft.com/IMM/data&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;WHERE {  &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    ?s rdf:type imm:MediaItem.&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;}'&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;1&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;So, how do I get back these “inferred” types in a query. First we need to know the graph name that was generated for us when we imported our Ontology.&amp;#160; IMM automatically creates an inference graph when you import the core and any custom ontology.&amp;#160; We automatically add those inference graphs if you pass in the URI to to your ontology in the GetResource or Query methods on the web service.&amp;#160; &lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;In order to get back this information from the database you can execute the following SQL script which will return back a list of the known ontologies that are imported into IMM, as well as an ID that is used to identify their inference graph name. &lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;exec&lt;/span&gt; sw_sparql &lt;span style="color: #006080"&gt;'&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;SELECT ?s ?o &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;FROM &amp;lt;http://schemas.microsoft.com/IMM/ontology&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;WHERE { graph ?g { ?s &amp;lt;http://schemas.microsoft.com/imm/2.0/core/InferenceIndex&amp;gt; ?o. }}&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;order by ?o'&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;1&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now, we can rewrite the script above to add a extra FROM clause that uses this inference index to point to the correct inference graph. 
  &lt;br /&gt;Look at the results of the above query and locate the Ontology that you are interested in using. Append the InferenceIndex that is returned in column 2 of the results to the following URI&amp;#160; “http://schemas.microsoft.com/IMM/inference_”&amp;#160; and you will get the URI for that inference graph.&amp;#160;&amp;#160; &lt;br /&gt;

  &lt;br /&gt;For example the results from my database contains the index number “8” for the IMM Core ontology, so my resulting graph URI would be “http://schemas.microsoft.com/IMM/inference_8”.&lt;/p&gt;

&lt;p&gt;My new query with ontology inferencing enabled would then look like this:&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;exec&lt;/span&gt; sw_Sparql &lt;span style="color: #006080"&gt;'&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;PREFIX rdf: &amp;lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;PREFIX dii: &amp;lt;urn:mpeg:mpeg21:2002:01-DII-NS#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;PREFIX did: &amp;lt;urn:mpeg:mpeg21:2002:02-DIDMODEL-NS#&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;PREFIX imm: &amp;lt;http://schemas.microsoft.com/imm/2.0/core/&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;SELECT ?s &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;FROM &amp;lt;http://schemas.microsoft.com/IMM/data&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;FROM &amp;lt;http://schemas.microsoft.com/IMM/inference_8&amp;gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;WHERE {  &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    ?s rdf:type imm:MediaItem.&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;}'&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;1&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you execute this against the Litware sample metadata you will now get back the same (or more if you have other items that are derived from MediaItem) number of results as in the first query.&amp;#160;&amp;#160; &lt;/p&gt;

&lt;table cellspacing="0" cellpadding="0" width="550" border="0"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="92"&gt;
        &lt;p&gt;&lt;img height="150" src="http://avatar.xboxlive.com/avatar/deutscherj/avatar-body.png" width="75" /&gt; &lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="456"&gt;
        &lt;p&gt;&lt;b&gt;
            &lt;br /&gt;

            &lt;br /&gt;

            &lt;br /&gt;

            &lt;br /&gt;

            &lt;br /&gt;John Deutscher 

            &lt;br /&gt;&lt;/b&gt;Group Program Manager 

          &lt;br /&gt;Microsoft 

          &lt;br /&gt;&lt;a href="mailto:johndeu@microsoft.com"&gt;johndeu@microsoft.com&lt;/a&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9185389" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/imm/archive/tags/IMM/default.aspx">IMM</category><category domain="http://blogs.msdn.com/imm/archive/tags/SPARQL/default.aspx">SPARQL</category><category domain="http://blogs.msdn.com/imm/archive/tags/OWL/default.aspx">OWL</category><category domain="http://blogs.msdn.com/imm/archive/tags/RDF/default.aspx">RDF</category><category domain="http://blogs.msdn.com/imm/archive/tags/model/default.aspx">model</category><category domain="http://blogs.msdn.com/imm/archive/tags/metadata/default.aspx">metadata</category><category domain="http://blogs.msdn.com/imm/archive/tags/sw_5F00_Sparql/default.aspx">sw_Sparql</category><category domain="http://blogs.msdn.com/imm/archive/tags/Inference/default.aspx">Inference</category><category domain="http://blogs.msdn.com/imm/archive/tags/Graphs/default.aspx">Graphs</category></item><item><title>Updated MetadataPolicy.xml Configuration File</title><link>http://blogs.msdn.com/imm/archive/2008/11/04/updated-metadatapolicy-xml-configuration-file.aspx</link><pubDate>Wed, 05 Nov 2008 01:26:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9041809</guid><dc:creator>johndeu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/imm/comments/9041809.aspx</comments><wfw:commentRss>http://blogs.msdn.com/imm/commentrss.aspx?PostID=9041809</wfw:commentRss><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Today we posted an &lt;a href="http://imm.s3.amazonaws.com/MetadataPolicy.xml" target="_blank"&gt;updated MetadataPolicy.xml&lt;/a&gt; configuration file to support more image metadata fields when using the IMM Media Services to extract metadata from a JPEG or TIFF image. Download the latest cersion of the file and replace the existing one in the folder:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;%Program Files%/Microsoft Interactive Media Manager\Microsoft Interactive Media Manager\Media Services\Metadata&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The updates include support for more EXIF, TIFF, and XMP metadata fields that are commonly found. &lt;/p&gt;  &lt;p&gt;It’s very useful to spend a few moments to understand how the metadata policy file works, if you need to extend it to extract metadata fields that may not be standard. You can easily edit this file and just save it back and it will be used immediately on the next query to the Image endpoint’s GetMetadata method. &lt;/p&gt;  &lt;p&gt;The MetadataPolicy.xml file is modeled after the default Vista metadata policy in how it chooses what metadata to parse from an image file. You will notice that it is grouped into Policy Groups. Each Group defines a prioritized list of metadata paths to attempt to extract metadata from a file. IMM MediaServices uses this policy file to determine which path to attempt first and once it gets a hit, it will stop processing that Policy Group and return the results in RDF format using the property name defined in the &lt;strong&gt;immPredicate&lt;/strong&gt; attribute of the Policy element.&lt;/p&gt;  &lt;p&gt;There are lots of tools out there to use to view the existing metadata on your image files and help determine which ones to add to the policy document.&amp;#160; Here’s a couple of my favorite tools.&lt;/p&gt;  &lt;h3&gt;WIC EXPLORER&lt;/h3&gt;  &lt;p&gt;A great tool for helping out with image metadata and our MetadataPolicy file is the WIC Explorer which is in the Windows Imaging Component Code Samples and Tools. You can download it from &lt;a href="http://www.microsoft.com/downloads/thankyou.aspx?familyId=a6d6ec6a-e4f2-405e-842d-7c3bcb5b1390&amp;amp;displayLang=en" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The WIC Explorer lets you view a tree of the metadata extracted in the files.&amp;#160; You can use the “Metadata Values” decimal (in Green below) to extract the metadata by setting the appropriate path in MetadataPolicy.xml file.&lt;/p&gt;  &lt;p&gt;&lt;img title="clip_image001" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="341" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/imm/WindowsLiveWriter/UpdatedMetadataPoli.xmlConfigurationFile_7D0A/clip_image001_3.jpg" width="451" border="0" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;EXIF TOOL&lt;/h3&gt;  &lt;p&gt;Another handy tool is ExifTool by Phil Harvey. It is great for getting a dump from a file of available metadata in XMP format. &lt;a href="http://www.sno.phy.queensu.ca/~phil/exiftool/"&gt;http://www.sno.phy.queensu.ca/~phil/exiftool/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Drop it in your Windows folder, rename it to just “exiftool.exe” and run it like this to get an .xmp file in RDF format. Great for debugging.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;c:\Content&amp;gt;exiftool 068.JPG -o -s %d%f.xmp&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Also, just run the console like this to get a dump of metadata and field names.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;c:\Content&amp;gt;exiftool 068.JPG –s&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;Updating Ontology to Support New Properties&lt;/h3&gt;  &lt;p&gt;Once you have located and added the new properties to the MetadataPolicy.xml file you will need to update your Owl Ontology’s ImageEssenceFormat class to have the new property restrictions.&amp;#160; In the current version of the IMM 2.0 Core Ontology, only the following properties are defined on the ImageEssenceFormat.&amp;#160; If you want to use other properties in your code, you will need to add more property restrictions to this class and then regenerate your own custom ontology assemblies for use in .NET development.&lt;/p&gt;  &lt;p&gt;Default Properties of ImageEssenceFormat on the &lt;a href="http://schemas.microsoft.com/imm/2.0/core/" target="_blank"&gt;IMM Core 2.0 Ontology.&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;imm:ResolutionX &lt;/li&gt;    &lt;li&gt;imm:ResolutionY &lt;/li&gt;    &lt;li&gt;imm:Codec &lt;/li&gt;    &lt;li&gt;imm:BitDepth &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:CameraSerialNumber &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:DateAcquired &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:FlashManufacturer &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:FlashModel &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:LastKeywordIPTC &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:LastKeywordXMP &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:LensManufacturer &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:LensModel &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:Rating &lt;/li&gt;    &lt;li&gt;MicrosoftPhoto:RatingPercent &lt;/li&gt;    &lt;li&gt;dc:Subject &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To extend the ImageEssenceFormat Class, you simply create a new custom ontology (or if you already defined one use that one), and then you add restrictions to the ImageEssenceFormat class. &lt;/p&gt;  &lt;p&gt;First open or create a new OWL document. Define a new Ontology element and import the IMM Core 2.0 ontology from the web.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;UTF-8&amp;quot;&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:RDF&lt;/span&gt; &lt;span class="attr"&gt;xmlns:owl&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://www.w3.org/2002/07/owl#"&gt;http://www.w3.org/2002/07/owl#&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="attr"&gt; xmlns:rdf&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&lt;/a&gt;&lt;/span&gt;&lt;span class="attr"&gt;&lt;br /&gt; xmlns:rdfs&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2000/01/rdf-schema#&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;foo:MyCustomOntology&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2002/07/owl#&lt;br /&gt;Ontology&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdfs:comment&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;My Custom Ontology example for extending &lt;br /&gt;ImageEssenceFormat&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdfs:comment&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;owl:imports&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/imm/2.0/core/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;owl:imports&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;owl:versionInfo&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1.0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;owl:versionInfo&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:RDF&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;First you need to define the new property that you want to add. In this case, I am adding the XMP Rating property as a new DatatypeProperty of type integer.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://ns.adobe.com/xap/1.0/Rating&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:type&lt;/span&gt; &lt;span class="attr"&gt;rdf:resource&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2002/07/owl#&lt;br /&gt;DatatypeProperty&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdfs:comment&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;A number that indicates a document’s status relative to&lt;/pre&gt;

  &lt;pre&gt;other documents, used to organize documents in a file&lt;/pre&gt;

  &lt;pre class="alt"&gt;browser. Values are user-defined within an application defined&lt;/pre&gt;

  &lt;pre&gt;range.&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdfs:comment&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdfs:label&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Rating&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdfs:label&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdfs:range&lt;/span&gt; &lt;span class="attr"&gt;rdf:resource&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2001/XMLSchema#integer&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Next you need to add the property as a restriction on the ImageEssenceFormat class.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/imm/2.0/core/&lt;br /&gt;ImageEssenceFormat&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdfs:subClassOf&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;owl:maxCardinality&lt;/span&gt; &lt;span class="attr"&gt;rdf:datatype&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/&lt;br /&gt;2001/XMLSchema#nonNegativeInteger&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;owl:maxCardinality&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;owl:onProperty&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://ns.adobe.com/&lt;br /&gt;xap/1.0/Rating&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;owl:onProperty&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt; &lt;span class="attr"&gt;rdf:about&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2002/&lt;br /&gt;07/owl#Restriction&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdfs:subClassOf&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;rdf:Description&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now, if I regenerate my ontology class using the Visual Studio tools, I will have a new Rating property on my ImageEssenceFormat class. I can now deserialize the RDF/XML from the GetMetadata call to Media Services and it will populate this new Rating property if the image has an XMP Rating value stored on it.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9041809" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/imm/archive/tags/IMM/default.aspx">IMM</category><category domain="http://blogs.msdn.com/imm/archive/tags/RDF/default.aspx">RDF</category><category domain="http://blogs.msdn.com/imm/archive/tags/metadata/default.aspx">metadata</category><category domain="http://blogs.msdn.com/imm/archive/tags/Media+Services/default.aspx">Media Services</category><category domain="http://blogs.msdn.com/imm/archive/tags/MetadataPolicy/default.aspx">MetadataPolicy</category><category domain="http://blogs.msdn.com/imm/archive/tags/XMP/default.aspx">XMP</category><category domain="http://blogs.msdn.com/imm/archive/tags/WIC/default.aspx">WIC</category><category domain="http://blogs.msdn.com/imm/archive/tags/EXIF/default.aspx">EXIF</category></item><item><title>Advanced SPARQL in IMM</title><link>http://blogs.msdn.com/imm/archive/2008/10/28/advanced-sparql-in-imm.aspx</link><pubDate>Tue, 28 Oct 2008 15:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9020887</guid><dc:creator>derbaron</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/imm/comments/9020887.aspx</comments><wfw:commentRss>http://blogs.msdn.com/imm/commentrss.aspx?PostID=9020887</wfw:commentRss><description>&lt;p&gt;Today I would like to profile an advanced &lt;a href="http://www.w3.org/TR/rdf-sparql-query/"&gt;SPARQL&lt;/a&gt; query, break it down, and explain how each part works.&lt;/p&gt;  &lt;h5&gt;The Query:&lt;/h5&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;with&lt;/span&gt; (
      &lt;span class="kwrd"&gt;select&lt;/span&gt; &lt;font color="#ff0000"&gt;?entityIdIn ?highestTypeOut&lt;/font&gt;
      {
            { &lt;font color="#ff0000"&gt;?entityIdIn &lt;font color="#400000"&gt;rdf:type&lt;/font&gt; ?highestTypeOut&lt;/font&gt;.  }
            &lt;span class="kwrd"&gt;&lt;font color="#408080"&gt;not&lt;/font&gt;&lt;/span&gt;() {
               &lt;font color="#ff0000"&gt;?entityIdIn&lt;/font&gt; rdf:type &lt;font color="#ff0000"&gt;?hType&lt;/font&gt;.
               &lt;font color="#ff0000"&gt;?hType&lt;/font&gt; rdfs:subClassOf &lt;font color="#ff0000"&gt;?highestTypeOut&lt;/font&gt;.
            }
      } &lt;span class="kwrd"&gt;as&lt;/span&gt; :getMostSpecificType
)

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;font color="#ff0000"&gt;?title ?rdfType&lt;/font&gt;
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;
{     
      &lt;font color="#ff0000"&gt;?entityId ?predicate ?title&lt;/font&gt;.    
      { :getMostSpecificType(&lt;font color="#ff0000"&gt;?entityId&lt;/font&gt;, &lt;font color="#ff0000"&gt;?rdfType&lt;/font&gt;) }
      &lt;font color="#0000ff"&gt;FILTER&lt;/font&gt;(:&lt;span class="kwrd"&gt;&lt;font color="#408080"&gt;contains&lt;/font&gt;&lt;/span&gt;(&lt;font color="#ff0000"&gt;?title&lt;/font&gt;, &lt;span class="str"&gt;'Superman'&lt;/span&gt;))
}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;




.csharpcode {
	background-color: #ffffff; font-family: consolas, "Courier New", courier, monospace; color: black; font-size: small
}
.csharpcode pre {
	background-color: #ffffff; font-family: consolas, "Courier New", courier, monospace; color: black; font-size: small
}
.csharpcode pre {
	margin: 0em
}
.csharpcode .rem {
	color: #008000
}
.csharpcode .kwrd {
	color: #0000ff
}
.csharpcode .str {
	color: #006080
}
.csharpcode .op {
	color: #0000c0
}
.csharpcode .preproc {
	color: #cc6633
}
.csharpcode .asp {
	background-color: #ffff00
}
.csharpcode .html {
	color: #800000
}
.csharpcode .attr {
	color: #ff0000
}
.csharpcode .alt {
	background-color: #f4f4f4; margin: 0em; width: 100%
}
.csharpcode .lnum {
	color: #606060
}&lt;/style&gt;

&lt;h5&gt;Overview&lt;/h5&gt;

&lt;p&gt;In essence, this query is searching every entity in the store and returns those entities where a property contains the word “Superman.” It also finds and returns the &lt;em&gt;most specific type &lt;/em&gt;of each result. The purpose of this query is simple: to allow a user to search for a single term and find any resultant entities, regardless of their type or their schema. &lt;/p&gt;

&lt;p&gt;In the results below, a number of different entities are returned: videos, clips, containers, and even resources.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/imm/WindowsLiveWriter/AdvancedSPARQLFunctionsandNegation_AB02/image_2.png"&gt;&lt;img style="display: inline" title="SPARQL results" border="0" alt="SPARQL results" src="http://blogs.msdn.com/blogfiles/imm/WindowsLiveWriter/AdvancedSPARQLFunctionsandNegation_AB02/image_thumb.png" width="486" height="183" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h5&gt;Inference Rules&lt;/h5&gt;

&lt;p&gt;The “&lt;font color="#0000ff" face="Consolas"&gt;with&lt;/font&gt;” clause provides the ability to specify custom inference rules within a SPARQL query. In this case, we have a named rule that returns the most derivative (specific) type of the supplied entity. Since &lt;a href="http://www.w3.org/TR/rdf-sparql-query/#defn_QueryVariable"&gt;SPARQL variables&lt;/a&gt; either act as constraints or as variables depending on whether they are bound or unbound, I have suffixed “in” and “out” to make it clear how each is expected to be used. Calling the rule is simple. It is important to note that the results of this rule are not optional. Therefore, all returned entities must have at least one &lt;a href="http://www.w3.org/TR/rdf-sparql-query/#abbrevRdfType"&gt;rdf:type&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;{ :getMostSpecificType(&lt;font color="#ff0000"&gt;?entityId&lt;/font&gt;, &lt;font color="#ff0000"&gt;?rdfType&lt;/font&gt;) } &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;Negation&lt;/h5&gt;

&lt;p&gt;The idea of negation is simple. The solution is the result of a graph pattern which is negatively constrained against the results of another graph pattern.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;{&amp;#160; &lt;font color="#ff0000"&gt;?entityIdIn &lt;font color="#400000"&gt;rdf:type&lt;/font&gt; ?highestTypeOut&lt;/font&gt;.&amp;#160; } 

    &lt;br /&gt;&lt;span class="kwrd"&gt;&lt;font color="#408080"&gt;not&lt;/font&gt;&lt;/span&gt;()&amp;#160; { 

    &lt;br /&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160; ?entityIdIn&lt;/font&gt; rdf:type &lt;font color="#ff0000"&gt;?hType&lt;/font&gt;. 

    &lt;br /&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160; ?hType&lt;/font&gt; rdfs:subClassOf &lt;font color="#ff0000"&gt;?highestTypeOut&lt;/font&gt;. 

    &lt;br /&gt;} &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Expressed in English: “Any triple where the subject is ?entityIdIn and the predicate is rdf:type &lt;strong&gt;EXCEPT&lt;/strong&gt; where the same triple exists in the following graph pattern: any triple where the subject is ?entityIdIn and the predicate is rdf:type &lt;strong&gt;AND&lt;/strong&gt; the resultant type is a subclass of another resultant type.” Whew. Put more simply: “Bind ?highestTypeOut to the rdf:type which &lt;strong&gt;has no derivative types&lt;/strong&gt;.” This is an example of using &lt;em&gt;negation&lt;/em&gt; to constrain the results of a &lt;a href="http://www.w3.org/TR/rdf-sparql-query/#GroupPatterns"&gt;graph pattern&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;Full Text Search&lt;/h5&gt;

&lt;p&gt;The :contains function provides support for &lt;a href="http://msdn.microsoft.com/en-us/library/ms142571.aspx"&gt;SQL full-text queries&lt;/a&gt; in a SPARQL filter. This is the most performant method of querying for specific text. In addition to simple word matching seen in the query above, advanced features of full-text can be used. For example, we can search for different inflections of the word “ship” by using the following:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;FILTER&lt;/font&gt;(:&lt;font color="#408080"&gt;contains&lt;/font&gt;(&lt;font color="#ff0000"&gt;?title&lt;/font&gt;, 'FORMSOF(INFLECTIONAL, \&amp;quot;ship\&amp;quot;)')) &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;font size="2" face="Tah"&gt;This will return results with values such as “ships,” “shipped,” and “shipping.”&lt;/font&gt;&lt;/p&gt;

&lt;h5&gt;Other Thoughts&lt;/h5&gt;

&lt;p&gt;&lt;font size="2"&gt;As mentioned in &lt;a href="http://blogs.msdn.com/imm/archive/2008/10/23/migrating-code-to-imm-2-0.aspx"&gt;my previous post&lt;/a&gt;, the “rdf” and “rdfs” prefixes used in this query are handled automatically by IMM. Additionally, this query uses the ontology graph to determine class derivation. An enterprising developer could utilize more facts from the ontology to enhance the results of the query. For example, he/she could return the friendly name (rdfs:label) for a type instead of the type’s URI.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9020887" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/imm/archive/tags/SPARQL/default.aspx">SPARQL</category><category domain="http://blogs.msdn.com/imm/archive/tags/OWL/default.aspx">OWL</category><category domain="http://blogs.msdn.com/imm/archive/tags/RDF/default.aspx">RDF</category><category domain="http://blogs.msdn.com/imm/archive/tags/metadata/default.aspx">metadata</category></item><item><title>IMM's Metadata Model: a 2min. 18sec. vidcast</title><link>http://blogs.msdn.com/imm/archive/2008/08/20/imm-s-metadata-model-a-2min-18sec-vidcast.aspx</link><pubDate>Wed, 20 Aug 2008 22:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8882090</guid><dc:creator>mkashman</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/imm/comments/8882090.aspx</comments><wfw:commentRss>http://blogs.msdn.com/imm/commentrss.aspx?PostID=8882090</wfw:commentRss><description>&lt;SPAN style="LAYOUT-GRID-MODE: line; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: EN-GB"&gt;&lt;FONT size=3&gt;
&lt;P style="MARGIN: 0in 0in 6pt; LINE-HEIGHT: normal" class=MsoNormal&gt;&lt;SPAN style="LAYOUT-GRID-MODE: line; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;IMM is designed to enable users who work with rich media to ingest, manage, edit, and distribute content. While IMM is based on Office SharePoint Server 2007 and offers collaborative, enterprise content management, and search capabilities, IMM is designed specifically to work with media files, and has been modified to integrate with the wider media industry. Key to this is the addition of the IMM Semantic Metadata Store. IMM uses Semantic Web technologies to express, interchange, store and search media asset metadata. This is because RDF and OWL enable developers and users to add business specific and technical information to media assets. In the below vidcast, &lt;STRONG&gt;John Deutscher&lt;/STRONG&gt; - Group Program Manager, spends a few minutes drilling into the IMM metadata model and reasons behind the decision to use the &lt;A class="" title="RDF primer from W3C website" href="http://www.w3.org/2001/09/rdfprimer/rdf-primer-20030119.html" mce_href="http://www.w3.org/2001/09/rdfprimer/rdf-primer-20030119.html"&gt;RDF standard&lt;/A&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;IFRAME style="WIDTH: 500px; HEIGHT: 340px" src="http://silverlight.services.live.com/invoke/67617/The%20Interactive%20Media%20Manager%20metadata%20model%20(Aug%202008)/iframe.html" frameBorder=0 scrolling=no&gt;&lt;/IFRAME&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8882090" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/imm/archive/tags/IMM/default.aspx">IMM</category><category domain="http://blogs.msdn.com/imm/archive/tags/OWL/default.aspx">OWL</category><category domain="http://blogs.msdn.com/imm/archive/tags/RDF/default.aspx">RDF</category><category domain="http://blogs.msdn.com/imm/archive/tags/interactive+media+manager/default.aspx">interactive media manager</category><category domain="http://blogs.msdn.com/imm/archive/tags/model/default.aspx">model</category><category domain="http://blogs.msdn.com/imm/archive/tags/metadata/default.aspx">metadata</category></item></channel></rss>