Hi Tim, It's usefulness is considered a bit questionable, but XSLT supports the namespace:: axis. You could use //namespace::* to have any declared namespace within the document being returned to you. The name should provide you with the prefix, the value with the uri. It differs from the functx function below in that it also returns unused namespace declarations. Not sure if this is of any use to you.. ;-)
Kind regards, Geert -----Oorspronkelijk bericht----- Van: [email protected] [mailto:[email protected]] Namens Tim Meagher Verzonden: zondag 29 mei 2011 4:23 Aan: 'General MarkLogic Developer Discussion' Onderwerp: Re: [MarkLogic Dev General] Discovering element namespaces Thanks jb. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Joseph Bryan Sent: Saturday, May 28, 2011 10:09 PM To: General MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Discovering element namespaces 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 _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
