Q:

XPath translate() within contains() with dynamic variable

I am working in VBscript with an application that has XPath to return matching node information.
To make it case insensitive I am using translate function. There is a variable that holds value to search for (say v_Search). After I implemented translate() it is not returning matching nodes rather it returns all nodes in XML.
Below XPath returns correct information but is case sensitive ;-
//*[contains(., '"& v_search &"')]/ancestor-or-self::*/*[local-name()='name' and @locale='en']

To make it case insensitive I implemented translate() but it is not able to check for matching result. Below is expression :-
//*[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') , v_search)]/ancestor-or-self::*/*[local-name()='name' and @locale='en']

I am unable to figure out what is wrong..

This expression returns everything from xml document.

I have already tried '"& v_search &"' in that case it does not give any result.

Edit After figuring out problem
//*[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), translate('"& v_search &"', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))]/ancestor-or-self::*/*[local-name()='name' and @locale='en']

Still it doesn't returns only matching nodes. However it doesn't return entire xml node now.
Edit:- Sample Xml
<root xmlns="https://jlkjsdlfjl/">
    <name>Accounts</name>
    <property name="included" type="hidden">true</property>
    <locales>
        <locale>en</locale>
        <locale>de</locale>
    </locales>
    <defaultLocale>en</defaultLocale>
    <searchspace>
        <name locale="en">Accounts</name>
        <name locale="de">Accounts</name>
        <lastChanged>2014-03-05T18:47:30</lastChanged>
        <lastChangedBy>userx</lastChangedBy>
        <property name="included" type="hidden">true</property>
        <searchspace>
            <name locale="en">Database L</name>
            <name locale="zw">Database L</name>
            <searchSubject status="valid">
                <name locale="en">SName1</name>
                <name locale="zw">qskxyz</name>
                <searchItem>
                    <name locale="en">IName1</name>
                    <name locale="zw">qixyz</name>
                    <hello>v_search</hello>
                </searchItem>
                 <searchItem>
                    <name locale="en">IName2</name>
                    <name locale="zw">abc</name>
                    v_search
                </searchItem>
                 <searchItem>
                    <name locale="en">IName3</name>
                    <name locale="zw">def</name>
                    <hello>something else</hello>
                </searchItem>
            </searchSubject>
        </searchspace>
    </searchspace>
    <searchspace>
        <name locale="en">Names</name>
        <lastChanged>2016-01-12T12:42:46</lastChanged>
        <searchspace>
            <name locale="en">Database Layer</name>
            <name locale="zw">Database Layer</name>
            <searchSubject status="valid">
                <name locale="en">SName2</name>
                <searchItem>
                    <name locale="en">IName4</name>
                    <hello>...Hi there..</hello>
                </searchItem>
            </searchSubject>
        </searchspace>
    </searchspace>
</root>

Sample result:

Accounts,   Database L,  SName1,  IName 1
--------,   ----------, -------,  IName 2

These two hirarchy contains the v_search text.... Others should not come.

A:

//*[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), translate('v_search', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))]/ancestor-or-self::*/name[@locale='en']

I have tested it in xpathtester and result is:
<name locale="en">Accounts</name>
<name locale="en">Database L</name>
<name locale="en">SName1</name>
<name locale="en">IName1</name>
<name locale="en">IName2</name>

