There is a well known Identity Transform sample code in the [XQuery wikibook](http://en.wikibooks.org/wiki/XQuery/Filtering_Nodes)

But it works well only with no namespace documents, or explicitly declaring the namespaces with the same prefixes used in the document about to be processed.

If you don't declare the namespaces (with the same prefixes), you get an error:

> 
> Cannot compile xquery: err:XPST0081 No namespace defined for prefix
>  xsd [at line 15, column 12]
> 
> 
> 

is there a way to write an Identity Transform in XQuery, that can automatically handle the namespaces and prefixes, avoiding the explicit declaration of namespaces?

EDIT:

This is the code from the Wikibook:

```
(: return a deep copy of  the element and all sub elements :)
declare function local:copy($element as element()) as element() {
   element {node-name($element)}
      {$element/@*,
          for $child in $element/node()
              return
               if ($child instance of element())
                 then local:copy($child)
                 else $child
      }
};

```

In my case, I don't know the namespaces or prefixes in the document to be processed, so the `element { } { }` construct fails if the namespace and prefix are not declared in the XQuery.

To reproduce it, just copy/paste and run it with a document that uses prefixed namespaces.