try {
// there's always an Id
Node attributeIdNode = attrs.getNamedItem("AttributeId");
if(attributeIdNode == null)
throw new ParsingException("Required AttributeId missing in " +
"AttributeDesignator ->" + root.getNodeName() );
id = new URI(attributeIdNode.getNodeValue());
} catch (Exception e) {
throw new ParsingException("Required AttributeId missing in " +
"AttributeDesignator", e);
}
try {
// there's always a data type
Node dataTypeNode = attrs.getNamedItem("DataType");
if(dataTypeNode == null)
throw new IllegalStateException("Required DataType missing in " +
"AttributeDesignator ->" + root.getNodeName());
type = new URI(dataTypeNode.getNodeValue());
} catch (Exception e) {
throw new ParsingException("Required DataType missing in " +
"AttributeDesignator", e);
}
try {
// there might be an issuer
Node node = attrs.getNamedItem("Issuer");
if (node != null)
issuer = new URI(node.getNodeValue());
// if it's for the Subject section, there's another attr
if (target == SUBJECT_TARGET) {
Node scnode = attrs.getNamedItem("SubjectCategory");
if (scnode != null)
subjectCategory = new URI(scnode.getNodeValue());
else
subjectCategory = new URI(SUBJECT_CATEGORY_DEFAULT);
}
// there might be a mustBePresent flag
node = attrs.getNamedItem("MustBePresent");
if (node != null)
if (node.getNodeValue().equals("true"))
mustBePresent = true;
} catch (Exception e) {
// this shouldn't ever happen, but in theory something could go
// wrong in the code in this try block
throw new ParsingException("Error parsing AttributeDesignator " +
"optional attributes", e);
}
AttributeDesignator ad =
new AttributeDesignator(target, type, id, mustBePresent, issuer);