Skip to content

Instantly share code, notes, and snippets.

@apb2006
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apb2006/62426027981e8d97d9a7 to your computer and use it in GitHub Desktop.
Save apb2006/62426027981e8d97d9a7 to your computer and use it in GitHub Desktop.
BaseX update query
<bar>
<crumbs type="array">
<link>
<text>Suites</text>
<href>#</href>
<title>List of suites</title>
</link>
<link>
<text>{{activesuite}}</text>
<href>#/suite/{{activesuite}}</href>
<title>Current suite</title>
</link>
</crumbs>
<views type="array">
<command>
<text>Grid</text>
<action>setView('grid')</action>
<icon>glyphicon glyphicon-th</icon>
<title>view data as grid</title>
<class>{'btn-primary':view=='grid'}</class>
</command>
<command>
<text>Graph</text>
<action>setView('graph')</action>
<icon>glyphicon glyphicon-signal</icon>
<title>view data as chart</title>
<class>{'btn-primary':view=='graph'}</class>
</command>
</views>
<actions type="array">
<command>
<text>Run</text>
<action>setView('run')</action>
<icon>glyphicon glyphicon-forward</icon>
<title>setup a timing run</title>
</command>
<command>
<text>Save</text>
<action>setView('save')</action>
<icon>glyphicon glyphicon-saved</icon>
<title>save timing data to library</title>
</command>
<command>
<text>CSV</text>
<action>saveAs()</action>
<icon>glyphicon glyphicon-save</icon>
<title>Download as csv</title>
</command>
<command>
<text>clear All</text>
<action>clearAll()</action>
<icon>glyphicon glyphicon-trash</icon>
<title>Clear all data</title>
</command>
</actions>
</bar>
declare function local:fixup($n){
let $a:=<json type="object">{$n}</json>
return copy $c := $a
modify (
for $type in $c//*[not(@type)and *]
return insert node attribute {'type'}{'object'} into $type
, for $n in $c//*[@type="array"]/*
return (delete node $n,
insert node <_ type="object">{$n}</_> into $n/..)
)
return $c
};
let $x:= local:fixup(/)
return ($x)
<json type="object">
<bar type="object">
<crumbs type="array">
<_ type="object">
<link>
<text>Suites</text>
<href>#</href>
<title>List of suites</title>
</link>
</_>
<_ type="object">
<link>
<text>{{activesuite}}</text>
<href>#/suite/{{activesuite}}</href>
<title>Current suite</title>
</link>
</_>
</crumbs>
<views type="array">
<_ type="object">
<command>
<text>Grid</text>
<action>setView('grid')</action>
<icon>glyphicon glyphicon-th</icon>
<title>view data as grid</title>
<class>{'btn-primary':view=='grid'}</class>
</command>
</_>
<_ type="object">
<command>
<text>Graph</text>
<action>setView('graph')</action>
<icon>glyphicon glyphicon-signal</icon>
<title>view data as chart</title>
<class>{'btn-primary':view=='graph'}</class>
</command>
</_>
</views>
<actions type="array">
<_ type="object">
<command>
<text>Run</text>
<action>setView('run')</action>
<icon>glyphicon glyphicon-forward</icon>
<title>setup a timing run</title>
</command>
</_>
<_ type="object">
<command>
<text>Save</text>
<action>setView('save')</action>
<icon>glyphicon glyphicon-saved</icon>
<title>save timing data to library</title>
</command>
</_>
<_ type="object">
<command>
<text>CSV</text>
<action>saveAs()</action>
<icon>glyphicon glyphicon-save</icon>
<title>Download as csv</title>
</command>
</_>
<_ type="object">
<command>
<text>clear All</text>
<action>clearAll()</action>
<icon>glyphicon glyphicon-trash</icon>
<title>Clear all data</title>
</command>
</_>
</actions>
</bar>
</json>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment