throws PolicyException {
try {
final QName name = element.getName();
if (parent == null) {
if (!name.equals(POLICIES)) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<Policies>", name, element.getLocation())));
}
} else {
final QName parentName = parent.getName();
if (parentName.equals(POLICIES)) {
if (!name.equals(POLICY_ATTACHMENT)) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<PolicyAttachment>", name, element.getLocation())));
}
} else if (parentName.equals(POLICY_ATTACHMENT)) {
if (name.equals(POLICY)) {
readPolicy(reader);
return;
} else if (!name.equals(APPLIES_TO)) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<AppliesTo> or <Policy>", name, element.getLocation())));
}
} else if (parentName.equals(APPLIES_TO)) {
if (!name.equals(URI)) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<URI>", name, element.getLocation())));
}
} else {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0090_UNEXPECTED_ELEMENT(name, element.getLocation())));
}
}
reader.nextEvent();
this.unmarshal(reader, element);
} catch (XMLStreamException e) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0088_FAILED_PARSE(element.getLocation()), e));
}
}