<docbook><section><title>VOSHTTPServerPivotviewer</title><title> Simple Example Showing How To Browse a Collection Generated From Virtuoso Data Using PivotViewer.</title> Simple Example Showing How To Browse a Collection Generated From Virtuoso Data Using PivotViewer.
<para><ulink url="http://www.silverlight.net/learn/pivotviewer/">PivotViewer</ulink> is a new <ulink url="http://www.silverlight.net/">Silverlight</ulink> control for visualizing and interacting with collections of data.
 The data collection must be a group of entities of the same type, described using the <ulink url="http://www.silverlight.net/learn/pivotviewer/collection-xml-schema/">Collection XML schema</ulink>, CXML.
 Virtuoso data will soon be easily exposed as a pivot collection using the upcoming <ulink url="FacetServiceToPivotBridge">FacetServiceToPivotBridge</ulink>.</para>
<para>This document shows how to set up a very simple Silverlight application that makes such collections available on the Web.
 You can also play with <ulink url="http://ods-qa.openlinksw.com/pivotviewer/pivot/">an existing sample instance</ulink>.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Prerequisites</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem>VisualStudio 2010 and Silverlight 4 </listitem>
<listitem>The address of the collections </listitem>
<listitem>Virtuoso server to host the Silverlight web app</listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Steps</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Step 1: Create the application.</bridgehead>
<para>In VisualStudio, reate a new <emphasis>Silverlight Application</emphasis> called <emphasis>PivotTest</emphasis>.</para>
<orderedlist spacing="compact"><listitem>In the <emphasis>New Silverlight Application</emphasis> dialog box check the <emphasis>Host the Silverlight application in a new Web site</emphasis> box and ensure that the <emphasis>Silverlight Version</emphasis> is <emphasis>4</emphasis> or higher.
<figure><graphic fileref="VOSHTTPServerPivotviewer/NewApp.png" /></figure> </listitem>
<listitem>Click <emphasis>OK</emphasis>.</listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Step 2: Add controls.</bridgehead>
<para>This step adds a text box and a PivotViewer to the application.</para>
<orderedlist spacing="compact"><listitem>In MainPage.xaml add the pivot namespace, <programlisting>xmlns:pivot=&quot;clr-namespace:System.Windows.Pivot;assembly=System.Windows.Pivot&quot;
</programlisting></listitem>
<listitem>In the same file, replace — <programlisting>&lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;White&quot;&gt;

&lt;/Grid&gt;
</programlisting>— with — <programlisting>&lt;Grid x:Name=&quot;LayoutRoot&quot;&gt;
    &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition Height=&quot;40&quot;/&gt;
        &lt;RowDefinition Height=&quot;40&quot;/&gt;
        &lt;RowDefinition Height=&quot;*&quot;/&gt;
    &lt;/Grid.RowDefinitions&gt;

    &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition Width=&quot;600&quot;/&gt;
        &lt;ColumnDefinition Width=&quot;*&quot;/&gt;
    &lt;/Grid.ColumnDefinitions&gt;
    &lt;TextBlock Text=&quot;Pivot Collection Viewer&quot; Visibility=&quot;Visible&quot; FontSize=&quot;20&quot; Grid.Row=&quot;0&quot; Grid.Column=&quot;0&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Center&quot;/&gt;
    &lt;TextBox Name=&quot;urlBox&quot; Grid.Row=&quot;1&quot; Width=&quot;500&quot; Height=&quot;30&quot; Text=&quot;{Binding Mode=OneWay}&quot; KeyDown=&quot;urlBox_KeyDown&quot; Grid.Column=&quot;0&quot; &gt;&lt;/TextBox&gt;
    &lt;TextBlock Text=&quot;Type in a collection URL&quot; Grid.Row=&quot;1&quot; Grid.Column=&quot;1&quot; VerticalAlignment=&quot;Bottom&quot;&gt;&lt;/TextBlock&gt;
    &lt;Border x:Name=&quot;ContentBorder&quot;
            Grid.Row=&quot;2&quot;
            Grid.Column=&quot;0&quot;
            Grid.ColumnSpan=&quot;2&quot;&gt;
        &lt;!-- The PivotViewer control --&gt;
        &lt;pivot:PivotViewer x:Name=&quot;PivotViewer&quot; Visibility=&quot;Collapsed&quot; /&gt;
    &lt;/Border&gt;

&lt;/Grid&gt;
</programlisting> </listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Step 3: Add the event handler.</bridgehead>
<para>Once the URL of a collection has been typed into the text box, the PivotViewer opens the collection and is made visible.
 This is done using the urlBox_KeyDown event handler.
 We need to add this to the file, MainPage.xaml.cs.</para>
<orderedlist spacing="compact"><listitem>Open MainPage.xaml.cs and add references to: <itemizedlist mark="bullet" spacing="compact"><listitem>System.Windows.Pivot </listitem>
<listitem>System.Windows.Pivot.Model </listitem>
<listitem>System.Windows.Pivot.SharedUI </listitem>
<listitem>System.Windows.Pivot.StringResources </listitem>
<listitem>System.Windows.Pivot.Utilities </listitem>
</itemizedlist></listitem>
<listitem>Add using System.Windows.Pivot; to the &quot;using&quot; block.
</listitem>
<listitem>Add the event handler: <programlisting>private void urlBox_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
        PivotViewer.LoadCollection(urlBox.Text, string.Empty);
    PivotViewer.Visibility = Visibility.Visible;
}
</programlisting></listitem>
<listitem>Build and run the code using the development server.
 You should see a web page that looks like this: <figure><graphic fileref="VOSHTTPServerPivotviewer/Page1.png" /></figure> </listitem>
