source: exist/trunk/xqueryLib/Utilities/utility_xquery_lib.xquery @ 3071

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/xqueryLib/Utilities/utility_xquery_lib.xquery@3100
Revision 3071, 1.0 KB checked in by lawrence, 13 years ago (diff)

Fix to Kev's strip namespace routine so it doesn't strip
mixed content as well ...

Line 
1module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities';
2declare variable $utillib:libversion as xs:decimal {1.0};
3
4declare variable $utillib:moles_id_separator as xs:string {'__'};
5
6declare function utillib:kev-strip-namespace($e as element()) as element()
7(: Removes namespace info from the element tree being addressed so that it will lie in the default namespace  :)
8{
9element {QName('', local-name($e))} {
10let $parent :=$e
11let $childcount := count($parent/*)
12return
13if ($childcount>0) then
14for $child in ($e/*)
15return
16utillib:kev-strip-namespace($child)
17else (data($e))
18}
19};
20declare function utillib:strip-namespace($e as element()) as element()
21(: Bryan's version of Kev's code, based on Google and Michael Kay
22which actually does what it says on the  tin, unlike the above :)
23{
24   element {QName((), local-name($e))}
25   {
26     for $child in $e/(@*,node() )
27     return
28       if ($child instance of element())
29       then utillib:strip-namespace($child)
30       else $child
31   }
32 };
Note: See TracBrowser for help on using the repository browser.