while (itNS.hasNext()) {
Namespace ns = itNS.next();
// Rule M4.2
if (ns.getURI().equals(PackageNamespaces.MARKUP_COMPATIBILITY))
throw new InvalidFormatException(
"OPC Compliance error [M4.2]: A format consumer shall consider the use of the Markup Compatibility namespace to be an error.");
}
// Rule M4.3
if (el.getNamespace().getURI().equals(
PackageProperties.NAMESPACE_DCTERMS)
&& !(el.getName().equals(KEYWORD_CREATED) || el.getName()
.equals(KEYWORD_MODIFIED)))
throw new InvalidFormatException(
"OPC Compliance error [M4.3]: Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.");
// Rule M4.4
if (el.attribute(new QName("lang", namespaceXML)) != null)
throw new InvalidFormatException(
"OPC Compliance error [M4.4]: Producers shall not create a document element that contains the xml:lang attribute. Consumers shall consider a document element that violates this constraint to be an error.");
// Rule M4.5
if (el.getNamespace().getURI().equals(
PackageProperties.NAMESPACE_DCTERMS)) {
// DCTerms namespace only use with 'created' and 'modified' elements
String elName = el.getName();
if (!(elName.equals(KEYWORD_CREATED) || elName
.equals(KEYWORD_MODIFIED)))
throw new InvalidFormatException("Namespace error : " + elName
+ " shouldn't have the following naemspace -> "
+ PackageProperties.NAMESPACE_DCTERMS);
// Check for the 'xsi:type' attribute
Attribute typeAtt = el.attribute(new QName("type", namespaceXSI));
if (typeAtt == null)
throw new InvalidFormatException("The element '" + elName
+ "' must have the '" + namespaceXSI.getPrefix()
+ ":type' attribute present !");
// Check for the attribute value => 'dcterms:W3CDTF'
if (!typeAtt.getValue().equals("dcterms:W3CDTF"))
throw new InvalidFormatException("The element '" + elName
+ "' must have the '" + namespaceXSI.getPrefix()
+ ":type' attribute with the value 'dcterms:W3CDTF' !");
}
// Check its children