you did not encounter a bug, you just noticed correct behaviour of tf:containsText. This is a text retrieval function that searches for words and phrases. Apparently, there is no word “SA” in your database, so teh result is correct.
Obviously, you want to search for all Nombre element which contain words starting with “SA” at any position of the element content. In this case, you have to specify that you do not want to search for whole words but for their prefix only. In tf:containsText, you can do this using the * wildcard:
for $a in input()/Establecimiento
where tf:containsText($a/DefinicionEstablecimiento/Nombre, "SA*")
return $a/DefinicionEstablecimiento/Nombre
This wildcard can also be applied at the beginning or in the middle of a word.
In your scenario, you will not find the names using “fn:starts-with()” - not because it is a buggy function, but simply because your element content DOES NOT start with “SAN”.
You might find the Tamino documentation helpful in explaining this in more depth
for $a in input()/Establecimiento where tf:containsText($a/DefinicionEstablecimiento/Nombre, "H*") return substring($a/DefinicionEstablecimiento/Nombre,1,1)
If you get “H” four times, I agree that starts-with seems to have a bug
for $a in input()/Establecimiento where tf:containsText($a/DefinicionEstablecimiento/Nombre, "H*") return substring($a/DefinicionEstablecimiento/Nombre,1,1)
actually, that is what I had expected. It seems that your Nombre elements contain some non-printable character in form of the “H”.
Please check with an editor that is capable of HEX display