[jira] [Resolved] (VELTOOLS-197) xmlTool.find("./text()") (XPATH) not the same as xmlTool.getText () (METHOD) when & in text

"Claude Brisson (Jira)" <[email protected]> Wed, 17 Jun 2026 15:27:00 +0000 (UTC)
Newsgroups gmane.comp.jakarta.velocity.devel
Message-ID <[email protected]>
     [ https://issues.apache.org/jira/browse/VELTOOLS-197?page=3Dcom.atlass=
ian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claude Brisson resolved VELTOOLS-197.
-------------------------------------
    Fix Version/s: 3.2
                   4.0
         Assignee: Claude Brisson
       Resolution: Fixed

> xmlTool.find("./text()") (XPATH) not the same as xmlTool.getText () (METH=
OD) when & in text
> -------------------------------------------------------------------------=
------------------
>
>                 Key: VELTOOLS-197
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-197
>             Project: Velocity Tools
>          Issue Type: Bug
>          Components: GenericTools
>    Affects Versions: 3.1
>            Reporter: steven van vlierberghe
>            Assignee: Claude Brisson
>            Priority: Major
>             Fix For: 3.2, 4.0
>
>
> #foreach ($item2 in $xmlf1.find("/input/rep/x"))
> xpath: ${item2.find("./text()")} xml: $item2.getText()
> #end
> with $xmlf1 an XmlTool instance initialized on the following inputfile:
> {code:java}
> <input>
> <rep>
> <x>R&amp;R</x>
> <x>R&amp;B</x>
> </rep>
> </input>
> {code}
> using VeloctityTools-XmlTool 2.0=C2=A0 :=C2=A0 find("./text()") returns s=
ame as getText() for an xmlTool instance=C2=A0 (and complying with the expe=
ctation)
> {code:java}
> xpath: R&R   xml:  R&R
> xpath: R&B   xml:  R&B
> {code}
> However, using XmlTool 3.1, the xpath construct does not return the same =
as the getText,
> so the xpath does not comply with expectation
> {code:java}
> xpath: R&amp;R   xml:  R&R
> xpath: R&amp;B   xml:  R&B
> {code}
> =C2=A0
> PS:
> it can be solved in 3.1, by replacing $item2.find("./text()")=C2=A0 by=C2=
=A0 =C2=A0$item2.find("./text()").node().getNodeValue()
> BUT
> this really requires to adapt the script
> the actual problem is that I give support in our software to users for ru=
nning their own Velocity scripts in our software.
> In the next version of our software, we upgraded Velocity + VelocityTools=
 to 3.1=C2=A0
> and as a consequence, scripts of the users might break;=C2=A0
> meaning, this regression issue will impose our users to have to adapt the=
ir scripts that are used in production
> and for sure, they will not be happy having to do so
> =C2=A0
> PS2: also have the impression that plainly rendering $item2.find("./text(=
)") as String also looses leading and trailing white space
> =C2=A0
> PS: the actual reason for upgrading VelocityTools (2.0 > 3.1) is that Ver=
aCode flags the 2.0-related velocity libraries having vulnerabilities (and =
also dependent libraries like common- beanutils); these vulnerabilities hav=
e been solved in 3.1.
> Because there are (to us important) regression issues with upgrading the =
velocity stuff, we cannot upgrade and therefor remain stuck with flagged vu=
lnerabilities in our software.=C2=A0



--
This message was sent by Atlassian Jira
(v8.20.10#820010)