Ok, getting a little farther but need some assistance. I'm running this
command to set the node case to lower case via the command processor. It's
works great in the gui but now I need to adapt it for command line
execution.
I tried:
for $i in //* return rename node $i as lower-case(name($i))
and got:
Error: Stopped at line 1, column 14: [XPDY0002] No context item set for
'root()'.
Thinking that, like for my queries, I needed to specify the database, I
tried:
for $i in collection("OpenSongSearch") return rename node $i as
lower-case(name($i))
and got:
Error: Stopped at line 1, column 84: [XUTY0012] Single element, attribute
or pi expected as rename target.
Any clues as to what I'm doing wrong?
Thanks for your help!
David
mailto:david@leighweb.com DavidEmailSig
From: David Leigh [mailto:david@leighweb.com]
Sent: Monday, June 18, 2012 07:49 PM
To: 'basex-talk@mailman.uni-konstanz.de'
Subject: RE: [basex-talk] XML element case sensitivity
Oops.didn't look at it closely enough. Of course it changes all the nodes.
It's also fast so it will work perfectly. Thanks!
mailto:david@leighweb.com DavidEmailSig
From: David Leigh [mailto:david@leighweb.com]
Sent: Sunday, June 17, 2012 09:28 PM
To: 'basex-talk@mailman.uni-konstanz.de'
Subject: [basex-talk] XML element case sensitivity
Jens,
Could I do this right after database creation and it would actually CHANGE
the node names so that my queries could all still references the lower case
node names? (that's what it looks like it's doing but I just wanted to
confirm it).
I need to do it for 3 node names, can it be done in one "for" loop?
I don't mind taking the hit at database creation time as opposed to query
time.
Thanks!
David
***********************************************************************
Hi David,
for preprocessing you could use something like
for $i in //*
return rename node $i as lower-case(name($i))
to rename all nodes to their lower-case equivalent. If you only want to
process lyrics-nodes of all variations, insert Dirk's predicate to `//*`.
Sadly the full-text index which offers case insensitivity doesn't include
tag names, so you can't use this either.
Kind regards from Lake Constance, Germany,
Jens
--
Jens Erat
[phone]: tel:+49-151-56961126
[mail]: mailto:email at jenserat.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
[jabber]: xmpp:jabber at jenserat.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
[web]:
http://www.jenserat.de
PGP: 350E D9B6 9ADC 2DED F5F2 8549 CBC2 613C D745 722B
Am 16.06.2012 um 16:46 schrieb Dirk Kirsten:
> There are functions like lower-case() and upper-case(). So you could do
something like this
>
> //*[lower-case(name(.)) = "lyrics"]
>
> However, I guess it could result in a decreased performance. Therefore it
might be reasonable to do this in some kind of preprocessing, if it is
relevant for your use-case.
>
> cheers,
> Dirk
>
>
> On 06/16/2012 03:51 PM, David Leigh wrote:
>> I've been searching in the BaseX docs online and can't seem to find
>> reference to what I'm seeing. It may be common knowledge in the XML
>> community but I'm not highly skilled in XML.
>>
>> Here's my issue:
>>
>> I have XML files that I'm loading into my database where there is
>> inconsistency in the case (capital vs. lower-case) of the tag names (XML
>> elements I think?). For instance, I have a tag named "lyrics" and
>> sometimes in the files (whose source is not necessarily under my
>> control) that will be <lyrics> and sometimes <Lyrics>. It could of
>> course, by someone's error also be <lYrIcS> or any other weird
>> combination. Is there a way, either at database creation or via some
>> option or at query time to say that "lyrics" = "Lyrics" = "LyRics", etc.
>> i.e. to be case insensitive for the XML tag names?
>>
>> Thanks!
>>
>> David
>>
>> DavidEmailSig <mailto:david at leighweb.com
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
>>
>>
>>
>> _______________________________________________
>> BaseX-Talk mailing list
>> BaseX-Talk at mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>>
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
> _______________________________________________
> BaseX-Talk mailing list
> BaseX-Talk at mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
mailto:david@leighweb.com DavidEmailSig