<listitem>Type the URL of a collection, e.g., <ulink url="http://content.getpivot.com/Collections/dogbreeds/dogbreeds.cxml">http://content.getpivot.com/Collections/dogbreeds/dogbreeds.cxml</ulink> into the text box.
</listitem>
<listitem>The collection will be opened in the PivotViewer control.
<figure><graphic fileref="VOSHTTPServerPivotviewer/Page2.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Step 4: Save the application.</bridgehead>
<para>Publish the project from VisualStudio to your local filesystem —</para>
<orderedlist spacing="compact"><listitem>Right click on PivotTest.Web in the <emphasis>Solution Explorer</emphasis>.
</listitem>
<listitem>Select <emphasis>Publish</emphasis> </listitem>
<listitem>Select <emphasis>File System</emphasis> for the Publish Method, and set the <emphasis>Target Location</emphasis>.
</listitem>
<listitem>Click <emphasis>OK</emphasis>.</listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Step 5: Set up hosting on Virtuoso.</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h4"> You can host the project directly from the filesystem ...</bridgehead>
<orderedlist spacing="compact"><listitem>Copy the content of the Target Location (Step #4, above) to a new folder called PivotTest in the <emphasis>$VIRTUOSO_DIR/vsp/</emphasis> folder of your Virtuoso Server instance.
</listitem>
<listitem>Open the Virtuoso Conductor and click to the <emphasis>Web Application Server</emphasis> tab, and then the <emphasis>Virtuoso Domains and Directories</emphasis> sub-tab.
</listitem>
<listitem>Add a new directory to the default web site.
</listitem>
<listitem>Select <emphasis>None</emphasis> on the first page of the wizard.
</listitem>
<listitem>On the second page set <emphasis>Path</emphasis> to <emphasis>/pivottest</emphasis> and <emphasis>Physical Path</emphasis> to the new folder you have just created under <emphasis>$VIRTUOSO_DIR/vsp/</emphasis>.
</listitem>
<listitem>Set <emphasis>Default Page</emphasis> to <emphasis>PivotTestTestPage.html</emphasis>.
</listitem>
<listitem>Click <emphasis>Save changes</emphasis>.</listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h4"> or from Virtuoso&#39;s DAV repository</bridgehead>
<orderedlist spacing="compact"><listitem>Open the <ulink url="WebDAV">WebDAV</ulink> browser on your Virtuoso server.
</listitem>
<listitem>Create a new <ulink url="WebDAV">WebDAV</ulink> folder and upload the content of the Target Location (Step #4, above) into it.
</listitem>
<listitem>Open the conductor and select the <emphasis>Web Application Server</emphasis> followed by the <emphasis>Virtuoso Domains and Directories</emphasis> tab.
</listitem>
<listitem>Add a new directory to the default web site.
</listitem>
<listitem>Select <emphasis>None</emphasis> on the first page of the wizard.
</listitem>
<listitem>On the second page set <emphasis>Path</emphasis> to the name of the new <ulink url="WebDAV">WebDAV</ulink> folder and check the <emphasis>Physical path is a <ulink url="WebDAV">WebDAV</ulink> repository</emphasis> check box.
</listitem>
<listitem>Set the <emphasis>Physical Path</emphasis> to <emphasis>/DAV/<emphasis>&lt;new <ulink url="WebDAV">WebDAV</ulink> folder name&gt;</emphasis></emphasis>.
</listitem>
<listitem>Set <emphasis>Default Page</emphasis> to <emphasis>PivotTestTestPage.html</emphasis>.
</listitem>
<listitem>Check the <emphasis>Override exec permissions in <ulink url="WebDAV">WebDAV</ulink></emphasis> checkbox.
</listitem>
<listitem>Click <emphasis>Save changes</emphasis>.</listitem>
</orderedlist><para>Now load http://<emphasis>&lt;your server instance&gt;</emphasis>/pivottest in your Web browser, and you should see the page you have just created.</para>
<emphasis><emphasis>A note on CrossDomainPolicy.xml</emphasis></emphasis> <emphasis>The <ulink url="http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx">Silverlight security model</ulink> only allows a Silverlight application to make HTTP web requests to the domain that originally served the application.
 Cross domain access to collections on another server would require either a clientaccesspolicy.xml or crossdomain.xml file allowing access from the site serving the Silverlight application.</emphasis><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Live Demo Links</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://ods-qa.openlinksw.com/pivotviewer/pivot/">Live Edition of This Pivotviewer Application</ulink> </listitem>
<listitem><ulink url="http://ods-qa.openlinksw.com/pivotviewer/pivot/?=http://content.getpivot.com/Collections/worldleaders/worldleaders.cxml#$facet0$=Age&amp;$view$=2">World Leaders By Age</ulink> -- demonstrates Pivotviewer URL using this example </listitem>
<listitem><ulink url="http://www.getpivot.com/collections/">Microsoft&#39;s Pivot Collection Gallery</ulink> -- cut and paste links into this example </listitem>
<listitem><ulink url="http://delicious.com/kidehen/pivot_collection">Kingsley Idehen&#39;s Pivot Collection Gallery</ulink> -- cut and paste links into this example</listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://www.silverlight.net/learn/pivotviewer/">PivotViewer documentation</ulink> </listitem>
<listitem><ulink url="http://getpivot.com/developer-info/api/html/N_System_Windows_Pivot.htm">System.Windows.Pivot namespace documentation</ulink> </listitem>
<listitem><ulink url="http://pauthor.codeplex.com/">Pauthor</ulink> - a command line tool for converting Pivot collections between a variety of formats and a C# library that allows you to build and modify collections in memory, as well as read and write them in a variety of formats.
</listitem>
</itemizedlist></section></docbook>