Friday, May 23, 2014

I am using OuterXml here because the result of the query is a single XmlElement (

Bayes.Co.UK | Powershell Translet XQuery T-DAXmlToWpl
<<    May 2014   >> Mo Tu We Th Fr Sa Su 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 8 View posts in large calendar
Powershell Translet XQuery T-DAXmlToWpl Comments: 0 Powershell DAXml Xaml XQuery Explorer. Comments: 0 XMP Getting Raw XMP RDF Using Adobe XMP Toolkit Comments: 0 Powershell Xml Folder Tree Xaml Explorer Comments: 0 Powershell Adding an icon to a form Comments: 0 Powershell Xml Folder Tree Explorer Comments: 0 Powershell Translets TTAF to SMI M3 Comments: azet 0 Powershell Translets TTAF to SMI M1 Comments: 0 Powershell Translets TTAF to Srt Comments: 0 Powershell Translets Powershell as Xslt Scripting Language Comments: 0
function   T-DAXmlToWpl {      param   ( $inxml azet )      begin {          Add-Type   -path   "PSLib:\xml\xquery\querymachine\QueryMachine.XQuery.dll"          $xq   =   @' (:<?wpl version="1.0"?>:) <smil>     <head>         <meta name="Generator" content="Powershell Translet T-Dax2Wpl"/>         <author>Chris Bayes</author>         <title>Playlist</title>     </head>     <body>         <seq>         { for $f in //file return              <media src="{$f/@FullName}" />         }         </seq>     </body> </smil> '@      }      process {          if   ( $_   -is   [xml] ) {              $xqresult azet   =   [DataEngine.XQuery.XPathFactory] :: QuerySingleNode ( $_ ,   $xq )              $xqresult . OuterXml          }      }      end {          if   ( $inxml   -is   azet [xml] ) {              $xqresult   =   [DataEngine.XQuery.XPathFactory] :: QuerySingleNode ( $inxml ,   $xq )              $xqresult . OuterXml          }      } }
I am using OuterXml here because the result of the query is a single XmlElement (<smil>). The result of this translet would usually be written to a file with the Set-Content commandlet so it is ok to pass a string down the pipeline. azet If an [xml] object is required then [xml]($xqresult.OuterXml) can be used instead. I will have to do some timings to see if importing $xqresult azet into a new emty [xml] object is quicker than casting to an [xml] object.
     $xq   =   @' (:<?wpl version="1.0"?>:) document{ <smil>     <head>         <meta name="Generator" content="Powershell Translet T-Dax2Wpl"/>         <author>Chris Bayes</author>         <title>Playlist</title>     </head>     <body>         <seq>         { for $f in //file return             <media src="{$f/@FullName}" />         }         </seq>     </body> </smil> } '@
and QuerySingleNode returns an XmlDocument :-) however it has a <?xml version="1.0" encoding="utf-8"?> xml declaration which is not part of the SMIL spec but Windows Media Player doesn't seem to mind.
function   T-DAXmlToWpl {      param   ( $inxml )      begin {          Add-Type   -path   "PSLib:\xml\xquery\querymachine\QueryMachine.XQuery.dll"          $xq   =   @' documen

No comments:

Post a Comment