append("\"]/ns:type");
// bind the "ns" prefix to the rootElements namespace.
Namespace[] namespaces = new Namespace[]{
Namespace.getNamespace("ns", rootElement.getNamespaceURI())
};
XPath xpath = new XPath(buffer.toString(), namespaces);
try {
policyTypeElement = xpath.selectSingleElement(rootElement);
// see if the type element has a "ref" attribute
if (policyTypeElement != null) {
String ref = policyTypeElement.getAttributeValue(
DeviceRepositorySchemaConstants.
POLICY_DEFINITION_REF_ATTRIBUTE_NAME);
// if the type element has a ref attribute then the attributes
// value, references a named type whose definition can be
// obtainded from the /definitions/types element.
if (ref != null) {
// this is referencing a type that is defined in the
// types element
buffer = new StringBuffer();
buffer.append("/ns:definitions/ns:types/ns:type[@name=\"")
.append(ref)
.append("\"]");
xpath = new XPath(buffer.toString(), namespaces);
policyTypeElement = xpath.selectSingleElement(rootElement);
}
}
} catch (XPathException e) {
// There was a problem retrieving the type element.
throw new UndeclaredThrowableException(e, e.getMessage());