ODFTOOLKIT-478 - Adding namespaces to manifest and digital signature DOM by fix & refactoring of generator
diff --git a/generator/schema2template/pom.xml b/generator/schema2template/pom.xml
index dd73c34..972b2ef 100644
--- a/generator/schema2template/pom.xml
+++ b/generator/schema2template/pom.xml
@@ -32,10 +32,15 @@
<version>0.9.0-incubating-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-engine-core</artifactId>
+ <version>2.0</version>
+ </dependency>
<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- </dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </dependency>
<dependency>
<groupId>net.java.dev.msv</groupId>
<artifactId>msv-core</artifactId>
diff --git a/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java b/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
index 494d77c..65ca307 100644
--- a/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
+++ b/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
@@ -110,8 +110,10 @@
private static final String PYTHON_OUTPUT_FILES = "target" + File.separator + "python-output-files.xml";
private static final String DOM_OUTPUT_FILES_TEMPLATE = "dom-output-files.vm";
private static final String DOM_OUTPUT_FILES = "target" + File.separator + "dom-output-files.xml";
- private static final String PKG_OUTPUT_FILES_TEMPLATE = "pkg-output-files.vm";
- private static final String PKG_OUTPUT_FILES = "target" + File.separator + "pkg-output-files.xml";
+ private static final String PKG_MANIFEST_OUTPUT_FILES_TEMPLATE = "pkg-manifest-output-files.vm";
+ private static final String PKG_MANIFEST_OUTPUT_FILES = "target" + File.separator + "pkg-manifest-output-files.xml";
+ private static final String PKG_DSIG_OUTPUT_FILES_TEMPLATE = "pkg-dsig-output-files.vm";
+ private static final String PKG_DSIG_OUTPUT_FILES = "target" + File.separator + "pkg-dsig-output-files.xml";
private static XMLModel mOdf12SignatureSchemaModel;
private static XMLModel mOdf12ManifestSchemaModel;
private static XMLModel mOdf12SchemaModel;
@@ -154,9 +156,9 @@
initialize();
// ODF 1.2 Code Generation
- fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
- fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
- fillTemplates(odfPkgResourceDir, mOdf12ManifestRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
+ fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES, mOdf12SchemaModel);
+ fillTemplates(odfPkgResourceDir, mOdf12ManifestRoot, PKG_MANIFEST_OUTPUT_FILES_TEMPLATE, PKG_MANIFEST_OUTPUT_FILES, mOdf12ManifestSchemaModel);
+ fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_DSIG_OUTPUT_FILES_TEMPLATE, PKG_DSIG_OUTPUT_FILES, mOdf12SignatureSchemaModel);
}
public static void main(String[] args) throws Exception {
@@ -164,14 +166,14 @@
initialize();
// ODF 1.2 HTML Reference (yet without BNF nor images)
- fillTemplates(odfReferenceResourceDir, mOdf12Root, REFERENCE_OUTPUT_FILES_TEMPLATE, REFERENCE_OUTPUT_FILES);
+ fillTemplates(odfReferenceResourceDir, mOdf12Root, REFERENCE_OUTPUT_FILES_TEMPLATE, REFERENCE_OUTPUT_FILES, mOdf12SchemaModel);
// ODF 1.2 Python (The generated Python source is from a former colleague and might not work any longer..)
- fillTemplates(odfPythonResourceDir, mOdf12Root, PYTHON_OUTPUT_FILES_TEMPLATE, PYTHON_OUTPUT_FILES);
+ fillTemplates(odfPythonResourceDir, mOdf12Root, PYTHON_OUTPUT_FILES_TEMPLATE, PYTHON_OUTPUT_FILES, mOdf12SchemaModel);
// ODF 1.2 Code Generation
- fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
- fillTemplates(odfPkgResourceDir, mOdf12ManifestRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
- fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_OUTPUT_FILES_TEMPLATE, PKG_OUTPUT_FILES);
+ fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES, mOdf12SchemaModel);
+ fillTemplates(odfPkgResourceDir, mOdf12ManifestRoot, PKG_MANIFEST_OUTPUT_FILES_TEMPLATE, PKG_MANIFEST_OUTPUT_FILES, mOdf12ManifestSchemaModel);
+ fillTemplates(odfPkgResourceDir, mOdf12SignatureRoot, PKG_DSIG_OUTPUT_FILES_TEMPLATE, PKG_DSIG_OUTPUT_FILES, mOdf12SignatureSchemaModel);
}
private static void initialize() throws Exception {
@@ -205,7 +207,7 @@
LOG.info("Finished initilization..");
}
- private static void fillTemplates(String sourceDir, Expression root, String outputRuleTemplate, String outputRuleFile) throws Exception {
+ private static void fillTemplates(String sourceDir, Expression root, String outputRuleTemplate, String outputRuleFile, XMLModel model) throws Exception {
// intialising template engine (ie. Velocity)
Properties props = new Properties();
props.setProperty("file.resource.loader.path", sourceDir);
@@ -213,12 +215,12 @@
ve.init();
// Create output-files.xml
- createOutputFileList(ve, outputRuleTemplate, outputRuleFile);
+ createOutputFileList(ve, outputRuleTemplate, outputRuleFile, model);
LOG.info("output-files.xml created done.");
// Process output-files.xml, create output files
LOG.fine("Processing output files... ");
- processFileList(ve, root, outputRuleFile);
+ processFileList(ve, root, outputRuleFile, model);
LOG.fine("DONE.\n");
}
@@ -264,12 +266,26 @@
* @throws Exception
*/
public static Expression loadSchema(File rngFile) throws Exception {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
+
+ SAXParserFactory saxFactory = new org.apache.xerces.jaxp.SAXParserFactoryImpl();
+ saxFactory.setNamespaceAware(true);
+ saxFactory.setValidating(false);
+ try {
+ saxFactory.setXIncludeAware(false);
+ saxFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ // removing potential vulnerability: see https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing
+ saxFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ saxFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ saxFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ } catch (Exception ex) {
+ Logger.getLogger(OdfHelper.class.getName()).log(Level.SEVERE, null, ex);
+ throw new RuntimeException();
+ }
+
// Parsing the Schema with MSV
String absolutePath = rngFile.getAbsolutePath();
com.sun.msv.reader.util.IgnoreController ignoreController = new com.sun.msv.reader.util.IgnoreController();
- Expression root = RELAXNGReader.parse(absolutePath, factory, ignoreController).getTopLevel();
+ Expression root = RELAXNGReader.parse(absolutePath, saxFactory, ignoreController).getTopLevel();
if (root == null) {
@@ -280,9 +296,6 @@
private static VelocityContext getContext(String contextStr, String param) {
VelocityContext context = new VelocityContext();
- context.put("signaturemodel", mOdf12SignatureSchemaModel);
- context.put("manifestmodel", mOdf12ManifestSchemaModel);
- context.put("model", mOdf12SchemaModel);
context.put("oldmodel", mOdf11SchemaModel);
context.put("odfmodel", mOdfModel);
context.put("javamodel", mJavaModel);
@@ -291,8 +304,9 @@
return context;
}
- private static void createOutputFileList(VelocityEngine ve, String template, String output) throws Exception {
+ private static void createOutputFileList(VelocityEngine ve, String template, String output, XMLModel model) throws Exception {
VelocityContext context = getContext(null, null);
+ context.put("model", model);
File parentPatch = new File(output).getParentFile();
if (!parentPatch.exists()) {
parentPatch.mkdirs();
@@ -328,7 +342,7 @@
}
}
- public static void processFileList(VelocityEngine ve, Expression root, String outputRuleFile) throws Exception {
+ public static void processFileList(VelocityEngine ve, Expression root, String outputRuleFile, XMLModel model) throws Exception {
File outputFiles = new File(outputRuleFile);
List<OutputFileListEntry> fl = OutputFileListHandler.readFileListFile(outputFiles);
@@ -337,15 +351,18 @@
case PATH:
break;
case FILE:
- LOG.log(Level.INFO, "Processing line{0}: Generating file {1}\n", new Object[]{f.getLineNumber(), generateFilename(f.getAttribute("path"))});
+ LOG.log(Level.INFO, "Processing line {0}: Generating file {1}\n", new Object[]{f.getLineNumber(), generateFilename(f.getAttribute("path"))});
String odfContextStr = f.getAttribute("context");
String param = f.getAttribute("param");
VelocityContext context = getContext(odfContextStr, param);
if (context == null) {
throw new RuntimeException("Error in output-files.xml, line " + f.getLineNumber() + ": no or invalid odf-scope");
- }
+ }else{
+ context.put("model", model);
+ }
File out = new File(outputRoot + File.separator + generateFilename(f.getAttribute("path"))).getCanonicalFile();
+ LOG.info("Absolute path of generated file: " + out.getAbsolutePath());
ensureParentFolders(out);
FileWriter fileout = new FileWriter(out);
String encoding = "utf-8";
diff --git a/generator/schema2template/src/main/java/schema2template/model/NamespaceDictionary.java b/generator/schema2template/src/main/java/schema2template/model/NamespaceDictionary.java
index ca3f877..ac2b976 100644
--- a/generator/schema2template/src/main/java/schema2template/model/NamespaceDictionary.java
+++ b/generator/schema2template/src/main/java/schema2template/model/NamespaceDictionary.java
@@ -109,8 +109,10 @@
dict.put("grddl","http://www.w3.org/2003/g/data-view#");
dict.put("xhtml","http://www.w3.org/1999/xhtml");
dict.put("smil","urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
- dict.put("xml", "http://www.w3.org/XML/1998/namespace");
-
+ dict.put("xml", "http://www.w3.org/XML/1998/namespace");
+ dict.put("manifest", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
+ dict.put("dsig", "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0");
+ dict.put("ds", "http://www.w3.org/2000/09/xmldsig#");
return dict;
}
diff --git a/generator/schema2template/src/main/java/schema2template/model/PuzzlePieceSet.java b/generator/schema2template/src/main/java/schema2template/model/PuzzlePieceSet.java
index 5e45505..42d5768 100644
--- a/generator/schema2template/src/main/java/schema2template/model/PuzzlePieceSet.java
+++ b/generator/schema2template/src/main/java/schema2template/model/PuzzlePieceSet.java
@@ -61,7 +61,7 @@
throw new RuntimeException("Attempt to " + plannedAction + " of empty DefinitionSet ");
}
}
-
+
private void assertMultiples(String plannedAction) {
assertNotEmpty(plannedAction);
PuzzlePiece first = first();
@@ -85,7 +85,7 @@
public int hashCode() {
return mDefinitions.hashCode();
}
-
+
private PuzzlePiece first() {
return this.iterator().next();
}
@@ -139,7 +139,7 @@
}
return retval;
}
-
+
/**
* Make PuzzlePieceSet immutable. Cannot be undone.
*
diff --git a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm
index 4c4a92f..b6e29dc 100644
--- a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm
+++ b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm
@@ -18,18 +18,17 @@
## under the License.
##
##################################################################
-## Template to create the list of signature artefacts which are to be generated
+
+## Template to create the list of artifacts which are to be generated
##
## Documentation of template development can be found in local file
## TemplateHelp.html.
##
## Returns PuzzleComponent covering a PuzzlePiece or PuzzlePieceSet dependent if attribute is multiple times defined
-## Template to create the list of artefacts which are to be generated
-#set($attribute = $signaturemodel.getAttribute($context))
-#set($NS = "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0")
-#set ($PREFIX = "dsig")
-#set($localname = ${signaturemodel.extractLocalname($attribute)})
-#set($classname = "${signaturemodel.camelCase($attribute)}Attribute")
+#set($attribute = $model.getAttribute($context))
+#set($NS = $attribute.getNamespace())
+#set($localname = ${model.extractLocalname($attribute)})
+#set($classname = "${model.camelCase($attribute.getLocalName())}Attribute")
#set ($valueobject = "String")
##
#set($datatypes = ${attribute.getDatatypes().withoutMultiples()})
@@ -95,22 +94,30 @@
#end
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+#if ($hasDefaultValue and $defaultValueSet.size()>1)
+#foreach ($parent in ${attribute.getParents().withoutMultiples()})
+#if ($model.getDefaultAttributeValue($attribute, $parent))
+import org.odftoolkit.odfdom.pkg.dsig.${model.camelCase($parent.getLocalName())}Element;
+#end
+#end
+#end
/**
* DOM implementation of OpenDocument attribute {@odf.attribute ${attribute.getQName()}}.
*
*/
public class $classname extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("${NS}", "${PREFIX}:${attribute}");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.${NS.toUpperCase()}, "$localname");
#if ($hasDefaultValue)
#if ($defaultValueSet.size()>1)
#foreach ($defaultValue in $defaultValueSet)
-#set ($constant = $signaturemodel.constantCase($defaultValue))
+#set ($constant = $model.constantCase($defaultValue))
#if (($defaultValue=="true" or $defaultValue=="false") and $enum == false)
- public static final String DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)}= "$defaultValue";
+ public static final String DEFAULT_VALUE_${model.escapeKeyword($constant)}= "$defaultValue";
#else
- public static final String DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)}= Value.${signaturemodel.escapeKeyword($constant)}.toString();
+ public static final String DEFAULT_VALUE_${model.escapeKeyword($constant)}= Value.${model.escapeKeyword($constant)}.toString();
#end
#end
#else
@@ -160,8 +167,8 @@
#if (${value.toString().length()} == 1)
#set ($constant = $value)
#else
-#set ($constant = $signaturemodel.constantCase($value))
-#end${separator}${signaturemodel.escapeKeyword($constant)}("${signaturemodel.escapeLiteral($value)}")#set ($separator=", ")
+#set ($constant = $model.constantCase($value))
+#end${separator}${model.escapeKeyword($constant)}("${model.escapeLiteral($value)}")#set ($separator=", ")
#end ;
private String mValue;
@@ -217,7 +224,7 @@
/**
* @param value The <code>${simplevalue}</code> value of the attribute.
*/
- public void set${signaturemodel.camelCase($simplevalue)}Value(${simplevalue} value) {
+ public void set${model.camelCase($simplevalue)}Value(${simplevalue} value) {
super.setValue(String.valueOf(value));
}
@@ -227,7 +234,7 @@
public ${simplevalue} ${simplevalue}Value() {
String val = super.getValue();
try {
- return ${valueobject}.parse${signaturemodel.camelCase($simplevalue)}(val);
+ return ${valueobject}.parse${model.camelCase($simplevalue)}(val);
} catch (NumberFormatException e) {
// TODO: validation handling/logging
throw (e);
@@ -311,13 +318,13 @@
#if ($defaultValueSet.size()>1)
#foreach ($parent in ${attribute.getParents().withoutMultiples()})
#if ($odfmodel.getDefaultAttributeValue($attribute, $parent))
- if (parentElement instanceof ${signaturemodel.camelCase($parent)}Element) {
- defaultValue = "${signaturemodel.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $parent))}";
+ if (parentElement instanceof ${model.camelCase($parent)}Element) {
+ defaultValue = "${model.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $parent))}";
}
#end
#end
#else
- defaultValue = "${signaturemodel.escapeLiteral($uniqueDefaultValue)}";
+ defaultValue = "${model.escapeLiteral($uniqueDefaultValue)}";
#end
}
return defaultValue;
diff --git a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm
index 0ebb09a..eca6a7a 100644
--- a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm
+++ b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm
@@ -23,15 +23,9 @@
## Documentation of template development can be found in local file
## TemplateHelp.html.
##
-#set ($element = ${signaturemodel.getElement($context)})
-#if ($element == "Signature")
- #set ($NS = "http://www.w3.org/2000/09/xmldsig#")
- #set ($PREFIX = "ds")
-#else
- #set ($NS = "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0")
- #set ($PREFIX = "dsig")
-#end
-###set ($NS = "${element.getNamespace()}")
+#set ($element = ${model.getElement($context)})
+#set ($oldelement = ${oldmodel.getElement($context)})
+#set ($NS = ${element.getNamespace()})
#set ($classname = "${model.camelCase($element)}Element")
##
## Set child element and child attributes
@@ -79,7 +73,37 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+#set ($element = ${model.getElement($context)})
+#set ($oldelement = ${oldmodel.getElement($context)})
+#set ($NS = ${element.getNamespace()})
+#set ($classname = "${model.camelCase($element.getLocalName())}Element")
+#foreach ($child in $children)
+#if ($child == "*")
+ #set ($anychild = true)
+#else
+ #set ($childNS = ${child.getNamespace()})
+ #set ($childClassname = "${model.camelCase($child.getLocalName())}Element")
+#if ($childNS != $NS)
+## we call it all DSIG no DS folder..
+## WE DO NOT IMPORT SAME PACKAGE FOLDER
+##import org.odftoolkit.odfdom.pkg.dsig.$childClassname;
+#end
+#end
+#end
+##
+#foreach ($child in $attributes)
+#if ($child == "*")
+#set ($anyattribute = true)
+#else
+#set ($childNS = ${child.getNamespace()})
+#set ($childClassname = "${model.camelCase($child.getLocalName())}Attribute")
+#if (!$childNS.equals("dsig")) ## Do not generate "import" for the same package!
+import org.odftoolkit.odfdom.pkg.${childNS}.$childClassname;
+#end
+#end
+#end
##
## If there is a base class which is not in the current package
#if ($baseimport)
@@ -103,7 +127,7 @@
*/
public class $classname extends $baseclassname {
- public static final OdfName ELEMENT_NAME = OdfName.newName("${NS}", "${PREFIX}:${element}");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.${NS.toUpperCase()}, "${element.getLocalName()}");
/**
* Create the instance of <code>$classname</code>
@@ -119,6 +143,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element ${context}}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -134,7 +159,7 @@
## ---------------------------------------------------
##
#foreach ($attr in $attributes)
-#set($attri = ${signaturemodel.getAttribute($attr.getQName())})
+#set($attri = ${model.getAttribute($attr.getQName())})
#set ($valueObject = "String")
#set ($simpleValue = "")
#set ($dataTypes = ${attri.getDatatypes().withoutMultiples()})
@@ -169,8 +194,8 @@
#if ($attr != "*")
#set ($attribute = ${attr.withMultiples()})
#set ($aNS = ${attribute.getNamespace()})
-#set ($aClassname = "${signaturemodel.camelCase($attribute)}Attribute")
-#set ($aParam = "${signaturemodel.javaCase($attribute)}Value")
+#set ($aClassname = "${model.camelCase($attribute.getLocalName())}Attribute")
+#set ($aParam = "${model.javaCase($attribute.getLocalName())}Value")
/**
* Receives the value of the ODFDOM attribute representation <code>$aClassname</code> , See {@odf.attribute ${attribute.getQName()}}
@@ -182,7 +207,7 @@
* @return - the <code>$valueObject</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public $valueObject get${aClassname}() {
- $aClassname attr = ($aClassname) getOdfAttribute(${aClassname}.ATTRIBUTE_NAME);
+ $aClassname attr = ($aClassname) getOdfAttribute(OdfPackageNamespace.${aNS.toUpperCase()}, "${attribute.getLocalName()}");
if (attr != null) {
#if ($simpleValue!="")
return ${valueObject}.valueOf(attr.${simpleValue}Value());
@@ -191,14 +216,14 @@
#end
}
#if ($odfmodel.getDefaultAttributeValue($attribute, $element))
-#set ($defaultValue = ${signaturemodel.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $element))})
+#set ($defaultValue = ${model.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $element))})
#set ($defaultValueSet = $odfmodel.getDefaultAttributeValues($attribute))
#if ($defaultValueSet.size()>1)
-#set ($constant = $signaturemodel.constantCase($defaultValue))
+#set ($constant = $model.constantCase($defaultValue))
#if ($valueObject == "String")
- return ${aClassname}.DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)};
+ return ${aClassname}.DEFAULT_VALUE_${model.escapeKeyword($constant)};
#else
- return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)});
+ return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE_${model.escapeKeyword($constant)});
#end
#else
#if ($valueObject == "String")
@@ -223,7 +248,7 @@
#if ($valueObject == "String")
attr.setValue($aParam);
#else
- attr.set${signaturemodel.camelCase($simpleValue)}Value($aParam.${simpleValue}Value());
+ attr.set${model.camelCase($simpleValue)}Value($aParam.${simpleValue}Value());
#end
}
#end
@@ -237,8 +262,8 @@
#foreach($ch in $children)
#if ($ch != "*")
#set ($child = ${ch.withMultiples()})
-#set ($cClassname = "${signaturemodel.camelCase($child)}Element")
-#set ($cVar = ${signaturemodel.javaCase($child)})
+#set ($cClassname = "${model.camelCase($child.getLocalName())}Element")
+#set ($cVar = ${model.javaCase($child)})
#set ($ch_attributes = ${child.getAttributes().withoutMultiples()})
##set has parameter flag
#set ($hasParams = false)
@@ -255,7 +280,7 @@
#set ($params="")
#foreach ($ch_attr in $ch_attributes)
#if (${child.isMandatory($ch_attr)})
-#set($ch_attri = ${signaturemodel.getAttribute($ch_attr.getQName())})
+#set($ch_attri = ${model.getAttribute($ch_attr.getQName())})
#set ($ch_ValueObject = "String")
#set ($ch_SimpleValue = "")
#set ($ch_DataTypes = ${ch_attri.getDatatypes().withoutMultiples()})
@@ -290,8 +315,8 @@
#if ($ch_attr != "*")
#set ($attribute = ${ch_attr.withMultiples()})
#set ($aNS = ${attribute.getNamespace()})
-#set ($aClassname = "${signaturemodel.camelCase($attribute)}Attribute")
-#set ($aParam = "${signaturemodel.javaCase($attribute)}Value")
+#set ($aClassname = "${model.camelCase($attribute.getLocalName())}Attribute")
+#set ($aParam = "${model.javaCase($attribute.getLocalName())}Value")
* @param $aParam the <code>$ch_ValueObject</code> value of <code>$aClassname</code>, see {@odf.attribute ${attribute.getQName()}} at specification
#if ($ch_SimpleValue!="")
#set ($params="${params}${seperateFlag}${ch_SimpleValue} ${aParam}")
@@ -318,8 +343,8 @@
$cClassname $cVar = ((OdfFileDom) this.ownerDocument).newOdfElement(${cClassname}.class);
#foreach ($ch_attr in $ch_attributes)
#if ($ch_attr != "*" && ${child.isMandatory($ch_attr)})
-#set ($aClassname = "${signaturemodel.camelCase($ch_attr)}Attribute")
-#set ($aParam = "${signaturemodel.javaCase($ch_attr)}Value")
+#set ($aClassname = "${model.camelCase($ch_attr.getLocalName())}Attribute")
+#set ($aParam = "${model.javaCase($ch_attr.getLocalName())}Value")
${cVar}.set$aClassname($aParam);
#end
#end
@@ -362,7 +387,7 @@
* Add text content. Only elements which are allowed to have text content offer this method.
*/
public void newTextNode(String content) {
- if (content != null && !content.equals("")) {
+ if (content != null && !content.isEmpty()) {
this.appendChild(this.getOwnerDocument().createTextNode(content));
}
}
diff --git a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-attribute-template.vm b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-attribute-template.vm
index 7f025f5..9083006 100644
--- a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-attribute-template.vm
+++ b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-attribute-template.vm
@@ -18,17 +18,17 @@
## under the License.
##
##################################################################
-## Template to create the list of manifest artefacts which are to be generated
+
+## Template to create the list of artefacts which are to be generated
##
## Documentation of template development can be found in local file
## TemplateHelp.html.
##
## Returns PuzzleComponent covering a PuzzlePiece or PuzzlePieceSet dependent if attribute is multiple times defined
-#set($attribute = $manifestmodel.getAttribute($context))
-#set ($NS = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")
-#set($NS = ${attribute.getNamespace()})
-#set($localname = ${manifestmodel.extractLocalname($attribute)})
-#set($classname = "${manifestmodel.camelCase($attribute)}Attribute")
+#set($attribute = $model.getAttribute($context))
+#set($NS = $attribute.getNamespace())
+#set($localname = ${model.extractLocalname($attribute)})
+#set($classname = "${model.camelCase($attribute.getLocalName())}Attribute")
#set ($valueobject = "String")
##
#set($datatypes = ${attribute.getDatatypes().withoutMultiples()})
@@ -94,11 +94,14 @@
#end
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
#if ($hasDefaultValue and $defaultValueSet.size()>1)
#foreach ($parent in ${attribute.getParents().withoutMultiples()})
#if ($odfmodel.getDefaultAttributeValue($attribute, $parent))
-import org.odftoolkit.odfdom.pkg.${parent.getNamespace()}.${manifestmodel.camelCase($parent)}Element;
+#if (!$parent.equals("manifest")) ## Do not generate "import" for the same package!
+import org.odftoolkit.odfdom.pkg.manifest.${model.camelCase($parent.getLocalName())}Element;
+#end
#end
#end
#end
@@ -108,15 +111,15 @@
*/
public class $classname extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("${NS}", "manifest:${attribute}");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.${NS.toUpperCase()}, "$localname");
#if ($hasDefaultValue)
#if ($defaultValueSet.size()>1)
#foreach ($defaultValue in $defaultValueSet)
-#set ($constant = $manifestmodel.constantCase($defaultValue))
+#set ($constant = $model.constantCase($defaultValue))
#if (($defaultValue=="true" or $defaultValue=="false") and $enum == false)
- public static final String DEFAULT_VALUE_${manifestmodel.escapeKeyword($constant)}= "$defaultValue";
+ public static final String DEFAULT_VALUE_${model.escapeKeyword($constant)}= "$defaultValue";
#else
- public static final String DEFAULT_VALUE_${manifestmodel.escapeKeyword($constant)}= Value.${manifestmodel.escapeKeyword($constant)}.toString();
+ public static final String DEFAULT_VALUE_${model.escapeKeyword($constant)}= Value.${model.escapeKeyword($constant)}.toString();
#end
#end
#else
@@ -166,8 +169,8 @@
#if (${value.toString().length()} == 1)
#set ($constant = $value)
#else
-#set ($constant = $manifestmodel.constantCase($value))
-#end${separator}${manifestmodel.escapeKeyword($constant)}("${manifestmodel.escapeLiteral($value)}")#set ($separator=", ")
+#set ($constant = $model.constantCase($value))
+#end${separator}${model.escapeKeyword($constant)}("${model.escapeLiteral($value)}")#set ($separator=", ")
#end ;
private String mValue;
@@ -223,7 +226,7 @@
/**
* @param value The <code>${simplevalue}</code> value of the attribute.
*/
- public void set${manifestmodel.camelCase($simplevalue)}Value(${simplevalue} value) {
+ public void set${model.camelCase($simplevalue)}Value(${simplevalue} value) {
super.setValue(String.valueOf(value));
}
@@ -233,7 +236,7 @@
public ${simplevalue} ${simplevalue}Value() {
String val = super.getValue();
try {
- return ${valueobject}.parse${manifestmodel.camelCase($simplevalue)}(val);
+ return ${valueobject}.parse${model.camelCase($simplevalue)}(val);
} catch (NumberFormatException e) {
// TODO: validation handling/logging
throw (e);
@@ -317,13 +320,13 @@
#if ($defaultValueSet.size()>1)
#foreach ($parent in ${attribute.getParents().withoutMultiples()})
#if ($odfmodel.getDefaultAttributeValue($attribute, $parent))
- if (parentElement instanceof ${manifestmodel.camelCase($parent)}Element) {
- defaultValue = "${manifestmodel.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $parent))}";
+ if (parentElement instanceof ${model.camelCase($parent)}Element) {
+ defaultValue = "${model.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $parent))}";
}
#end
#end
#else
- defaultValue = "${manifestmodel.escapeLiteral($uniqueDefaultValue)}";
+ defaultValue = "${model.escapeLiteral($uniqueDefaultValue)}";
#end
}
return defaultValue;
diff --git a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-element-template.vm b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-element-template.vm
index 714aa99..8d0bd85 100644
--- a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-element-template.vm
+++ b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-element-template.vm
@@ -18,15 +18,16 @@
## under the License.
##
##################################################################
-## Template to create the Java class representing an ODF manifest element
+
+## Template to create the Java class representing an ODF element
##
## Documentation of template development can be found in local file
## TemplateHelp.html.
##
-#set ($element = ${manifestmodel.getElement($context)})
+#set ($element = ${model.getElement($context)})
#set ($oldelement = ${oldmodel.getElement($context)})
-###set ($NS = ${element.getNamespace()})
-#set ($classname = "${manifestmodel.camelCase($element)}Element")
+#set ($NS = ${element.getNamespace()})
+#set ($classname = "${model.camelCase($element.getLocalName())}Element")
##
## Set child element and child attributes
#set ($children = ${element.getChildElements().withoutMultiples()})
@@ -60,6 +61,26 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+
+##
+#foreach ($child in $attributes)
+#if ($child == "*")
+#set ($anyattribute = true)
+#else
+#set ($childNS = ${child.getNamespace()})
+#set ($childClassname = "${model.camelCase($child.getLocalName())}Attribute")
+#if (!$childNS.equals("manifest")) ## Do not generate "import" for the same package!
+import org.odftoolkit.odfdom.pkg.${childNS}.$childClassname;
+#end
+#end
+#end
+##
+## If there is a base class which is not in the current package
+#if ($baseimport)
+import ${baseimport};
+#end
+
##
## ---------------------------------------------------
## Class
@@ -77,7 +98,7 @@
*/
public class $classname extends $baseclassname {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:${element}");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.${NS.toUpperCase()}, "${element.getLocalName()}");
/**
* Create the instance of <code>$classname</code>
@@ -93,6 +114,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element ${context}}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -108,7 +130,7 @@
## ---------------------------------------------------
##
#foreach ($attr in $attributes)
-#set($attri = ${manifestmodel.getAttribute($attr.getQName())})
+#set($attri = ${model.getAttribute($attr.getQName())})
#set ($valueObject = "String")
#set ($simpleValue = "")
#set ($dataTypes = ${attri.getDatatypes().withoutMultiples()})
@@ -143,8 +165,8 @@
#if ($attr != "*")
#set ($attribute = ${attr.withMultiples()})
#set ($aNS = ${attribute.getNamespace()})
-#set ($aClassname = "${manifestmodel.camelCase($attribute)}Attribute")
-#set ($aParam = "${manifestmodel.javaCase($attribute)}Value")
+#set ($aClassname = "${model.camelCase($attribute.getLocalName())}Attribute")
+#set ($aParam = "${model.javaCase($attribute.getLocalName())}Value")
/**
* Receives the value of the ODFDOM attribute representation <code>$aClassname</code> , See {@odf.attribute ${attribute.getQName()}}
@@ -156,7 +178,7 @@
* @return - the <code>$valueObject</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public $valueObject get${aClassname}() {
- $aClassname attr = ($aClassname) getOdfAttribute(${aClassname}.ATTRIBUTE_NAME);
+ $aClassname attr = ($aClassname) getOdfAttribute(OdfPackageNamespace.${aNS.toUpperCase()}, "${attribute.getLocalName()}");
if (attr != null) {
#if ($simpleValue!="")
return ${valueObject}.valueOf(attr.${simpleValue}Value());
@@ -165,14 +187,14 @@
#end
}
#if ($odfmodel.getDefaultAttributeValue($attribute, $element))
-#set ($defaultValue = ${manifestmodel.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $element))})
+#set ($defaultValue = ${model.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $element))})
#set ($defaultValueSet = $odfmodel.getDefaultAttributeValues($attribute))
#if ($defaultValueSet.size()>1)
-#set ($constant = $manifestmodel.constantCase($defaultValue))
+#set ($constant = $model.constantCase($defaultValue))
#if ($valueObject == "String")
- return ${aClassname}.DEFAULT_VALUE_${manifestmodel.escapeKeyword($constant)};
+ return ${aClassname}.DEFAULT_VALUE_${model.escapeKeyword($constant)};
#else
- return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE_${manifestmodel.escapeKeyword($constant)});
+ return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE_${model.escapeKeyword($constant)});
#end
#else
#if ($valueObject == "String")
@@ -197,7 +219,7 @@
#if ($valueObject == "String")
attr.setValue($aParam);
#else
- attr.set${manifestmodel.camelCase($simpleValue)}Value($aParam.${simpleValue}Value());
+ attr.set${model.camelCase($simpleValue)}Value($aParam.${simpleValue}Value());
#end
}
#end
@@ -211,8 +233,8 @@
#foreach($ch in $children)
#if ($ch != "*")
#set ($child = ${ch.withMultiples()})
-#set ($cClassname = "${manifestmodel.camelCase($child)}Element")
-#set ($cVar = ${manifestmodel.javaCase($child)})
+#set ($cClassname = "${model.camelCase($child.getLocalName())}Element")
+#set ($cVar = ${model.javaCase($child)})
#set ($ch_attributes = ${child.getAttributes().withoutMultiples()})
##set has parameter flag
#set ($hasParams = false)
@@ -229,7 +251,7 @@
#set ($params="")
#foreach ($ch_attr in $ch_attributes)
#if (${child.isMandatory($ch_attr)})
-#set($ch_attri = ${manifestmodel.getAttribute($ch_attr.getQName())})
+#set($ch_attri = ${model.getAttribute($ch_attr.getQName())})
#set ($ch_ValueObject = "String")
#set ($ch_SimpleValue = "")
#set ($ch_DataTypes = ${ch_attri.getDatatypes().withoutMultiples()})
@@ -264,8 +286,8 @@
#if ($ch_attr != "*")
#set ($attribute = ${ch_attr.withMultiples()})
#set ($aNS = ${attribute.getNamespace()})
-#set ($aClassname = "${manifestmodel.camelCase($attribute)}Attribute")
-#set ($aParam = "${manifestmodel.javaCase($attribute)}Value")
+#set ($aClassname = "${model.camelCase($attribute.getLocalName())}Attribute")
+#set ($aParam = "${model.javaCase($attribute.getLocalName())}Value")
* @param $aParam the <code>$ch_ValueObject</code> value of <code>$aClassname</code>, see {@odf.attribute ${attribute.getQName()}} at specification
#if ($ch_SimpleValue!="")
#set ($params="${params}${seperateFlag}${ch_SimpleValue} ${aParam}")
@@ -292,8 +314,8 @@
$cClassname $cVar = ((OdfFileDom) this.ownerDocument).newOdfElement(${cClassname}.class);
#foreach ($ch_attr in $ch_attributes)
#if ($ch_attr != "*" && ${child.isMandatory($ch_attr)})
-#set ($aClassname = "${manifestmodel.camelCase($ch_attr)}Attribute")
-#set ($aParam = "${manifestmodel.javaCase($ch_attr)}Value")
+#set ($aClassname = "${model.camelCase($ch_attr.getLocalName())}Attribute")
+#set ($aParam = "${model.javaCase($ch_attr.getLocalName())}Value")
${cVar}.set$aClassname($aParam);
#end
#end
@@ -336,7 +358,7 @@
* Add text content. Only elements which are allowed to have text content offer this method.
*/
public void newTextNode(String content) {
- if (content != null && !content.equals("")) {
+ if (content != null && !content.isEmpty()) {
this.appendChild(this.getOwnerDocument().createTextNode(content));
}
}
diff --git a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-dsig-output-files.vm
similarity index 62%
copy from generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm
copy to generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-dsig-output-files.vm
index f5e3f81..19a9350 100644
--- a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm
+++ b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-dsig-output-files.vm
@@ -1,62 +1,45 @@
-##################################################################
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements. See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership. The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied. See the License for the
-## specific language governing permissions and limitations
-## under the License.
-##
-##################################################################
-<?xml version="1.0" encoding="UTF-8"?>
-## Template to create the list of artefacts which are to be generated
-##
-## Documentation of template development can be found in local file
-## src/main/resources/documentation/help.html
-##
-<filelist>
-##
-#foreach ($element in ${signaturemodel.getElements().withoutMultiples()})
-#if ($element != "*")
-##
-#set($classname = "${signaturemodel.camelCase($element)}Element")
- <file path="org/odftoolkit/odfdom/pkg/dsig/${classname}.java" context="$element" template="odfdom-dsig-element-template.vm" />
-##
-#end
-#end
-##
-#foreach ($attribute in ${signaturemodel.getAttributes().withoutMultiples()})
-#if ($attribute != "*")
-##
-#set($classname = "${signaturemodel.camelCase($attribute)}Attribute")
- <file path="org/odftoolkit/odfdom/pkg/dsig/${classname}.java" context="$attribute" template="odfdom-dsig-attribute-template.vm" />
-#end
-#end
-##
-#foreach ($element in ${manifestmodel.getElements().withoutMultiples()})
-#if ($element != "*")
-##
-#set($classname = "${manifestmodel.camelCase($element)}Element")
- <file path="org/odftoolkit/odfdom/pkg/manifest/${classname}.java" context="$element" template="odfdom-manifest-element-template.vm" />
-##
-#end
-#end
-##
-#foreach ($attribute in ${manifestmodel.getAttributes().withoutMultiples()})
-#if ($attribute != "*")
-##
-#set($classname = "${manifestmodel.camelCase($attribute)}Attribute")
- <file path="org/odftoolkit/odfdom/pkg/manifest/${classname}.java" context="$attribute" template="odfdom-manifest-attribute-template.vm" />
-#end
-#end
-</filelist>
+##################################################################
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+##################################################################
+<?xml version="1.0" encoding="UTF-8"?>
+## Template to create the list of artefacts which are to be generated
+##
+## Documentation of template development can be found in local file
+## src/main/resources/documentation/help.html
+##
+<filelist>
+##
+#foreach ($element in ${model.getElements().withoutMultiples()})
+#if ($element != "*")
+##
+#set($classname = "${model.camelCase($element.getLocalName())}Element")
+ <file path="org/odftoolkit/odfdom/pkg/dsig/${classname}.java" context="$element" template="odfdom-dsig-element-template.vm" />
+##
+#end
+#end
+##
+#foreach ($attribute in ${model.getAttributes().withoutMultiples()})
+#if ($attribute != "*")
+##
+#set($classname = "${model.camelCase($attribute.getLocalName())}Attribute")
+ <file path="org/odftoolkit/odfdom/pkg/dsig/${classname}.java" context="$attribute" template="odfdom-dsig-attribute-template.vm" />
+#end
+#end
+</filelist>
diff --git a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-manifest-output-files.vm
similarity index 62%
rename from generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm
rename to generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-manifest-output-files.vm
index f5e3f81..9f0cfc0 100644
--- a/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm
+++ b/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-manifest-output-files.vm
@@ -1,62 +1,44 @@
-##################################################################
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements. See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership. The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied. See the License for the
-## specific language governing permissions and limitations
-## under the License.
-##
-##################################################################
-<?xml version="1.0" encoding="UTF-8"?>
-## Template to create the list of artefacts which are to be generated
-##
-## Documentation of template development can be found in local file
-## src/main/resources/documentation/help.html
-##
-<filelist>
-##
-#foreach ($element in ${signaturemodel.getElements().withoutMultiples()})
-#if ($element != "*")
-##
-#set($classname = "${signaturemodel.camelCase($element)}Element")
- <file path="org/odftoolkit/odfdom/pkg/dsig/${classname}.java" context="$element" template="odfdom-dsig-element-template.vm" />
-##
-#end
-#end
-##
-#foreach ($attribute in ${signaturemodel.getAttributes().withoutMultiples()})
-#if ($attribute != "*")
-##
-#set($classname = "${signaturemodel.camelCase($attribute)}Attribute")
- <file path="org/odftoolkit/odfdom/pkg/dsig/${classname}.java" context="$attribute" template="odfdom-dsig-attribute-template.vm" />
-#end
-#end
-##
-#foreach ($element in ${manifestmodel.getElements().withoutMultiples()})
-#if ($element != "*")
-##
-#set($classname = "${manifestmodel.camelCase($element)}Element")
- <file path="org/odftoolkit/odfdom/pkg/manifest/${classname}.java" context="$element" template="odfdom-manifest-element-template.vm" />
-##
-#end
-#end
-##
-#foreach ($attribute in ${manifestmodel.getAttributes().withoutMultiples()})
-#if ($attribute != "*")
-##
-#set($classname = "${manifestmodel.camelCase($attribute)}Attribute")
- <file path="org/odftoolkit/odfdom/pkg/manifest/${classname}.java" context="$attribute" template="odfdom-manifest-attribute-template.vm" />
-#end
-#end
-</filelist>
+##################################################################
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+##################################################################
+<?xml version="1.0" encoding="UTF-8"?>
+## Template to create the list of artefacts which are to be generated
+##
+## Documentation of template development can be found in local file
+## src/main/resources/documentation/help.html
+##
+<filelist>
+#foreach ($element in ${model.getElements().withoutMultiples()})
+#if ($element != "*")
+##
+#set($classname = "${model.camelCase($element.getLocalName())}Element")
+ <file path="org/odftoolkit/odfdom/pkg/manifest/${classname}.java" context="$element" template="odfdom-manifest-element-template.vm" />
+##
+#end
+#end
+##
+#foreach ($attribute in ${model.getAttributes().withoutMultiples()})
+#if ($attribute != "*")
+##
+#set($classname = "${model.camelCase($attribute.getLocalName())}Attribute")
+ <file path="org/odftoolkit/odfdom/pkg/manifest/${classname}.java" context="$attribute" template="odfdom-manifest-attribute-template.vm" />
+#end
+#end
+</filelist>
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageNamespace.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageNamespace.java
index 461d955..f325014 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageNamespace.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageNamespace.java
@@ -26,8 +26,10 @@
public enum OdfPackageNamespace implements NamespaceName {
- MANIFEST("chart", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"),
- XML("xml", "http://www.w3.org/XML/1998/namespace" );
+ MANIFEST("manifest", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"),
+ XML("xml", "http://www.w3.org/XML/1998/namespace"),
+ DSIG("dsig", "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0"),
+ DS("ds", "http://www.w3.org/2000/09/xmldsig#");
private String mPrefix;
private String mUri;
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/DocumentSignaturesElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/DocumentSignaturesElement.java
index 9b4d949..44be07a 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/DocumentSignaturesElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/DocumentSignaturesElement.java
@@ -31,20 +31,21 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
- * DOM implementation of OpenDocument element {@odf.element dsig:document-signatures}.
+ * Data signature implementation of OpenDocument element {@odf.element dsig:document-signatures}.
*
*/
public class DocumentSignaturesElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0", "dsig:document-signatures");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.DSIG, "document-signatures");
/**
* Create the instance of <code>DocumentSignaturesElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public DocumentSignaturesElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,8 +54,9 @@
/**
* Get the element name
*
- * @return return <code>OdfName</code> the name of element {@odf.element dsig:document-signatures}.
+ * @return return <code>OdfName</code> the name of element {@odf.element dsig:document-signatures}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -67,7 +69,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getVersionAttribute() {
- VersionAttribute attr = (VersionAttribute) getOdfAttribute(VersionAttribute.ATTRIBUTE_NAME);
+ VersionAttribute attr = (VersionAttribute) getOdfAttribute(OdfPackageNamespace.DSIG, "version");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -95,9 +97,9 @@
* @return the element {@odf.element ds:Signature}
*/
public SignatureElement newSignatureElement() {
- SignatureElement signature = ((OdfFileDom) this.ownerDocument).newOdfElement(SignatureElement.class);
- this.appendChild(signature);
- return signature;
+ SignatureElement dsSignature = ((OdfFileDom) this.ownerDocument).newOdfElement(SignatureElement.class);
+ this.appendChild(dsSignature);
+ return dsSignature;
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/SignatureElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/SignatureElement.java
index 696ae4a..c7fa75e 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/SignatureElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/SignatureElement.java
@@ -31,20 +31,23 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
- * DOM implementation of OpenDocument element {@odf.element ds:Signature}.
+ * Data signature implementation of OpenDocument element {@odf.element ds:Signature}.
*
+ * This class can have any org.w3c.dom.Element child element.
+ * This class can have any org.w3c.dom.Attribute attribute.
*/
public class SignatureElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("http://www.w3.org/2000/09/xmldsig#", "ds:Signature");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.DS, "Signature");
/**
* Create the instance of <code>SignatureElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public SignatureElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,8 +56,9 @@
/**
* Get the element name
*
- * @return return <code>OdfName</code> the name of element {@odf.element ds:Signature}.
+ * @return return <code>OdfName</code> the name of element {@odf.element ds:Signature}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -63,7 +67,7 @@
* Add text content. Only elements which are allowed to have text content offer this method.
*/
public void newTextNode(String content) {
- if (content != null && !content.equals("")) {
+ if (content != null && !content.isEmpty()) {
this.appendChild(this.getOwnerDocument().createTextNode(content));
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/VersionAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/VersionAttribute.java
index 32fed37..5617f2a 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/VersionAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/dsig/VersionAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* DOM implementation of OpenDocument attribute {@odf.attribute dsig:version}.
@@ -38,7 +40,7 @@
*/
public class VersionAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0", "dsig:version");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.DSIG, "version");
/**
* Create the instance of OpenDocument attribute {@odf.attribute dsig:version}.
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmElement.java
index e70d8b0..2edef02 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmElement.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,18 +32,21 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+
+
/**
* Manifest implementation of OpenDocument element {@odf.element manifest:algorithm}.
*
*/
public class AlgorithmElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:algorithm");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "algorithm");
/**
* Create the instance of <code>AlgorithmElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public AlgorithmElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,6 +57,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element manifest:algorithm}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -65,7 +70,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getAlgorithmNameAttribute() {
- AlgorithmNameAttribute attr = (AlgorithmNameAttribute) getOdfAttribute(AlgorithmNameAttribute.ATTRIBUTE_NAME);
+ AlgorithmNameAttribute attr = (AlgorithmNameAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "algorithm-name");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -91,7 +96,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getInitialisationVectorAttribute() {
- InitialisationVectorAttribute attr = (InitialisationVectorAttribute) getOdfAttribute(InitialisationVectorAttribute.ATTRIBUTE_NAME);
+ InitialisationVectorAttribute attr = (InitialisationVectorAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "initialisation-vector");
if (attr != null) {
return String.valueOf(attr.getValue());
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmNameAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmNameAttribute.java
index 60c04a3..c592b8d 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmNameAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/AlgorithmNameAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:algorithm-name}.
@@ -38,7 +40,7 @@
*/
public class AlgorithmNameAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:algorithm-name");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "algorithm-name");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:algorithm-name}.
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumAttribute.java
index 159bf53..79929d1 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:checksum}.
@@ -38,7 +40,7 @@
*/
public class ChecksumAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:checksum");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "checksum");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:checksum}.
@@ -93,7 +95,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of checksum is not valid");
+ throw new NumberFormatException("the value of manifest:checksum is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumTypeAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumTypeAttribute.java
index 445b1f6..c7b99f5 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumTypeAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ChecksumTypeAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:checksum-type}.
@@ -38,7 +40,7 @@
*/
public class ChecksumTypeAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:checksum-type");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "checksum-type");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:checksum-type}.
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/EncryptionDataElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/EncryptionDataElement.java
index 8e3aa02..5add791 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/EncryptionDataElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/EncryptionDataElement.java
@@ -1,9 +1,10 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- *
+ *
* Use is subject to license terms.
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -32,19 +33,20 @@
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
-import org.w3c.dom.NodeList;
+
+
/**
* Manifest implementation of OpenDocument element {@odf.element manifest:encryption-data}.
*
*/
public class EncryptionDataElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:encryption-data");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "encryption-data");
/**
* Create the instance of <code>EncryptionDataElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public EncryptionDataElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -55,6 +57,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element manifest:encryption-data}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -67,7 +70,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getChecksumAttribute() {
- ChecksumAttribute attr = (ChecksumAttribute) getOdfAttribute(ChecksumAttribute.ATTRIBUTE_NAME);
+ ChecksumAttribute attr = (ChecksumAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "checksum");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -93,7 +96,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getChecksumTypeAttribute() {
- ChecksumTypeAttribute attr = (ChecksumTypeAttribute) getOdfAttribute(ChecksumTypeAttribute.ATTRIBUTE_NAME);
+ ChecksumTypeAttribute attr = (ChecksumTypeAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "checksum-type");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -123,25 +126,11 @@
* @return the element {@odf.element manifest:algorithm}
*/
public AlgorithmElement newAlgorithmElement(String algorithmNameValue, String initialisationVectorValue) {
- AlgorithmElement algorithm = ((OdfFileDom) this.ownerDocument).newOdfElement(AlgorithmElement.class);
- algorithm.setAlgorithmNameAttribute(algorithmNameValue);
- algorithm.setInitialisationVectorAttribute(initialisationVectorValue);
- if(this.hasChildNodes()){
- OdfElement precedingSibling = null;
- NodeList nl = this.getElementsByTagNameNS(OdfPackageNamespace.MANIFEST.getUri(), "start-key-generation");
- if(nl.getLength() == 0){
- nl = this.getElementsByTagNameNS(OdfPackageNamespace.MANIFEST.getUri(), "key-derivation");
- }
- if(nl.getLength() != 0){
- precedingSibling = (OdfElement) nl.item(0);
- this.insertBefore(algorithm, precedingSibling);
- }else{
- this.appendChild(algorithm);
- }
- }else{
- this.appendChild(algorithm);
- }
- return algorithm;
+ AlgorithmElement manifestAlgorithm = ((OdfFileDom) this.ownerDocument).newOdfElement(AlgorithmElement.class);
+ manifestAlgorithm.setAlgorithmNameAttribute(algorithmNameValue);
+ manifestAlgorithm.setInitialisationVectorAttribute(initialisationVectorValue);
+ this.appendChild(manifestAlgorithm);
+ return manifestAlgorithm;
}
/**
@@ -157,12 +146,12 @@
* @return the element {@odf.element manifest:key-derivation}
*/
public KeyDerivationElement newKeyDerivationElement(int iterationCountValue, String keyDerivationNameValue, String saltValue) {
- KeyDerivationElement keyDerivation = ((OdfFileDom) this.ownerDocument).newOdfElement(KeyDerivationElement.class);
- keyDerivation.setIterationCountAttribute(iterationCountValue);
- keyDerivation.setKeyDerivationNameAttribute(keyDerivationNameValue);
- keyDerivation.setSaltAttribute(saltValue);
- this.appendChild(keyDerivation);
- return keyDerivation;
+ KeyDerivationElement manifestKeyDerivation = ((OdfFileDom) this.ownerDocument).newOdfElement(KeyDerivationElement.class);
+ manifestKeyDerivation.setIterationCountAttribute(iterationCountValue);
+ manifestKeyDerivation.setKeyDerivationNameAttribute(keyDerivationNameValue);
+ manifestKeyDerivation.setSaltAttribute(saltValue);
+ this.appendChild(manifestKeyDerivation);
+ return manifestKeyDerivation;
}
/**
@@ -174,22 +163,10 @@
* @return the element {@odf.element manifest:start-key-generation}
*/
public StartKeyGenerationElement newStartKeyGenerationElement(String startKeyGenerationNameValue) {
- StartKeyGenerationElement startKeyGeneration = ((OdfFileDom) this.ownerDocument).newOdfElement(StartKeyGenerationElement.class);
- startKeyGeneration.setStartKeyGenerationNameAttribute(startKeyGenerationNameValue);
-
- if(this.hasChildNodes()){
- OdfElement precedingSibling = null;
- NodeList nl = this.getElementsByTagNameNS(OdfPackageNamespace.MANIFEST.getUri(), "key-derivation");
- if(nl.getLength() != 0){
- precedingSibling = (OdfElement) nl.item(0);
- this.insertBefore(startKeyGeneration, precedingSibling);
- }else{
- this.appendChild(startKeyGeneration);
- }
- }else{
- this.appendChild(startKeyGeneration);
- }
- return startKeyGeneration;
+ StartKeyGenerationElement manifestStartKeyGeneration = ((OdfFileDom) this.ownerDocument).newOdfElement(StartKeyGenerationElement.class);
+ manifestStartKeyGeneration.setStartKeyGenerationNameAttribute(startKeyGenerationNameValue);
+ this.appendChild(manifestStartKeyGeneration);
+ return manifestStartKeyGeneration;
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FileEntryElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FileEntryElement.java
index 0962b41..69fdfd6 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FileEntryElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FileEntryElement.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,18 +32,21 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+
+
/**
* Manifest implementation of OpenDocument element {@odf.element manifest:file-entry}.
*
*/
public class FileEntryElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:file-entry");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "file-entry");
/**
* Create the instance of <code>FileEntryElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public FileEntryElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,6 +57,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element manifest:file-entry}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -65,7 +70,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getFullPathAttribute() {
- FullPathAttribute attr = (FullPathAttribute) getOdfAttribute(FullPathAttribute.ATTRIBUTE_NAME);
+ FullPathAttribute attr = (FullPathAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "full-path");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -91,7 +96,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getMediaTypeAttribute() {
- MediaTypeAttribute attr = (MediaTypeAttribute) getOdfAttribute(MediaTypeAttribute.ATTRIBUTE_NAME);
+ MediaTypeAttribute attr = (MediaTypeAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "media-type");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -115,7 +120,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getPreferredViewModeAttribute() {
- PreferredViewModeAttribute attr = (PreferredViewModeAttribute) getOdfAttribute(PreferredViewModeAttribute.ATTRIBUTE_NAME);
+ PreferredViewModeAttribute attr = (PreferredViewModeAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "preferred-view-mode");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -139,7 +144,7 @@
* @return - the <code>Integer</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public Integer getSizeAttribute() {
- SizeAttribute attr = (SizeAttribute) getOdfAttribute(SizeAttribute.ATTRIBUTE_NAME);
+ SizeAttribute attr = (SizeAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "size");
if (attr != null) {
return Integer.valueOf(attr.intValue());
}
@@ -163,7 +168,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getVersionAttribute() {
- VersionAttribute attr = (VersionAttribute) getOdfAttribute(VersionAttribute.ATTRIBUTE_NAME);
+ VersionAttribute attr = (VersionAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "version");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -191,11 +196,11 @@
* @return the element {@odf.element manifest:encryption-data}
*/
public EncryptionDataElement newEncryptionDataElement(String checksumValue, String checksumTypeValue) {
- EncryptionDataElement encryptionData = ((OdfFileDom) this.ownerDocument).newOdfElement(EncryptionDataElement.class);
- encryptionData.setChecksumAttribute(checksumValue);
- encryptionData.setChecksumTypeAttribute(checksumTypeValue);
- this.appendChild(encryptionData);
- return encryptionData;
+ EncryptionDataElement manifestEncryptionData = ((OdfFileDom) this.ownerDocument).newOdfElement(EncryptionDataElement.class);
+ manifestEncryptionData.setChecksumAttribute(checksumValue);
+ manifestEncryptionData.setChecksumTypeAttribute(checksumTypeValue);
+ this.appendChild(manifestEncryptionData);
+ return manifestEncryptionData;
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FullPathAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FullPathAttribute.java
index e21a0f4..f866d84 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FullPathAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/FullPathAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:full-path}.
@@ -38,7 +40,7 @@
*/
public class FullPathAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:full-path");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "full-path");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:full-path}.
@@ -93,7 +95,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of full-path is not valid");
+ throw new NumberFormatException("the value of manifest:full-path is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/InitialisationVectorAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/InitialisationVectorAttribute.java
index 525de5c..754cf84 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/InitialisationVectorAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/InitialisationVectorAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:initialisation-vector}.
@@ -38,7 +40,7 @@
*/
public class InitialisationVectorAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:initialisation-vector");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "initialisation-vector");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:initialisation-vector}.
@@ -93,7 +95,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of initialisation-vector is not valid");
+ throw new NumberFormatException("the value of manifest:initialisation-vector is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/IterationCountAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/IterationCountAttribute.java
index 6a250b2..7cae61b 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/IterationCountAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/IterationCountAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:iteration-count}.
@@ -38,7 +40,7 @@
*/
public class IterationCountAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:iteration-count");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "iteration-count");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:iteration-count}.
@@ -113,7 +115,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of iteration-count is not valid");
+ throw new NumberFormatException("the value of manifest:iteration-count is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationElement.java
index c85ce80..7e97079 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationElement.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,18 +32,21 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+
+
/**
* Manifest implementation of OpenDocument element {@odf.element manifest:key-derivation}.
*
*/
public class KeyDerivationElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:key-derivation");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "key-derivation");
/**
* Create the instance of <code>KeyDerivationElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public KeyDerivationElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,6 +57,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element manifest:key-derivation}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -65,7 +70,7 @@
* @return - the <code>Integer</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public Integer getIterationCountAttribute() {
- IterationCountAttribute attr = (IterationCountAttribute) getOdfAttribute(IterationCountAttribute.ATTRIBUTE_NAME);
+ IterationCountAttribute attr = (IterationCountAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "iteration-count");
if (attr != null) {
return Integer.valueOf(attr.intValue());
}
@@ -91,7 +96,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getKeyDerivationNameAttribute() {
- KeyDerivationNameAttribute attr = (KeyDerivationNameAttribute) getOdfAttribute(KeyDerivationNameAttribute.ATTRIBUTE_NAME);
+ KeyDerivationNameAttribute attr = (KeyDerivationNameAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "key-derivation-name");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -115,7 +120,7 @@
* @return - the <code>Integer</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public Integer getKeySizeAttribute() {
- KeySizeAttribute attr = (KeySizeAttribute) getOdfAttribute(KeySizeAttribute.ATTRIBUTE_NAME);
+ KeySizeAttribute attr = (KeySizeAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "key-size");
if (attr != null) {
return Integer.valueOf(attr.intValue());
}
@@ -141,7 +146,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getSaltAttribute() {
- SaltAttribute attr = (SaltAttribute) getOdfAttribute(SaltAttribute.ATTRIBUTE_NAME);
+ SaltAttribute attr = (SaltAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "salt");
if (attr != null) {
return String.valueOf(attr.getValue());
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationNameAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationNameAttribute.java
index c345d27..6755038 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationNameAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeyDerivationNameAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:key-derivation-name}.
@@ -38,7 +40,7 @@
*/
public class KeyDerivationNameAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:key-derivation-name");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "key-derivation-name");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:key-derivation-name}.
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeySizeAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeySizeAttribute.java
index 2c1437a..35435bd 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeySizeAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/KeySizeAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:key-size}.
@@ -38,7 +40,7 @@
*/
public class KeySizeAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:key-size");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "key-size");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:key-size}.
@@ -113,7 +115,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of key-size is not valid");
+ throw new NumberFormatException("the value of manifest:key-size is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ManifestElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ManifestElement.java
index e8ce4dc..774dc27 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ManifestElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ManifestElement.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,18 +32,21 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+
+
/**
* Manifest implementation of OpenDocument element {@odf.element manifest:manifest}.
*
*/
public class ManifestElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:manifest");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "manifest");
/**
* Create the instance of <code>ManifestElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public ManifestElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,6 +57,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element manifest:manifest}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -65,7 +70,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getVersionAttribute() {
- VersionAttribute attr = (VersionAttribute) getOdfAttribute(VersionAttribute.ATTRIBUTE_NAME);
+ VersionAttribute attr = (VersionAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "version");
if (attr != null) {
return String.valueOf(attr.getValue());
}
@@ -95,11 +100,11 @@
* @return the element {@odf.element manifest:file-entry}
*/
public FileEntryElement newFileEntryElement(String fullPathValue, String mediaTypeValue) {
- FileEntryElement fileEntry = ((OdfFileDom) this.ownerDocument).newOdfElement(FileEntryElement.class);
- fileEntry.setFullPathAttribute(fullPathValue);
- fileEntry.setMediaTypeAttribute(mediaTypeValue);
- this.appendChild(fileEntry);
- return fileEntry;
+ FileEntryElement manifestFileEntry = ((OdfFileDom) this.ownerDocument).newOdfElement(FileEntryElement.class);
+ manifestFileEntry.setFullPathAttribute(fullPathValue);
+ manifestFileEntry.setMediaTypeAttribute(mediaTypeValue);
+ this.appendChild(manifestFileEntry);
+ return manifestFileEntry;
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/MediaTypeAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/MediaTypeAttribute.java
index c3aab9c..7195567 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/MediaTypeAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/MediaTypeAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:media-type}.
@@ -38,7 +40,7 @@
*/
public class MediaTypeAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "media-type");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:media-type}.
@@ -93,7 +95,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of media-type is not valid");
+ throw new NumberFormatException("the value of manifest:media-type is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfManifestDom.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfManifestDom.java
index 43d68d9..33c7e8c 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfManifestDom.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfManifestDom.java
@@ -25,23 +25,22 @@
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
-
import org.odftoolkit.odfdom.dom.OdfSchemaDocument;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfPackage;
/**
* The DOM representation of the ODF manifest.xml file of an ODF document.
- *
+ *
* @since 0.8.9
*/
public class OdfManifestDom extends OdfFileDom {
-
+
private static final long serialVersionUID = 8149848234988627233L;
-
+
/**
* Creates the DOM representation of an XML file of an Odf document.
- *
+ *
* @param odfDocument
* the document the XML files belongs to
* @param packagePath
@@ -50,10 +49,10 @@
public OdfManifestDom(OdfSchemaDocument odfDocument, String packagePath) {
super(odfDocument, packagePath);
}
-
+
/**
* Creates the DOM representation of an XML file of an Odf document.
- *
+ *
* @param pkg
* the package the XML files belongs to
* @param packagePath
@@ -62,7 +61,7 @@
public OdfManifestDom(OdfPackage pkg, String packagePath) {
super(pkg, packagePath);
}
-
+
/**
* Might be used to initialize specific XML Namespace prefixes/URIs for this
* XML file
@@ -73,7 +72,7 @@
mPrefixByUri.put("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest");
super.initialize();
}
-
+
/**
* @return The root element <manifest:manifest > of the manifest.xml file as
* <code>ManifestElement</code>.
@@ -82,12 +81,12 @@
public ManifestElement getRootElement() {
return (ManifestElement) getDocumentElement();
}
-
+
/**
* Creates an JDK <code>XPath</code> instance. Initialized with ODF
* namespaces from <code>OdfDocumentNamespace</code>. Updated with all
* namespace of the XML file.
- *
+ *
* @return an XPath instance with namespace context set to include the
* standard ODFDOM prefixes.
*/
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/PreferredViewModeAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/PreferredViewModeAttribute.java
index e6cb6af..f0d770e 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/PreferredViewModeAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/PreferredViewModeAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:preferred-view-mode}.
@@ -38,7 +40,7 @@
*/
public class PreferredViewModeAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:preferred-view-mode");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "preferred-view-mode");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:preferred-view-mode}.
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SaltAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SaltAttribute.java
index 8dd6016..9a71be7 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SaltAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SaltAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:salt}.
@@ -38,7 +40,7 @@
*/
public class SaltAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:salt");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "salt");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:salt}.
@@ -93,7 +95,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of salt is not valid");
+ throw new NumberFormatException("the value of manifest:salt is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SizeAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SizeAttribute.java
index 529f033..ddcf305 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SizeAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/SizeAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:size}.
@@ -38,7 +40,7 @@
*/
public class SizeAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:size");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "size");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:size}.
@@ -113,7 +115,7 @@
return super.getValue();
} catch (IllegalArgumentException e) {
// TODO: validation handling/logging
- throw new NumberFormatException("the value of size is not valid");
+ throw new NumberFormatException("the value of manifest:size is not valid");
}
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationElement.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationElement.java
index 5f37287..ccacf21 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationElement.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationElement.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,18 +32,21 @@
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
+
+
/**
* Manifest implementation of OpenDocument element {@odf.element manifest:start-key-generation}.
*
*/
public class StartKeyGenerationElement extends OdfElement {
- public static final OdfName ELEMENT_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:start-key-generation");
+ public static final OdfName ELEMENT_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "start-key-generation");
/**
* Create the instance of <code>StartKeyGenerationElement</code>
*
- * @param ownerDoc The type is <code>OdfFileDom</code>
+ * @param ownerDoc The type is <code>OdfFileDom</code>
*/
public StartKeyGenerationElement(OdfFileDom ownerDoc) {
super(ownerDoc, ELEMENT_NAME);
@@ -53,6 +57,7 @@
*
* @return return <code>OdfName</code> the name of element {@odf.element manifest:start-key-generation}.
*/
+ @Override
public OdfName getOdfName() {
return ELEMENT_NAME;
}
@@ -63,7 +68,7 @@
* @return - the <code>Integer</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public Integer getKeySizeAttribute() {
- KeySizeAttribute attr = (KeySizeAttribute) getOdfAttribute(KeySizeAttribute.ATTRIBUTE_NAME);
+ KeySizeAttribute attr = (KeySizeAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "key-size");
if (attr != null) {
return Integer.valueOf(attr.intValue());
}
@@ -89,7 +94,7 @@
* @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public String getStartKeyGenerationNameAttribute() {
- StartKeyGenerationNameAttribute attr = (StartKeyGenerationNameAttribute) getOdfAttribute(StartKeyGenerationNameAttribute.ATTRIBUTE_NAME);
+ StartKeyGenerationNameAttribute attr = (StartKeyGenerationNameAttribute) getOdfAttribute(OdfPackageNamespace.MANIFEST, "start-key-generation-name");
if (attr != null) {
return String.valueOf(attr.getValue());
}
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationNameAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationNameAttribute.java
index 4d4687c..952c53d 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationNameAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/StartKeyGenerationNameAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:start-key-generation-name}.
@@ -38,7 +40,7 @@
*/
public class StartKeyGenerationNameAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:start-key-generation-name");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "start-key-generation-name");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:start-key-generation-name}.
diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/VersionAttribute.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/VersionAttribute.java
index c14edde..58adaca 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/VersionAttribute.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/VersionAttribute.java
@@ -1,3 +1,4 @@
+
/************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
@@ -31,6 +32,7 @@
import org.odftoolkit.odfdom.pkg.OdfAttribute;
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.pkg.OdfPackageNamespace;
/**
* Manifest implementation of OpenDocument attribute {@odf.attribute manifest:version}.
@@ -38,7 +40,7 @@
*/
public class VersionAttribute extends OdfAttribute {
- public static final OdfName ATTRIBUTE_NAME = OdfName.newName("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:version");
+ public static final OdfName ATTRIBUTE_NAME = OdfName.newName(OdfPackageNamespace.MANIFEST, "version");
/**
* Create the instance of OpenDocument attribute {@odf.attribute manifest:version}.