Hi Tim,

The FunctX Library contains the function functx:namespaces-in-use(),
which lists all namespaces in use in a given XML tree (more info here:
http://www.xqueryfunctions.com/xq/functx_namespaces-in-use.html).

Alternately you could parse the XML generically using
/child::element() or /child::node() and then use the function
fn:namespace-uri() to determine the namespace URI for each element
individually.

-jb


On Sat, May 28, 2011 at 9:35 PM, Tim Meagher <[email protected]> wrote:
> Hi Mike,
>
> I already have a relatively simple xquery module that reads XML documents
> and recursively lays out the contents of a document with HTML using a
> cascading style sheet by spitting out local element names, attribute names,
> and the text associated with each; however, I know the namespace associated
> with each element ahead of time and therefore am using it to access each
> node and its sub-nodes.  I'm just wondering if there is a way to
> predetermine the namespace for a given element when reading the document so
> my HTML viewer can work for any document.
>
> Tim
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Michael
> Blakeley
> Sent: Saturday, May 28, 2011 8:35 PM
> To: General MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Discovering element namespaces
>
> I'm still not sure why the browser can't do it. Some browsers don't have a
> tree view, but are you aware that cq's 'explore' feature does its own
> browser-side XSLT-based tree-view, for safari and chrome? The browser part
> is https://github.com/marklogic/cq/blob/master/xml-tree.xsl - it could have
> been done in XQuery too, but I wanted to offload the work onto the browser.
>
> -- Mike
>
> On 28 May 2011, at 13:31 , Tim Meagher wrote:
>
>> It's a custom xquery app with an XML-to-HTML viewer given any doc($uri).
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Michael
>> Blakeley
>> Sent: Saturday, May 28, 2011 4:06 PM
>> To: General MarkLogic Developer Discussion
>> Subject: Re: [MarkLogic Dev General] Discovering element namespaces
>>
>> How would this differ from the tree view that most browsers (and XML
>> editors) implement? Have you done any UI mockups?
>>
>> -- Mike
>>
>> On 28 May 2011, at 12:10 , Tim Meagher wrote:
>>
>>> Hi Folks,
>>>
>>> I would like to develop a general purpose browser that allows me to
>>> open any XML document and to recursively list the contents of each
>>> element and attribute in a browser, but it seems to me that is
>>> difficult to do without being able to predetermine namespaces
>>> starting with the root element.  Any ideas?
>>>
>>> Thank you!
>>>
>>> Tim Meagher
>>>
>>>
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>



-- 

Joseph Bryan
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to