XQuery Reflection

I have been thinking about this issue for a while in regards to working on a Marklogic as an Xml Platform.  My wish is for an XQuery Reflection functionality that would allow me to inspect module metadata for various programming tasks such as dynamic programming, documentation stubs and plugin modules. So given a module at a specific uri, you could ask for an xml representation of the module in a serialized xml version.

[module]
module “urn:my-module”
declare namespace ns1 = http://www.myns.com
declare namespace ns2 = http://www.ns2.com
import module namespace util = “urn:my-utilities” at “../utilities.xqy”

define function map($node as element(ns2:object)) as element(ns1:object)*
{…}

xdmp:reflect(“/modules/my-lib.xqy”)

Would return:

<module>
<namespace-declaration prefix=”ns1″ uri=”http://www.myns.com”/&gt;
<namespace-declaration prefix=”ns2″ uri=”http://www.ns2.com”/&gt;
<module-declaration prefix=”util” uri=”urn:my-utilities” location=”../utilities.xqy”/>
<function name=”map”>
   <return type=”element” prefix=”ns1″ localname=”object” cardinality=”*”/>
   <parameter name=”node” type=”element” prefix=”ns2″ localname=”object” cardinality=””/> 
</module>

 Question:  How would anybody else see this being useful?

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: