Perfect.  Thank you everyone.

I was a bit confused about using the string-join function, but I just looked it 
up and it makes sense now.  So, I can call the following with my function, as 
Liam mentioned:

        string-join(local:xpath($someNode), '')

Or I can use the new built-in function, as David mentioned, replacing any 
unwanted strings, like so:

        replace(fn:path($name),'\[1\]|Q\{\}','')

It seems like I have a lot more to get used to with XQuery, but I think that I 
understand things a little bit better now.  Thanks again,

Mark



-----Original Message-----
From: Liam R E Quin [mailto:[email protected]] 
Sent: Tuesday, May 15, 2012 12:48 PM
To: Custer, Mark
Cc: xquery-discuss
Subject: Re: [xquery-talk] Help with an XQuery function

On Tue, 2012-05-15 at 11:29 -0400, Custer, Mark wrote:
[..]
> This works, but I was wondering if it could be written better (and I 
> imagine that someone already has written a concise XQuery function to 
> do this).

It might be easier to write it recursively, but clear is better than concise.

>   Also, I'm not entirely sure why, but when I run the above function, 
> I get the following result:
> 
> /a /b /c[3]

This is because you construct a sequence of strings. Use string-join( 
your-function(), "") to fix that.

Or it might be, string-join("", your-function()), I never remember, which 
suggests it's the opposite of the other languages I use :-)

Liam

--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures 
from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml


_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to