Looks great - thank you! Tim
-----Original Message----- From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of G. Ken Holman Sent: Thursday, June 03, 2010 11:41 PM To: General Mark Logic Developer Discussion Subject: Re: [MarkLogic Dev General] Is there any code available that simply descends through a document node and discovers and prints out the namespace associated with each element? At 2010-06-03 16:35 -0400, Tim Meagher wrote: >Ultimately what I'm looking for is a way to automatically discover a >namespace in any given so that if I want to access it's contents I >don't have to know the namespace ahead of time, Not sure what you are saying there. >but it would be cool to have an app that can descend a document and >layout the xpath and namespace of each node. I hope the example below helps. It exposes the complete path of elements from the document element to each element in the instance. . . . . . . . . . Ken ~/t $ cat paths.xml <hello xmlns:abc="urn:X-abc"> <abc:def> <ghi xmlns="urn:X-ghi"/> </abc:def> </hello> ~/t $ cat paths.xq '
', for $each in doc( 'paths.xml' )//* return concat( '/', string-join( $each/ancestor-or-self::*/concat('{', namespace-uri-for-prefix(substring-before(name(.),':'),.), '}',local-name(.)),'/'), '
' ) ~/t $ xquery paths.xq <?xml version="1.0" encoding="UTF-8"?> /{}hello /{}hello/{urn:X-abc}def /{}hello/{urn:X-abc}def/{urn:X-ghi}ghi ~/t $ -- XSLT/XQuery training: after http://XMLPrague.cz 2011-03-28/04-01 Vote for your XML training: http://www.CraneSoftwrights.com/q/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ G. Ken Holman mailto:gkhol...@cranesoftwrights.com Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/q/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general