defaultNamespacePrefix = prefix;
}
}
Tree ast = PropertyParser.parse(propertyName);
Property property = PropertyParser.parse(propertyName, false);
boolean isDynamic = property.isDynamic();
SchemaElementComplex rootComplexElement = SchemaUtil.findRootElement(schemaModel, namespace, rootElementName);
String prefix = ctx.getPrefix(rootComplexElement.getNamespace());
if (prefix == null) {
prefix = "";
}
else {
prefix += ':';
}
StringBuilder xPathBuf = new StringBuilder();
xPathBuf.append('/');
xPathBuf.append(prefix);
if (rootElementName.startsWith("//"))
{
xPathBuf.append(rootElementName.substring(2));
}
else
{
xPathBuf.append(rootElementName);
}
SchemaElementComplex parentComplexElement = rootComplexElement;
Pair<String, QName> pair = null;
if (ast.getChildCount() == 1)
{
pair = makeProperty(rootComplexElement, ast.getChild(0), ctx, true, isDynamic, defaultNamespacePrefix);
if (pair == null)
{
throw new PropertyAccessException("Failed to locate property '" + propertyName + "' in schema");
}
xPathBuf.append(pair.getFirst());
}
else
{
for (int i = 0; i < ast.getChildCount(); i++)
{
boolean isLast = (i == ast.getChildCount() - 1);
Tree child = ast.getChild(i);
pair = makeProperty(parentComplexElement, child, ctx, isLast, isDynamic, defaultNamespacePrefix);
if (pair == null)
{
throw new PropertyAccessException("Failed to locate property '" + propertyName + "' nested property part '" + child.toString() + "' in schema");
}
String text = child.getChild(0).getText();
SchemaItem obj = SchemaUtil.findPropertyMapping(parentComplexElement, text);
if (obj instanceof SchemaElementComplex)
{
parentComplexElement = (SchemaElementComplex) obj;
}
xPathBuf.append(pair.getFirst());
}
}
String xPath = xPathBuf.toString();
if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled()))
{
log.debug(".parse XPath for property '" + propertyName + "' is expression=" + xPath);
}
// Compile assembled XPath expression
XPath path = xPathFactory.newXPath();
path.setNamespaceContext(ctx);
if (log.isDebugEnabled())
{
log.debug("Compiling XPath expression '" + xPath + "' for property '" + propertyName + "' using namespace context :" + ctx);
}
XPathExpression expr;
try
{
expr = path.compile(xPath);
}
catch (XPathExpressionException e) {
String detail = "Error constructing XPath expression from property expression '" + propertyName + "' expression '" + xPath + "'";
if (e.getMessage() != null)
{
throw new EPException(detail + " :" + e.getMessage(), e);
}
throw new EPException(detail, e);
}
// get type
SchemaItem item = property.getPropertyTypeSchema(rootComplexElement, eventAdapterService);
if ((item == null) && (!isDynamic))
{
return null;
}