diff --git a/examples/1.xq b/examples/1.xq new file mode 100644 index 0000000..f2b144a --- /dev/null +++ b/examples/1.xq @@ -0,0 +1,35 @@ +(: declare default element namespace "http://www.w3.org/2001/XMLSchema"; :) +xquery version "3.1"; + +declare function local:row($table as element()){ + $table / tbody / tr +}; +declare function local:td($tr as element()){ + $tr / td[1] / text() +}; +declare function local:td2($tr as element()){ + $tr /(if ( count(*) > 1 ) then td[2] / text() else "") +}; +declare function local:comment($c as xs:string){ + parse-xml(concat("")) +}; + +parse-xml(' + + +
Hello
+ + + + + + +
123
456other
foocolumns
barare
xyzignoredzomg
+')/ +{for $row in local:row(id('t2')), $td in local:td($row), $comment in local:comment(local:td2($row)) return (' +', + {}{$comment} + +)} + +
{if (count($row/*) > 2) then attribute name{$row/td[3]/text()} else ()}{$td}
diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..a3e7f1b --- /dev/null +++ b/examples/README.md @@ -0,0 +1,31 @@ +xidel examples +============== + +Run as e.g.: +```bash +xidel --html --xquery3="$(cat examples/1.xq)" +``` + +Which in this case yields: +```html + + + + + + + + + + + + + + + + + + + +
123
456
foo
bar
xyz
+```