Using xalan:evaluate to ‘parameterize’ XPATH

This is in reference to this OTN post.The poster there had the below XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <title>Empire Burlesque</title>
 <artist>Bob Dylan</artist>

And he wanted to extract the value of /catalog/cd/title. The problem is that this xpath needs to be parameterized and not hardcoded, which means it requires dynamic XPATH evaluation. This can be done in OSB using a XSLT transformation leveraging  xalan:evaluate.

First lets create the xslt for doing this:

<xsl:stylesheet version="1.0"

<xsl:param name="xpath"/>

<xsl:template match="/">
<XalanResult> <xsl:value-of select="xalan:evaluate($xpath)"/></XalanResult>



Register this as a XSLT resource in OSB. Next create a proxy service to test this XSLT.
We will use a ASSIGN action to test this. This action just assigns the result of XSLT to the xalanEvaluationResult variable.

We configure it to pass content of $body as source input. The second parameter is the string representation of the Xpath we want to apply on the source XML.
Click the test button to test this.

For $body we pass the xml in that post.

The test result shows XSLT function applying the ‘parameterised’ xpath on the source xml and returning the result.

About atheek

I am a Tech consultant working in Middleware/Integration area.
This entry was posted in OSB, XSLT and tagged , , . Bookmark the permalink.

1 Response to Using xalan:evaluate to ‘parameterize’ XPATH

  1. Jairo Vides says:

    Hi atheek, I’m newbie in osb, can you say me, how to implement or use the xalan library in osb?, thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s