public class XPathAnnotationExpressionFactory extends DefaultAnnotationExpressionFactory {
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class expressionReturnType) {
String xpath = getExpressionFromAnnotation(annotation);
XPathBuilder builder = XPathBuilder.xpath(xpath);
if (annotation instanceof XPath) {
XPath xpathAnnotation = (XPath) annotation;
NamespacePrefix[] namespaces = xpathAnnotation.namespaces();
if (namespaces != null) {
for (NamespacePrefix namespacePrefix : namespaces) {
builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
}
}
}
return builder;
}