I have this xml file
<Collections xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<Collection value="bob">
<Environments>
<Environment>amazon</Environment>
</Environments>
<ContentTypes>
<Type>Standard:ShowVideo</Type>
<Type>Standard:VideoPlaylist</Type>
<Type>Blog</Type>
</ContentTypes>
</Collection>
<Collection value="sandy">
<Environments>
<Environment>amazon</Environment>
</Environments>
<ContentTypes>
<Type>Blog</Type>
</ContentTypes>
</Collection>
and am executing this xpath query in my Mule flow. It uses 2 flowVars 'environment' and 'contentType' which come from a Redis message.
<set-variable variableName="collectionQuery" value="/Collections/Collection[Environments/Environment='#[environment]' and ContentTypes/Type='#[contentType]']/@value" />
<logger message="collectionQuery is #[collectionQuery]" level="INFO" />
<set-payload value="#[xpath(collectionQuery)]" />
<logger message="payload is #[payload]" level="INFO" />
Here you can see the fully instantiated query and the result.
INFO] org.mule.api.processor.LoggerMessageProcessor: collectionQuery is /Collections/Collection[Environments/Environment='amazon' and ContentTypes/Type='Blog']/@value
INFO] org.mule.api.processor.LoggerMessageProcessor: payload is [org.dom4j.tree.DefaultAttribute@140207e0 [Attribute: name value value "bob"], org.dom4j.tree.DefaultAttribute@11530d63 [Attribute: name value value "sandy"]]
The result is what looks like an array of 2 org.dom4j.tree objects. I just need an ArrayList of attribute 'value' such as this
[bob,sandy]
I can do this in Groovy but not using Mule's xpath functionality.