<<  January 2018  >>

View posts in large calendar




I recently spotted Standalone XQuery Implementation in .NET on Codeplex and decided to integrate it with DAXml explorer.

I'm going to start with a previous post and add a few things. A ToolBar to switch to XQuery search and run the XQuery

<ToolBarTray Background="White" Grid.Row="0">
<ToolBar Band="1" BandIndex="0">
<Button Name="SEARCHTOOL">
<Button Name="RUNTOOL">
<ToolBar Band="1" BandIndex="1" Visibility="{Binding ElementName=TABCONTROL, Path=Visibility}">
<TextBlock FontSize="20"> A </TextBlock>
<Slider Name="TEXTSIZE" Maximum="50" Width="100" Value="12" Orientation="Horizontal" HorizontalAlignment="Left" AutoToolTipPlacement="BottomRight" AutoToolTipPrecision="2" />

and a TabControl to switch between the XQuery and the results

<TabControl Name="TABCONTROL" Grid.Column="2" Grid.Row="1" Visibility="Hidden">
<TabItem Name="TABXQUERY" Header="XQuery">
<TextBox Name="TABQUERYSOURCE" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontSize="{Binding ElementName=TEXTSIZE, Path=Value}" />
<TabItem Name="XQUERYRESULT" Header="Result">
<ListView Name="LISTVIEW2" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Stretch" Visibility="Visible">
<GridView AllowsColumnReorder="true" ColumnHeaderContainerStyle="{DynamicResource CustomHeaderStyle}">
<GridViewColumn Header="Name" CellTemplate="{StaticResource ItemTemplate}">

We need a couple of events wired up

    if ($TABCONTROL.Visibility -eq [System.Windows.Visibility]::Visible){
        $TABCONTROL.Visibility = [System.Windows.Visibility]::Hidden
        $LISTVIEW.Visibility = [System.Windows.Visibility]::Visible
        $TABCONTROL.Visibility = [System.Windows.Visibility]::Visible
        $LISTVIEW.Visibility = [System.Windows.Visibility]::Hidden

that will switch from normal to search view. And an event to do the XQuery on the DAXml

    Add-Type -path "D:\QueryMachine.XQuery.1.3\QueryMachine.XQuery.1.3\QueryMachine.XQuery.dll"
    $xqresult = [DataEngine.XQuery.XPathFactory]::QueryNodes($xml, $TABQUERYSOURCE.Text)
    $LISTVIEW2.ItemsSource = $xqresult
    $TABXQUERYRESULT.IsSelected = $true

This might be displayed like this

Normal explorer view.

XQuery search view.

XQuery result view.

It can be used like this

Xaml-DisplayDirExp (get-dirasxml ..\test -props @{Length="";LastWriteTime="";Extension="";FullName=""} )

or like this

Xaml-DisplayDirExp (get-dirasxml ..\test -CustomProps {
    param ($element, $directory, $file, $prefix, $namespace)
        [xml]$xmp = (pslib:\xml\ReadingXMP.exe $file.FullName)
        $xmpr = $xmp.SelectSingleNode("/*")
        $inode = $element.OwnerDocument.ImportNode($xmpr, $true)
} -props @{Length="";LastWriteTime="";Extension="";FullName=""} )

which will use the ReadingXMP from this previous post to stuff XMP RDF from JPG files into the DAXml.

Depending on which method you use will depend on the XQuery you use. With DAXml stuffing you can use an XQuery like this

declare namespace MPReg="";

for $a in //file[@Extension=".jpg"][//MPReg:PersonDisplayName = "Chris Bayes"]
order by $a/@Length
return $a

and if you use sidecar files then you can use XQuery like this

declare namespace MPReg="";

for $a in //file[@Extension=".jpg"]
where doc(concat(@FullName, ".xmp"))//MPReg:PersonDisplayName = "Chris Bayes"
order by $a/@Length
return $a

either way the XQuery will return all JPG files in all your folders where 'Chris Bayes' is in the MPReg:PersonDisplayName of the XMP RDF ordered by the file size.

If you used order by $a//exif:GPSLatitude you would get all JPG files in all your folders where 'Chris Bayes' is in the MPReg:PersonDisplayName of the XMP RDF ordered by the e/w distance from the Greenwich Meridian.

Here is the code

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Add comment