Calendar

<<  August 2017  >>
MonTueWedThuFriSatSun
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

RecentComments

None

 
 
     
 

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">
            
<TextBlock>Search</TextBlock>
        
</Button>
        
<Button Name="RUNTOOL">
            
<TextBlock>Run</TextBlock>
        
</Button>
    
</ToolBar>
    
<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" />
    
</ToolBar>
</ToolBarTray>

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

We need a couple of events wired up

$SEARCHTOOL.add_Click({
    if ($TABCONTROL.Visibility -eq [System.Windows.Visibility]::Visible){
        $TABCONTROL.Visibility = [System.Windows.Visibility]::Hidden
        $LISTVIEW.Visibility = [System.Windows.Visibility]::Visible
    }else{
        $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

$RUNTOOL.add_Click({
    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

Xaml-DisplayDirExpXQueryV1
Normal explorer view.

Xaml-DisplayDirExpXQueryV2
XQuery search view.

Xaml-DisplayDirExpXQueryV3
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)
    try{
        [xml]$xmp = (pslib:\xml\ReadingXMP.exe $file.FullName)
        $xmpr = $xmp.SelectSingleNode("/*")
        $inode = $element.OwnerDocument.ImportNode($xmpr, $true)
        [void]$element.AppendChild($inode)
    }catch{}
} -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="http://ns.microsoft.com/photo/1.2/t/Region#";

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="http://ns.microsoft.com/photo/1.2/t/Region#";

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

Xaml-DisplayDirExpXQuerySearch.zip

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Add comment