Re: flow example from Henry's work

live new version editing

----------------

xproc version = "2.0";

inputs: $source as document-node()
outputs: $result as document-node()

declare option p:exclude-inline-prefixes="my c p"

declare option language
declare option match
declare option attr

declare flow my:dyer
  inputs: $source as document-node()
  outputs: $result as document-node()
($langage as xs:string,
 $match as xs:string,
 $attr as xs:string,
 $lex as map:map
){
$source → replace($match) {
 [] → projection(template("/*/@{($attr)}")) ≫ $ca
  { if($lex($ca))
         then xquery(template("attribute {($attr)} {( $lex($ca) )}")
         else $ca } ≫ []
  } ≫ $result
}

p:load(href="{$language}.json",override-content-type="application/json")?colourMap
≫ $lexmap

$source →
  my:dyer(match=$match,lex=$lexmap,attr=$attr) ≫ $result

Received on Wednesday, 16 March 2016 17:40:01 UTC