# Using xpath functions

**URL:** <https://techcommunity.softwareag.com/t/using-xpath-functions/59502>\
**Category:** Forum\
**Tags:** Former-Crossvision-Products, Service-Orchestrator\
**Created:** [November 14, 2005, 10:27pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502 "2005-11-14T22:27:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![El\_Charlie](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@El\_Charlie](https://techcommunity.softwareag.com/u/El_Charlie)\
**Post date:** [November 14, 2005, 10:27pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/1 "2005-11-14T22:27:37Z")

</div>

Hello:

I want to use the xpath “replace()” function, but Mediator doestn’t recognize it:

something like:

```auto

{replace('hello','h','H')} 
```

in a property set doesn’t work. I’ve tried with namespaces:

```auto

<set xmlns:fn="http://www.w3.org/2005/02/xpath-functions" 
property="hi" value="{fn:replace('hello','h','H')}" xbd.zid="N400063"/>
```

…with the same result. I’m using 7.4.1.1 version.

Any idea? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Matthew](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Matthew](https://techcommunity.softwareag.com/u/Matthew)\
**Post date:** [November 15, 2005, 1:21pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/2 "2005-11-15T13:21:06Z")

</div>

Hi,

The replace function for XPath is part of the XPath 2.0 Candidate Recommendation submited to the W3C on 03.11.2005. Most implimentations of this XPath version and the replace function in general are based on the W3C XPath 2.0 Draft Requirement from 22.08.2003.  
Because of this, you will find very few “production” quality Xpath evaluation engines already implimenting the XPath 2.0. Xalan is currently the industry standard for this and their most recent release, Xalan 2.7, still bases its XPath functionality on XPath 1.0.  
If this is a functionality you cannot do without, I suggest you use one of the XPath 2.0 reference libraries and build a custom component to perform the transformation indicated.

---

<div class="post-metadata">

**Author:** ![El\_Charlie](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@El\_Charlie](https://techcommunity.softwareag.com/u/El_Charlie)\
**Post date:** [November 15, 2005, 2:53pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/3 "2005-11-15T14:53:18Z")

</div>

Thanks 4 replying.

It’s very frustrating that Mediator hasn’t this funcionality. I hope that in future releases, Xpath 2.0 will be implemented. I’ll follow your suggestion: develop an external component.

---

<div class="post-metadata">

**Author:** ![El\_Charlie](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@El\_Charlie](https://techcommunity.softwareag.com/u/El_Charlie)\
**Post date:** [November 15, 2005, 5:54pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/4 "2005-11-15T17:54:37Z")

</div>

Hello again:

This is the way I’ve implemented the replace function:

```auto

<?xml version="1.0" encoding="UTF-8"?>
<sequence version="4.0" xbd.zid="N400001">
    <block xbd.zid="N400002">
        <!--{Name: JavaObjectGateway};{Notes: }-->
        <step component="SagJavaObjectGateway" xbd.object.class="java.lang.String" xbd.object.function="Create" xbd.object.methodDescriptor="(Ljava/lang/String;)V" xbd.object.parm0="{'$with_blankspaces'}" xbd.object.result="MyString" xbd.zid="N400003"/>
        <!--{Name: JavaObjectGateway};{Notes: }-->
        <step component="SagJavaObjectGateway" xbd.object.function="Call" xbd.object.method="replaceAll" xbd.object.methodDescriptor="Ljava/lang/String;Ljava/lang/String;" xbd.object.object="MyString" xbd.object.parm0=" " xbd.object.parm1="_" xbd.object.property="without_blankspaces" xbd.zid="N400004"/>
    </block>
</sequence>

```

The only problem I have with this solution is that when I open the sequence in graphical mode, Mediator removes the blankspace value " " and puts an empty string.

Is there any way for defining a blankspace value in a mediator property?

---

<div class="post-metadata">

**Author:** ![El\_Charlie](https://avatars.discourse-cdn.com/v4/letter/e/4bbf92/32.png) [@El\_Charlie](https://techcommunity.softwareag.com/u/El_Charlie)\
**Post date:** [November 15, 2005, 8:04pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/5 "2005-11-15T20:04:19Z")

</div>

Hello again:

This is the way I’ve implemented the replace function:

```auto

<?xml version="1.0" encoding="UTF-8"?>
<sequence version="4.0" xbd.zid="N400001">
    <block xbd.zid="N400002">
        <!--{Name: JavaObjectGateway};{Notes: }-->
        <step component="SagJavaObjectGateway" xbd.object.class="java.lang.String" xbd.object.function="Create" xbd.object.methodDescriptor="(Ljava/lang/String;)V" xbd.object.parm0="{'$with_blankspaces'}" xbd.object.result="MyString" xbd.zid="N400003"/>
        <!--{Name: JavaObjectGateway};{Notes: }-->
        <step component="SagJavaObjectGateway" xbd.object.function="Call" xbd.object.method="replaceAll" xbd.object.methodDescriptor="Ljava/lang/String;Ljava/lang/String;" xbd.object.object="MyString" xbd.object.parm0=" " xbd.object.parm1="_" xbd.object.property="without_blankspaces" xbd.zid="N400004"/>
    </block>
</sequence>

```

The only problem I have with this solution is that when I open the sequence in graphical mode, Mediator removes the blankspace value " " and puts an empty string.

Is there any way for defining a blankspace value in a mediator property?

---

<div class="post-metadata">

**Author:** ![Matthew](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Matthew](https://techcommunity.softwareag.com/u/Matthew)\
**Post date:** [November 16, 2005, 3:54pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/6 "2005-11-16T15:54:01Z")

</div>

This sounds like a bug in the studio. It shouldn’t be altering your property values at all. If you can, please report this via ServLine24.

Thanks,

---

<div class="post-metadata">

**Author:** ![Mike\_Bernat](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mike\_Bernat](https://techcommunity.softwareag.com/u/Mike_Bernat)\
**Post date:** [November 17, 2005, 7:03pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/7 "2005-11-17T19:03:52Z")

</div>

Hi All,

If you are only doing single character replacements, you can use the XPath “translate” function. The arguments are much longer, but it is part of the XPath 1.0 specification.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:39pm UTC](https://techcommunity.softwareag.com/t/using-xpath-functions/59502/8 "2021-04-02T14:39:52Z")

</div>


