incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1244419 [1/2] - in /incubator/odf/trunk/generator: schema2template-maven-plugin/src/main/java/org/odftoolkit/odfdom/schema2template_maven_plugin/ schema2template/ schema2template/src/main/java/schema2template/example/odf/ schema2template/s...
Date Wed, 15 Feb 2012 09:43:11 GMT
Author: devinhan
Date: Wed Feb 15 09:43:09 2012
New Revision: 1244419

URL: http://svn.apache.org/viewvc?rev=1244419&view=rev
Log:
#ODFTOOLKIT-199# Supply signature and manifest features to code generator plugin.[Developer:Devin]

Added:
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/dom-output-files.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/output-files.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/copyright.txt
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/copyright.txt
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/dom-output-files.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-attribute-template.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-attribute-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-attribute-visitor.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-attribute-visitor.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-element-template.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-element-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-element-visitor.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-element-visitor.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-elementbase-template.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-elementbase-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-stylefamily.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-stylefamily.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-styleproperties.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-styleproperties.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/java-odfdom-styleset.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-styleset.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/copyright.txt
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-attribute-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-manifest-element-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/pkg-output-files.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/dom-output-files.vm
      - copied unchanged from r1212266, incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/output-files.vm
Removed:
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odf-reference/output-files.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/copyright.txt
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-attribute-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-attribute-visitor.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-element-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-element-visitor.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-elementbase-template.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-stylefamily.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-styleproperties.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/java-odfdom-styleset.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/output-files.vm
    incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-python/output-files.vm
Modified:
    incubator/odf/trunk/generator/schema2template-maven-plugin/src/main/java/org/odftoolkit/odfdom/schema2template_maven_plugin/CodegenMojo.java
    incubator/odf/trunk/generator/schema2template/pom.xml
    incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
    incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/SourceCodeModel.java

Modified: incubator/odf/trunk/generator/schema2template-maven-plugin/src/main/java/org/odftoolkit/odfdom/schema2template_maven_plugin/CodegenMojo.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template-maven-plugin/src/main/java/org/odftoolkit/odfdom/schema2template_maven_plugin/CodegenMojo.java?rev=1244419&r1=1244418&r2=1244419&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template-maven-plugin/src/main/java/org/odftoolkit/odfdom/schema2template_maven_plugin/CodegenMojo.java (original)
+++ incubator/odf/trunk/generator/schema2template-maven-plugin/src/main/java/org/odftoolkit/odfdom/schema2template_maven_plugin/CodegenMojo.java Wed Feb 15 09:43:09 2012
@@ -42,7 +42,7 @@ public class CodegenMojo extends Abstrac
 	 * @parameter
 	 * @required
 	 */
-	File resourceRoot;
+	File domResourceRoot;
 	
 	/**
 	 * @parameter
@@ -60,7 +60,19 @@ public class CodegenMojo extends Abstrac
 	 * @parameter
 	 * @required
 	 */
-	String configFile;
+	File pkgResourceRoot;
+	
+	/**
+	 * @parameter
+	 * @required
+	 */
+	String signatureSchemaFile;
+	
+	/**
+	 * @parameter
+	 * @required
+	 */
+	String manifestSchemaFile;
 	
 	/**
 	 * @parameter
@@ -69,6 +81,12 @@ public class CodegenMojo extends Abstrac
 	File targetRoot;
 	
 	/**
+	 * @parameter
+	 * @required
+	 */
+	String configFile;
+	
+	/**
 	 * @parameter expression="${project}"
 	 * @required
 	 */
@@ -93,22 +111,38 @@ public class CodegenMojo extends Abstrac
 				getLog().error("Please set odf1.1 schema file patch.");
 				throw new MojoFailureException("Please set schema file patch.");
 			}
+			if (signatureSchemaFile == null) {
+				getLog().error("Please set odf1.2 document signature schema file patch.");
+				throw new MojoFailureException("Please set schema file patch.");
+			}
+			if (manifestSchemaFile == null) {
+				getLog().error("Please set odf1.2 manifest schema file patch.");
+				throw new MojoFailureException("Please set schema file patch.");
+			}
 			String targetRootPath = targetRoot.getAbsolutePath();
 			if (targetRootPath == null) {
 				getLog().error("Please set generation code root patch.");
 				throw new MojoFailureException("Please set generation code root patch.");
 			}
-			String resourceRootPath = resourceRoot.getAbsolutePath();
-			if (resourceRootPath == null) {
-				getLog().error("Please set templates root patch.");
+			String domResourceRootPath = domResourceRoot.getAbsolutePath();
+			if (domResourceRootPath == null) {
+				getLog().error("Please set dom templates root patch.");
+				throw new MojoFailureException("Please set templates root patch.");
+			}
+			String pkgResourceRootPath = pkgResourceRoot.getAbsolutePath();
+			if (pkgResourceRootPath == null) {
+				getLog().error("Please set pkg templates root patch.");
 				throw new MojoFailureException("Please set templates root patch.");
 			}
-			getLog().debug("Template Files Directory " + resourceRootPath);
 			getLog().debug("Generation Code Files Root Directory " + targetRootPath);
+			getLog().debug("Config File " + configFile);
+			getLog().debug("Dom Template Files Directory " + domResourceRootPath);
 			getLog().debug("ODF1.2 Schema File " + odf12SchemaFile);
 			getLog().debug("ODF1.1 Schema File " + odf11SchemaFile);
-			getLog().debug("Config File " + configFile);
-			OdfHelper codeGen = new OdfHelper(resourceRootPath, targetRootPath, odf12SchemaFile, odf11SchemaFile, configFile);
+			getLog().debug("Pkg Template Files Directory " + pkgResourceRootPath);
+			getLog().debug("ODF1.2 Signature Schema File " + signatureSchemaFile);
+			getLog().debug("ODF1.2 Manifest Schema File " + manifestSchemaFile);
+			OdfHelper codeGen = new OdfHelper(domResourceRootPath, odf12SchemaFile, odf11SchemaFile, pkgResourceRootPath, signatureSchemaFile, manifestSchemaFile, targetRootPath, configFile);
 			codeGen.start();
 		} catch (Exception ex) {
 			getLog().error("Failed to parse template.");

Modified: incubator/odf/trunk/generator/schema2template/pom.xml
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/pom.xml?rev=1244419&r1=1244418&r2=1244419&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/pom.xml (original)
+++ incubator/odf/trunk/generator/schema2template/pom.xml Wed Feb 15 09:43:09 2012
@@ -1,241 +1,263 @@
-<?xml version="1.0"?>
-
-<!--
-  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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.odftoolkit</groupId>
-    <artifactId>schema2template-pom</artifactId>
-    <version>0.8.9-incubating-SNAPSHOT</version>
-  </parent>
-  
-    <!-- The Basics -->
-    <artifactId>schema2template</artifactId>
-    <version>0.8.9-incubating-SNAPSHOT</version>
-    <packaging>jar</packaging>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.velocity</groupId>
-            <artifactId>velocity</artifactId>
-            <version>1.6.4</version>
-        </dependency>
-        <dependency>
-            <groupId>net.java.dev.msv</groupId>
-            <artifactId>msv-core</artifactId>
-            <version>2009.1</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.5</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-    
-    <!-- Build Settings -->
-    <build>
-        <extensions>
-            <extension>
-                <groupId>org.apache.maven.wagon</groupId>
-                <artifactId>wagon-webdav-jackrabbit</artifactId>
-                <version>1.0-beta-7</version>
-            </extension>
-        </extensions>
-        <plugins>
-            <plugin>
-                <artifactId>maven-jar-plugin</artifactId>
-                <version>2.3.1</version>
-                <configuration>
-                    <archive>
-                        <index>true</index>
-                        <manifest>
-                            <mainClass>schema2template.example.odf.OdfHelper</mainClass>
-                        </manifest>
-                        <manifestEntries>
-                            <version>${project.version}</version>
-                        </manifestEntries>
-                        <manifestSections>
-                            <manifestSection>
-                                <name>schema2template</name>
-                                <manifestEntries>
-                                    <Application-Name>schema2template</Application-Name>
-                                    <Application-Version>${project.version}</Application-Version>
-                                    <Application-Website>http://incubator.apache.org/odftoolkit/</Application-Website>
-                                    <Built-By>${user.name}</Built-By>
-                                    <Built-Date>${build.timestamp}</Built-Date>
-                                </manifestEntries>
-                            </manifestSection>
-                        </manifestSections>
-                    </archive>
-                </configuration>
-            </plugin>
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <!-- Explizit version required for fix on systemPropertyVariables -->
-                <version>2.6</version>
-                <configuration>
-                    <systemPropertyVariables>
-                        <odfdom.version>${project.version}</odfdom.version>
-                        <odfdom.timestamp>${build.timestamp}</odfdom.timestamp>
-                    </systemPropertyVariables>
-                    <excludes>
-                        <exclude>**/integrationtest/**</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.0.2</version>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                    <showDeprecation>true</showDeprecation>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.rat</groupId>
-                <artifactId>apache-rat-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>src/test/resources/examples/odf/*.ref</exclude>
-                        <exclude>src/main/resources/examples/odf/odfdom-python/OdfTextDocument.odt</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-            <plugin>
-                  <groupId>org.codehaus.mojo</groupId>
-                  <artifactId>wagon-maven-plugin</artifactId>
-                  <version>1.0-beta-3</version>
-                  <executions>
-                    <execution>
-                          <id>download-odf-schema-v1.2</id>
-                          <phase>process-resources</phase>
-                          <goals>
-                            <goal>download-single</goal>
-                          </goals>
-                          <configuration>
-                            <url>dav:http://docs.oasis-open.org/office/v1.2</url>
-                            <fromFile>cs01/OpenDocument-v1.2-cs01-schema.rng</fromFile>
-                            <toDir>${project.build.directory}/odf-schemas</toDir>
-                          </configuration>
-                    </execution>
-                    <execution>
-                          <id>download-odf-schema-v1.1</id>
-                          <phase>process-resources</phase>
-                          <goals>
-                            <goal>download-single</goal>
-                          </goals>
-                          <configuration>
-                            <url>dav:http://docs.oasis-open.org/office/v1.1</url>
-                            <fromFile>OS/OpenDocument-schema-v1.1.rng</fromFile>
-                            <toDir>${project.build.directory}/odf-schemas</toDir>
-                          </configuration>
-                    </execution>
-                    <execution>
-                          <id>download-odf-strict-schema-v1.1</id>
-                          <phase>process-resources</phase>
-                          <goals>
-                            <goal>download-single</goal>
-                          </goals>
-                          <configuration>
-                            <url>dav:http://docs.oasis-open.org/office/v1.1</url>
-                            <fromFile>OS/OpenDocument-strict-schema-v1.1.rng</fromFile>
-                            <toDir>${project.build.directory}/odf-schemas</toDir>
-                          </configuration>
-                    </execution>
-                    <execution>
-                          <id>download-odf-schema-v1.0</id>
-                          <phase>process-resources</phase>
-                          <goals>
-                            <goal>download-single</goal>
-                          </goals>
-                          <configuration>
-                            <url>dav:http://www.oasis-open.org/committees/download.php/12571</url>
-                            <fromFile>OpenDocument-schema-v1.0-os.rng</fromFile>
-                            <toDir>${project.build.directory}/odf-schemas</toDir>
-                          </configuration>
-                    </execution>
-                    <execution>
-                          <id>download-odf-strict-schema-v1.0</id>
-                          <phase>process-resources</phase>
-                          <goals>
-                            <goal>download-single</goal>
-                          </goals>
-                          <configuration>
-                            <url>dav:http://www.oasis-open.org/committees/download.php/12569</url>
-                            <fromFile>OpenDocument-strict-schema-v1.0-os.rng</fromFile>
-                            <toDir>${project.build.directory}/odf-schemas</toDir>
-                          </configuration>
-                    </execution>
-                  </executions>
-            </plugin>
-        </plugins>
-    </build>
-    <!-- <distributionManagement>
-        <site>
-            <id>odfdom</id>
-            <name>ODFDOM Java Toolkit Project</name>
-            <url>dav:https://odftoolkit.org/website/odfdom/${project.version}/codegeneration/schema2template</url>
-        </site>
-    </distributionManagement> -->
-    <reporting>
-        <plugins>
-            <plugin>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.7</version>
-                <configuration>
-                    <doctitle>Schema2template</doctitle>
-                    <minmemory>512m</minmemory>
-                    <maxmemory>1024m</maxmemory>
-                    <links>
-                        <link>http://download.oracle.com/javase/6/docs/api/</link>
-                    </links>
-                    <splitindex>true</splitindex>
-                    <windowtitle>Schema2template v${project.version} - http://incubator.apache.org/odftoolkit/</windowtitle>
-                </configuration>
-            </plugin>
-
-            <!-- Code Coverage Testing generated by Cobertura -->
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>cobertura-maven-plugin</artifactId>
-                <version>2.4</version>
-                <configuration>
-                    <instrumentation>
-                        <excludes>
-                            <exclude>org/odftoolkit/**/*Test.class</exclude>
-                        </excludes>
-                    </instrumentation>
-                </configuration>
-            </plugin>
-        </plugins>
-    </reporting>
-
-    <!-- More Project Information -->
-    <name>XML Schema to Template Mapping Tool: Library</name>
-    <description>XML Schema to Template Mapping Tool: Library</description>
-    <organization>
-        <name>The Apache Software Foundation</name>
-        <url>http://www.apache.org/</url>
-    </organization>
-</project>
-
+<?xml version="1.0"?>
+
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.odftoolkit</groupId>
+    <artifactId>schema2template-pom</artifactId>
+    <version>0.8.9-incubating-SNAPSHOT</version>
+  </parent>
+  
+	<!-- The Basics -->
+	<artifactId>schema2template</artifactId>
+	<version>0.8.8-incubating-rc3</version>
+	<packaging>jar</packaging>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.6.4</version>
+		</dependency>
+		<dependency>
+			<groupId>net.java.dev.msv</groupId>
+			<artifactId>msv-core</artifactId>
+			<version>2009.1</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.5</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+	
+	<!-- Build Settings -->
+	<build>
+		<extensions>
+			<extension>
+				<groupId>org.apache.maven.wagon</groupId>
+				<artifactId>wagon-webdav-jackrabbit</artifactId>
+				<version>1.0-beta-7</version>
+			</extension>
+		</extensions>
+		<plugins>
+			<plugin>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>2.3.1</version>
+				<configuration>
+					<archive>
+						<index>true</index>
+						<manifest>
+							<mainClass>schema2template.example.odf.OdfHelper</mainClass>
+						</manifest>
+						<manifestEntries>
+							<version>${project.version}</version>
+						</manifestEntries>
+						<manifestSections>
+							<manifestSection>
+								<name>schema2template</name>
+								<manifestEntries>
+									<Application-Name>schema2template</Application-Name>
+									<Application-Version>${project.version}</Application-Version>
+									<Application-Website>http://incubator.apache.org/odftoolkit/</Application-Website>
+									<Built-By>${user.name}</Built-By>
+									<Built-Date>${build.timestamp}</Built-Date>
+								</manifestEntries>
+							</manifestSection>
+						</manifestSections>
+					</archive>
+				</configuration>
+			</plugin>
+			<plugin>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<!-- Explizit version required for fix on systemPropertyVariables -->
+				<version>2.6</version>
+				<configuration>
+					<systemPropertyVariables>
+						<odfdom.version>${project.version}</odfdom.version>
+						<odfdom.timestamp>${build.timestamp}</odfdom.timestamp>
+					</systemPropertyVariables>
+					<excludes>
+						<exclude>**/integrationtest/**</exclude>
+					</excludes>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.0.2</version>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+					<showDeprecation>true</showDeprecation>
+				</configuration>
+			</plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>src/test/resources/examples/odf/*.ref</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+            <plugin>
+      			<groupId>org.codehaus.mojo</groupId>
+      			<artifactId>wagon-maven-plugin</artifactId>
+      			<version>1.0-beta-3</version>
+      			<executions>
+        			<execution>
+          				<id>download-odf-schema-v1.2</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://docs.oasis-open.org/office/v1.2</url>
+            				<fromFile>cs01/OpenDocument-v1.2-cs01-schema.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+        			<execution>
+          				<id>download-odf-manifest-schema-v1.2</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://docs.oasis-open.org/office/v1.2</url>
+            				<fromFile>cs01/OpenDocument-v1.2-cs01-manifest-schema.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+        			<execution>
+          				<id>download-odf-dsig-schema-v1.2</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://docs.oasis-open.org/office/v1.2</url>
+            				<fromFile>cs01/OpenDocument-v1.2-cs01-dsig-schema.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+        			<execution>
+          				<id>download-odf-schema-v1.1</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://docs.oasis-open.org/office/v1.1</url>
+            				<fromFile>OS/OpenDocument-schema-v1.1.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+        			<execution>
+          				<id>download-odf-strict-schema-v1.1</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://docs.oasis-open.org/office/v1.1</url>
+            				<fromFile>OS/OpenDocument-strict-schema-v1.1.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+        			<execution>
+          				<id>download-odf-schema-v1.0</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://www.oasis-open.org/committees/download.php/12571</url>
+            				<fromFile>OpenDocument-schema-v1.0-os.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+        			<execution>
+          				<id>download-odf-strict-schema-v1.0</id>
+          				<phase>process-resources</phase>
+          				<goals>
+            				<goal>download-single</goal>
+          				</goals>
+          				<configuration>
+            				<url>dav:http://www.oasis-open.org/committees/download.php/12569</url>
+            				<fromFile>OpenDocument-strict-schema-v1.0-os.rng</fromFile>
+            				<toDir>${project.build.directory}/odf-schemas</toDir>
+          				</configuration>
+        			</execution>
+      			</executions>
+    		</plugin>
+		</plugins>
+	</build>
+	<!-- <distributionManagement>
+		<site>
+			<id>odfdom</id>
+			<name>ODFDOM Java Toolkit Project</name>
+			<url>dav:https://odftoolkit.org/website/odfdom/${project.version}/codegeneration/schema2template</url>
+		</site>
+	</distributionManagement> -->
+	<reporting>
+		<plugins>
+			<plugin>
+				<artifactId>maven-javadoc-plugin</artifactId>
+				<version>2.7</version>
+				<configuration>
+					<doctitle>Schema2template</doctitle>
+					<minmemory>512m</minmemory>
+					<maxmemory>1024m</maxmemory>
+					<links>
+						<link>http://download.oracle.com/javase/6/docs/api/</link>
+					</links>
+					<splitindex>true</splitindex>
+					<windowtitle>Schema2template v${project.version} - http://incubator.apache.org/odftoolkit/</windowtitle>
+				</configuration>
+			</plugin>
+
+			<!-- Code Coverage Testing generated by Cobertura -->
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>cobertura-maven-plugin</artifactId>
+				<version>2.4</version>
+				<configuration>
+					<instrumentation>
+						<excludes>
+							<exclude>org/odftoolkit/**/*Test.class</exclude>
+						</excludes>
+					</instrumentation>
+				</configuration>
+			</plugin>
+		</plugins>
+	</reporting>
+
+	<!-- More Project Information -->
+	<name>XML Schema to Template Mapping Tool: Library</name>
+	<description>XML Schema to Template Mapping Tool: Library</description>
+	<organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org/</url>
+    </organization>
+</project>
\ No newline at end of file

Modified: incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java?rev=1244419&r1=1244418&r2=1244419&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java (original)
+++ incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/OdfHelper.java Wed Feb 15 09:43:09 2012
@@ -84,7 +84,8 @@ public class OdfHelper {
 	NOTE: Ignoring the '*' there can be 1162 elements parsed, but with fixed schema it should be 1169. */
 	public static final int ODF11_ATTRIBUTE_NUMBER = 1162; //ToDo: 1169 - by search/Replace using RNGSchema and tools, prior exchange <name> to element or attribute declaration
 	public static final int ODF12_ATTRIBUTE_NUMBER = 1300; //in RNG 1301 as there is one deprecated attribute on foreign elements not referenced (ie. @office:process-content)
-	public static String odfResourceDir;
+	public static String odfDomResourceDir;
+	public static String odfPkgResourceDir;
 	public static String outputRoot;
 	public static final String INPUT_ROOT = "target" + File.separator + "odf-schemas";
 	public static final String TEST_INPUT_ROOT = "target" + File.separator + "test-classes" + File.separator
@@ -92,50 +93,75 @@ public class OdfHelper {
 	public static final String ODF10_RNG_FILE_NAME = "OpenDocument-strict-schema-v1.0-os.rng";
 	public static final String ODF11_RNG_FILE_NAME = "OpenDocument-strict-schema-v1.1.rng";
 	public static final String ODF12_RNG_FILE_NAME = "OpenDocument-v1.2-cs01-schema.rng";
+	public static final String ODF12_SIGNATURE_RNG_FILE_NAME = "OpenDocument-v1.2-cs01-dsig-schema.rng";
+	public static final String ODF12_MANIFEST_RNG_FILE_NAME = "OpenDocument-v1.2-cs01-manifest-schema.rng";
 	public static String odf12RngFile;
+	public static String odf12SignatureRngFile;
+	public static String odf12ManifestRngFile;
 	public static String odf11RngFile;
 	public static String odf10RngFile;
 	private static String mConfigFile;
-	private static final String OUTPUT_FILES_TEMPLATE = "output-files.vm";
-	private static final String OUTPUT_FILES = "target" + File.separator + "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 XMLModel mOdf12SignatureSchemaModel;
+	private static XMLModel mOdf12ManifestSchemaModel;
 	private static XMLModel mOdf12SchemaModel;
 	private static XMLModel mOdf11SchemaModel;
 	private static OdfModel mOdfModel;
 	private static SourceCodeModel mJavaModel;
+	private static Expression mOdf12SignatureRoot;
+	private static Expression mOdf12ManifestRoot;
 	private static Expression mOdf12Root;
 	private static Expression mOdf11Root;
 
-	public OdfHelper(String resourceRoot, String targetRoot, String odf12SchemaFile, String odf11SchemaFile, String configFile) {
-		odfResourceDir = resourceRoot;
-		outputRoot = targetRoot;
+	public OdfHelper(String domResourceRoot, String odf12SchemaFile, String odf11SchemaFile, String pkgResourceRoot, String odf12SignatureSchemaFile, String odf12ManifestSchemaFile, String targetRoot, String configFile) {
+		odfDomResourceDir = domResourceRoot;
 		odf12RngFile = odf12SchemaFile;
 		odf11RngFile = odf11SchemaFile;
+		odfPkgResourceDir = pkgResourceRoot;
+		odf12SignatureRngFile = odf12SignatureSchemaFile;
+		odf12ManifestRngFile = odf12ManifestSchemaFile;
+		outputRoot = targetRoot;
 		mConfigFile = configFile;
 	}
-
+	
 	static {
-		odfResourceDir = INPUT_ROOT + File.separator + "odfdom-java";
+		odfDomResourceDir = INPUT_ROOT + File.separator + "odfdom-java" + File.separator + "dom";
+		odfPkgResourceDir = INPUT_ROOT + File.separator + "odfdom-java" + File.separator + "pkg";
+		odf12SignatureRngFile = INPUT_ROOT + File.separator + ODF12_SIGNATURE_RNG_FILE_NAME;
+		odf12ManifestRngFile = INPUT_ROOT + File.separator + ODF12_MANIFEST_RNG_FILE_NAME;
 		odf12RngFile = INPUT_ROOT + File.separator + ODF12_RNG_FILE_NAME;
 		odf11RngFile = INPUT_ROOT + File.separator + ODF11_RNG_FILE_NAME;
 		odf10RngFile = INPUT_ROOT + File.separator + ODF10_RNG_FILE_NAME;
-		mConfigFile = INPUT_ROOT + File.separator + "config.xml";
 		outputRoot = "target";
+		mConfigFile = INPUT_ROOT + File.separator + "config.xml";		
 	}
 
 	public void start() throws Exception{
 		LOG.info("Starting code generation:");
 		initialize();
-		fillTemplates(odfResourceDir, mOdf12Root);
+		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);
 	}
 	
 	public static void main(String[] args) throws Exception {
 		initialize();
-		fillTemplates(odfResourceDir + File.separator + "odf-reference", mOdf12Root);
-		fillTemplates(odfResourceDir + File.separator + "odfdom-java", mOdf12Root);
-		fillTemplates(odfResourceDir + File.separator + "odfdom-python", mOdf12Root);
+		fillTemplates(INPUT_ROOT + File.separator + "odf-reference", mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
+		fillTemplates(odfDomResourceDir, mOdf12Root, DOM_OUTPUT_FILES_TEMPLATE, DOM_OUTPUT_FILES);
+		fillTemplates(INPUT_ROOT + File.separator +"odfdom-python", 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);
 	}
 
 	private static void initialize() throws Exception{
+		// calling MSV to parse the ODF 1.2 DSIG RelaxNG, returning a tree
+		System.out.println(new File(odf12SignatureRngFile).getAbsolutePath());
+		mOdf12SignatureRoot = loadSchema(new File(odf12SignatureRngFile));
+		// calling MSV to parse the ODF 1.2 Manifest RelaxNG, returning a tree
+		mOdf12ManifestRoot = loadSchema(new File(odf12ManifestRngFile));
 		// calling MSV to parse the ODF 1.2 RelaxNG, returning a tree
 		mOdf12Root = loadSchema(new File(odf12RngFile));
 		// calling MSV to parse the ODF 1.1 RelaxNG, returning a tree
@@ -151,14 +177,16 @@ public class OdfHelper {
 		Map<String, OdfModel.AttributeDefaults> attributeDefaultMap = new HashMap<String, OdfModel.AttributeDefaults>();
 		OdfConfigFileHandler.readConfigFile(new File(mConfigFile), elementToBaseNameMap, attributeDefaultMap, elementStyleFamiliesMap, datatypeValueAndConversionMap);
 
+		mOdf12SignatureSchemaModel = new XMLModel(mOdf12SignatureRoot);
+		mOdf12ManifestSchemaModel = new XMLModel(mOdf12ManifestRoot);
 		mOdf12SchemaModel = new XMLModel(mOdf12Root);
 		mOdf11SchemaModel = new XMLModel(mOdf11Root);
 		mOdfModel = new OdfModel(elementStyleFamiliesMap, attributeDefaultMap);
 		// Needed for the base classes - common attributes are being moved into the base classes
-		mJavaModel = new SourceCodeModel(mOdf12SchemaModel, mOdfModel, elementToBaseNameMap, datatypeValueAndConversionMap);
+		mJavaModel = new SourceCodeModel(mOdf12SchemaModel, mOdf12SignatureSchemaModel, mOdf12ManifestSchemaModel, mOdfModel, elementToBaseNameMap, datatypeValueAndConversionMap);
 	}
 
-	private static void fillTemplates(String sourceDir, Expression root) throws Exception {
+	private static void fillTemplates(String sourceDir, Expression root, String outputRuleTemplate, String outputRuleFile) throws Exception {
 		// intialising template engine (ie. Velocity)
 		Properties props = new Properties();
 		props.setProperty("file.resource.loader.path", sourceDir);
@@ -166,15 +194,15 @@ public class OdfHelper {
 		ve.init();
 
 		// Create output-files.xml
-		createOutputFileList(ve);
-		LOG.info("DONE.\n");
+		createOutputFileList(ve, outputRuleTemplate, outputRuleFile);
+		LOG.info("output-files.xml created done.");
 
 		// Process output-files.xml, create output files
 		LOG.fine("Processing output files... ");
-		processFileList(ve, root);
+		processFileList(ve, root, outputRuleFile);
 		LOG.fine("DONE.\n");
 	}
-
+	
 	/**
 	 * Load and parse the ODF 1.0 Schema.
 	 *
@@ -216,10 +244,9 @@ public class OdfHelper {
 		SAXParserFactory factory = SAXParserFactory.newInstance();
 		factory.setNamespaceAware(true);
 		// Parsing the Schema with MSV
-		Expression root = RELAXNGReader.parse(
-				rngFile.getAbsolutePath(),
-				factory,
-				new com.sun.msv.reader.util.IgnoreController()).getTopLevel();
+		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();
 
 
 		if (root == null) {
@@ -230,6 +257,8 @@ public class OdfHelper {
 
 	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);
@@ -239,15 +268,15 @@ public class OdfHelper {
 		return context;
 	}
 
-	private static void createOutputFileList(VelocityEngine ve) throws Exception {
+	private static void createOutputFileList(VelocityEngine ve, String template, String output) throws Exception {
 		VelocityContext context = getContext(null, null);
-		File parentPatch = new File(OUTPUT_FILES).getParentFile();
+		File parentPatch = new File(output).getParentFile();
 		if (!parentPatch.exists()) {
 			parentPatch.mkdirs();
 		}
-		FileWriter listout = new FileWriter(new File(OUTPUT_FILES));
+		FileWriter listout = new FileWriter(new File(output));
 		String encoding = "utf-8";
-		ve.mergeTemplate(OUTPUT_FILES_TEMPLATE, encoding, context, listout);
+		ve.mergeTemplate(template, encoding, context, listout);
 		listout.close();
 	}
 
@@ -271,8 +300,8 @@ public class OdfHelper {
 		}
 	}
 
-	public static void processFileList(VelocityEngine ve, Expression root) throws Exception {
-		File outputFiles = new File(OUTPUT_FILES);
+	public static void processFileList(VelocityEngine ve, Expression root, String outputRuleFile) throws Exception {
+		File outputFiles = new File(outputRuleFile);
 		List<OutputFileListEntry> fl = OutputFileListHandler.readFileListFile(outputFiles);
 
 		for (OutputFileListEntry f : fl) {
@@ -295,7 +324,6 @@ public class OdfHelper {
 
 					ve.mergeTemplate(f.getAttribute("template"), encoding, context, fileout);
 					fileout.close();
-
 					break;
 			}
 		}

Modified: incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/SourceCodeModel.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/SourceCodeModel.java?rev=1244419&r1=1244418&r2=1244419&view=diff
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/SourceCodeModel.java (original)
+++ incubator/odf/trunk/generator/schema2template/src/main/java/schema2template/example/odf/SourceCodeModel.java Wed Feb 15 09:43:09 2012
@@ -38,187 +38,189 @@ import schema2template.model.XMLModel;
  */
 public class SourceCodeModel {
     
-    Map<String, SourceCodeBaseClass> mElementBaseMap;
-    SortedSet<SourceCodeBaseClass> mBaseclasses;
-    Map<String, SourceCodeBaseClass> mBasenameToBaseclass;
-    Map<String, String[]> mDatatypeValueAndConversionMap;  // datatype -> {value-type, conversion-classname}
-
-    /**
-     * Construct SourceCodeModel. Not meant for template usage.
-     *
-     * @param model the XMLModel
-     * @param odfmodel the OdfModel
-     * @param elementnameBasenameMap the mapping from element names to source code base class names
-     * @param datatypeValueAndConversionMap the mapping from schema datatype to {source code types, name of conversion class}
-     */
-    public SourceCodeModel(XMLModel model, OdfModel odfmodel, Map<String, String> elementnameBasenameMap, Map<String, String[]> datatypeValueAndConversionMap) {
-        mDatatypeValueAndConversionMap = datatypeValueAndConversionMap;
-
-        // Intermediate Step -> get all basenames
-        SortedSet<String> basenames = new TreeSet<String>(elementnameBasenameMap.values());
-
-        // Intermediate Step -> get all subelement Definitions for each basename
-        Map<String, SortedSet<PuzzlePiece>> basenameElementsMap = new HashMap<String, SortedSet<PuzzlePiece>>(basenames.size());
-        for (String elementname : elementnameBasenameMap.keySet()) {
-            String basename = elementnameBasenameMap.get(elementname);
-            SortedSet<PuzzlePiece> elements = basenameElementsMap.get(basename);
-            if (elements == null) {
-                elements = new TreeSet<PuzzlePiece>();
-                basenameElementsMap.put(basename, elements);
-            }
-            QNamedPuzzleComponent subelement = model.getElement(elementname);
-            if (subelement != null) {
-                if (subelement instanceof Collection) {
-                    elements.addAll((Collection) subelement);
-                }
-                else {
-                    elements.add((PuzzlePiece) subelement);
-                }
-            }
-            else {
-                System.err.println("Warning: Baseclass definition for unknown element " + elementname);
-            }
-        }
-
-        // Generate all baseclasses (additional intermediate step: register them)
-        mBasenameToBaseclass = new HashMap<String, SourceCodeBaseClass>(basenames.size());
-        mBaseclasses = new TreeSet<SourceCodeBaseClass>();
-        for (String basename : basenames) {
-            SourceCodeBaseClass javabaseclass = new SourceCodeBaseClass(odfmodel, basename, basenameElementsMap.get(basename));
-            mBaseclasses.add(javabaseclass);
-            mBasenameToBaseclass.put(basename, javabaseclass);
-        }
-
-        // Generate a map from element tag name to baseclasses
-        mElementBaseMap = new HashMap<String, SourceCodeBaseClass>(elementnameBasenameMap.size());
-        for (String elementname : elementnameBasenameMap.keySet()) {
-            String basename = elementnameBasenameMap.get(elementname);
-            SourceCodeBaseClass baseclass = mBasenameToBaseclass.get(basename);
-            mElementBaseMap.put(elementname, baseclass);
-        }
-    }
-
-    /**
-     * Use in templates: Get baseclass of one element
-     *
-     * @param subelement element
-     * @return baseclass
-     */
-    public SourceCodeBaseClass getBaseclassOf(QNamed subelement) {
-        return mElementBaseMap.get(subelement.getQName());
-    }
-
-    /**
-     * Use in templates: Get all baseclasses
-     * @return all baseclasses
-     */
-    public SortedSet<SourceCodeBaseClass> getBaseclasses() {
-        return mBaseclasses;
-    }
-
-    /**
-     * Use in templates: Get baseclass by name
-     * @param basename name of baseclass
-     * @return baseclass object
-     */
-    public SourceCodeBaseClass getBaseclass(String basename) {
-        return mBasenameToBaseclass.get(basename);
-    }
-
-    /**
-     * Use in templates: Get baseclass by name
-     *
-     * @param base name of baseclass
-     * @return baseclass object
-     */
-    public SourceCodeBaseClass getBaseclass(QNamed base) {
-        return getBaseclass(base.getQName());
-    }
-
-    /**
-     * Use in templates: Get Source code value type for datatype used in schema
-     *
-     * @param datatype
-     * @return source code value type
-     */
-    public String getValuetype(QNamed datatype) {
-        String datatypename = datatype.getQName();
-        String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
-        if (tuple == null) {
-            return "";
-        }
-        String retval = tuple[0];
-        return (retval == null) ? "" : retval;
-    }
-
-    /**
-     * Use in templates: Get source code value types for datatypes used in schema
-     *
-     * @param datatypes Schema datatypes
-     * @return the corresponding source code datatypes
-     */
-    public SortedSet<String> getValuetypes(PuzzleComponent datatypes) {
-        SortedSet<String> retval = new TreeSet<String>();
-        for (PuzzlePiece datatype : datatypes.getCollection()) {
-            String datatypename = datatype.getQName();
-            String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
-            if (tuple != null) {
-                String valuetype = tuple[0];
-                if (valuetype != null) {
-                    retval.add(valuetype);
-                }
-            }
-        }
-        return retval;
-    }
-
-    /**
-     * Use in templates: Translate Java object to simple Java datatype
-     *
-     * @param objectType like "Boolean"
-     * @return simpleType like "boolean"
-     */
-    public String getPrimitiveType(String objectType) {
-        if (objectType.equals("Boolean")) {
-            return "boolean";
-        }
-        if (objectType.equals("Integer")) {
-            return "int";
-        }
-        if (objectType.equals("Double")) {
-            return "double";
-        }
-        return null;
-    }
-
-    /**
-     * Use in templates: Get Java conversion class for datatype used in schema.
-     *
-     * @param datatype Source code datatype
-     * @return name of source code conversion class for this datatype
-     */
-    public String getConversiontype(QNamed datatype) {
-        String datatypename = datatype.getQName();
-        String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
-        if (tuple == null) {
-            return "";
-        }
-        String retval = tuple[1];
-        return (retval == null) ? "" : retval;
-    }
-    
-    /**
-     * Use in templates: Get Java conversion class for datatype used in schema.
-     *
-     * @param datatypename Source code datatypename
-     * @return name of source code conversion class for this datatype
-     */
-    public String getConversiontype(String datatypename) {
-        String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
-        if (tuple == null) {
-            return "";
-        }
-        String retval = tuple[1];
-        return (retval == null) ? "" : retval;
-    }
+	 Map<String, SourceCodeBaseClass> mElementBaseMap;
+	    SortedSet<SourceCodeBaseClass> mBaseclasses;
+	    Map<String, SourceCodeBaseClass> mBasenameToBaseclass;
+	    Map<String, String[]> mDatatypeValueAndConversionMap;  // datatype -> {value-type, conversion-classname}
+
+	    /**
+	     * Construct SourceCodeModel. Not meant for template usage.
+	     *
+	     * @param model the XMLModel
+	     * @param signatureModel the signature XMLModel
+	     * @param manifestModel the manifest XMLModel
+	     * @param odfmodel the OdfModel
+	     * @param elementnameBasenameMap the mapping from element names to source code base class names
+	     * @param datatypeValueAndConversionMap the mapping from schema datatype to {source code types, name of conversion class}
+	     */
+	    public SourceCodeModel(XMLModel model, XMLModel signatureModel, XMLModel manifestModel, OdfModel odfmodel, Map<String, String> elementnameBasenameMap, Map<String, String[]> datatypeValueAndConversionMap) {
+	        mDatatypeValueAndConversionMap = datatypeValueAndConversionMap;
+
+	        // Intermediate Step -> get all basenames
+	        SortedSet<String> basenames = new TreeSet<String>(elementnameBasenameMap.values());
+
+	        // Intermediate Step -> get all subelement Definitions for each basename
+	        Map<String, SortedSet<PuzzlePiece>> basenameElementsMap = new HashMap<String, SortedSet<PuzzlePiece>>(basenames.size());
+	        for (String elementname : elementnameBasenameMap.keySet()) {
+	            String basename = elementnameBasenameMap.get(elementname);
+	            SortedSet<PuzzlePiece> elements = basenameElementsMap.get(basename);
+	            if (elements == null) {
+	                elements = new TreeSet<PuzzlePiece>();
+	                basenameElementsMap.put(basename, elements);
+	            }
+	            QNamedPuzzleComponent subelement = model.getElement(elementname);
+	            if (subelement != null) {
+	                if (subelement instanceof Collection) {
+	                    elements.addAll((Collection) subelement);
+	                }
+	                else {
+	                    elements.add((PuzzlePiece) subelement);
+	                }
+	            }
+	            else {
+	                System.err.println("Warning: Baseclass definition for unknown element " + elementname);
+	            }
+	        }
+
+	        // Generate all baseclasses (additional intermediate step: register them)
+	        mBasenameToBaseclass = new HashMap<String, SourceCodeBaseClass>(basenames.size());
+	        mBaseclasses = new TreeSet<SourceCodeBaseClass>();
+	        for (String basename : basenames) {
+	            SourceCodeBaseClass javabaseclass = new SourceCodeBaseClass(odfmodel, basename, basenameElementsMap.get(basename));
+	            mBaseclasses.add(javabaseclass);
+	            mBasenameToBaseclass.put(basename, javabaseclass);
+	        }
+
+	        // Generate a map from element tag name to baseclasses
+	        mElementBaseMap = new HashMap<String, SourceCodeBaseClass>(elementnameBasenameMap.size());
+	        for (String elementname : elementnameBasenameMap.keySet()) {
+	            String basename = elementnameBasenameMap.get(elementname);
+	            SourceCodeBaseClass baseclass = mBasenameToBaseclass.get(basename);
+	            mElementBaseMap.put(elementname, baseclass);
+	        }
+	    }
+
+	    /**
+	     * Use in templates: Get baseclass of one element
+	     *
+	     * @param subelement element
+	     * @return baseclass
+	     */
+	    public SourceCodeBaseClass getBaseclassOf(QNamed subelement) {
+	        return mElementBaseMap.get(subelement.getQName());
+	    }
+
+	    /**
+	     * Use in templates: Get all baseclasses
+	     * @return all baseclasses
+	     */
+	    public SortedSet<SourceCodeBaseClass> getBaseclasses() {
+	        return mBaseclasses;
+	    }
+
+	    /**
+	     * Use in templates: Get baseclass by name
+	     * @param basename name of baseclass
+	     * @return baseclass object
+	     */
+	    public SourceCodeBaseClass getBaseclass(String basename) {
+	        return mBasenameToBaseclass.get(basename);
+	    }
+
+	    /**
+	     * Use in templates: Get baseclass by name
+	     *
+	     * @param base name of baseclass
+	     * @return baseclass object
+	     */
+	    public SourceCodeBaseClass getBaseclass(QNamed base) {
+	        return getBaseclass(base.getQName());
+	    }
+
+	    /**
+	     * Use in templates: Get Source code value type for datatype used in schema
+	     *
+	     * @param datatype
+	     * @return source code value type
+	     */
+	    public String getValuetype(QNamed datatype) {
+	        String datatypename = datatype.getQName();
+	        String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
+	        if (tuple == null) {
+	            return "";
+	        }
+	        String retval = tuple[0];
+	        return (retval == null) ? "" : retval;
+	    }
+
+	    /**
+	     * Use in templates: Get source code value types for datatypes used in schema
+	     *
+	     * @param datatypes Schema datatypes
+	     * @return the corresponding source code datatypes
+	     */
+	    public SortedSet<String> getValuetypes(PuzzleComponent datatypes) {
+	        SortedSet<String> retval = new TreeSet<String>();
+	        for (PuzzlePiece datatype : datatypes.getCollection()) {
+	            String datatypename = datatype.getQName();
+	            String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
+	            if (tuple != null) {
+	                String valuetype = tuple[0];
+	                if (valuetype != null) {
+	                    retval.add(valuetype);
+	                }
+	            }
+	        }
+	        return retval;
+	    }
+
+	    /**
+	     * Use in templates: Translate Java object to simple Java datatype
+	     *
+	     * @param objectType like "Boolean"
+	     * @return simpleType like "boolean"
+	     */
+	    public String getPrimitiveType(String objectType) {
+	        if (objectType.equals("Boolean")) {
+	            return "boolean";
+	        }
+	        if (objectType.equals("Integer")) {
+	            return "int";
+	        }
+	        if (objectType.equals("Double")) {
+	            return "double";
+	        }
+	        return null;
+	    }
+
+	    /**
+	     * Use in templates: Get Java conversion class for datatype used in schema.
+	     *
+	     * @param datatype Source code datatype
+	     * @return name of source code conversion class for this datatype
+	     */
+	    public String getConversiontype(QNamed datatype) {
+	        String datatypename = datatype.getQName();
+	        String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
+	        if (tuple == null) {
+	            return "";
+	        }
+	        String retval = tuple[1];
+	        return (retval == null) ? "" : retval;
+	    }
+	    
+	    /**
+	     * Use in templates: Get Java conversion class for datatype used in schema.
+	     *
+	     * @param datatypename Source code datatypename
+	     * @return name of source code conversion class for this datatype
+	     */
+	    public String getConversiontype(String datatypename) {
+	        String[] tuple = mDatatypeValueAndConversionMap.get(datatypename);
+	        if (tuple == null) {
+	            return "";
+	        }
+	        String retval = tuple[1];
+	        return (retval == null) ? "" : retval;
+	    }
 }
\ No newline at end of file

Added: incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/dom-output-files.vm
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/dom-output-files.vm?rev=1244419&view=auto
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/dom-output-files.vm (added)
+++ incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/dom/dom-output-files.vm Wed Feb 15 09:43:09 2012
@@ -0,0 +1,75 @@
+##################################################################
+## 
+## 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>
+	<file path="org/odftoolkit/odfdom/dom/style/OdfStyleFamily.java" template="java-odfdom-stylefamily.vm" />
+	<file path="org/odftoolkit/odfdom/dom/style/props/OdfStylePropertiesSet.java" template="java-odfdom-styleset.vm" />
+####<file path="org/odftoolkit/odfdom/dom/DefaultElementVisitor.java" template="java-odfdom-element-visitor.vm" />
+####<file path="org/odftoolkit/odfdom/dom/DefaultAttributeVisitor.java" template="java-odfdom-attribute-visitor.vm" />
+##
+#foreach ($element in ${model.getElements().withoutMultiples()})
+#if ($element != "*")
+##
+#set($classname = "${model.camelCase($element)}Element")
+	<file path="org/odftoolkit/odfdom/dom/element/${model.extractNamespace($element)}/${classname}.java" context="$element" template="java-odfdom-element-template.vm" />
+##
+#end
+#end
+##
+#foreach ($base in $javamodel.getBaseclasses())
+##
+#if ($base != "container" && $base != "style" && $base != "styleproperties")
+#set($classname = "${model.camelCase($base)}ElementBase")
+	<file path="org/odftoolkit/odfdom/dom/element/${model.extractNamespace($base)}/${classname}.java" context="$base" template="java-odfdom-elementbase-template.vm" />
+#end
+##
+#end
+##
+#foreach ($attribute in ${model.getAttributes().withoutMultiples()})
+#if ($attribute != "*")
+##
+#set($classname = "${model.camelCase($attribute)}Attribute")
+	<file path="org/odftoolkit/odfdom/dom/attribute/${model.extractNamespace($attribute)}/${classname}.java" context="$attribute" template="java-odfdom-attribute-template.vm" />
+#end
+#end
+##
+#foreach ($attribute in ${model.getAttributes().withoutMultiples()})
+#if ($attribute != "*")
+##
+#set($classname = "${model.camelCase($attribute)}Attribute")
+	<file path="org/odftoolkit/odfdom/dom/attribute/${model.extractNamespace($attribute)}/${classname}.java" context="$attribute" template="java-odfdom-attribute-template.vm" />
+#end
+#end
+##
+#foreach ($styleelement in ${model.getElements().withoutMultiples()})
+#if ($styleelement.getNamespace() == "style" && ${styleelement.getLocalName().endsWith("properties")})
+#set ($properties=${styleelement.withMultiples().getAttributes()})
+#if ($properties.size()>0)
+	<file path="org/odftoolkit/odfdom/dom/style/props/Odf${model.camelCase(${styleelement.getLocalName()})}.java" context="$styleelement" template="java-odfdom-styleproperties.vm" />
+#end
+#end
+#end
+</filelist>

Added: incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/copyright.txt
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/copyright.txt?rev=1244419&view=auto
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/copyright.txt (added)
+++ incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/copyright.txt Wed Feb 15 09:43:09 2012
@@ -0,0 +1,24 @@
+/************************************************************************
+ *
+ * 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.
+ * 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.
+ *
+ ************************************************************************/
+

Added: incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm?rev=1244419&view=auto
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm (added)
+++ incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-attribute-template.vm Wed Feb 15 09:43:09 2012
@@ -0,0 +1,379 @@
+##################################################################
+## 
+## 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.
+##
+##################################################################
+## Template to create the list of signature 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
+## 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 ($valueobject = "String")
+##
+#set($datatypes = ${attribute.getDatatypes().withoutMultiples()})
+#if ($datatypes.size() > 0)
+#set ($hasdatatype = true)
+#else
+#set ($hasdatatype = false)
+#end
+##
+##2DO: Svante - getValues() vs. getValueLiterals() - only literals / constants for attribute values are taken
+#set($values = ${attribute.getValues().withoutMultiples()})
+#if ($values.size() > 0)
+#if ($values.size() ==2 && $hasdatatype == false)
+#set ($trueFlag = false)
+#set ($falseFlag = false)
+#foreach ($value in $values)
+#if ($value==true)
+#set ($trueFlag = true)
+#end
+#if ($value==false)
+#set ($falseFlag = true)
+#end
+#end
+#if ($trueFlag and $falseFlag)
+#set ($hasdatatype = true)
+#set ($valueobject = "Boolean")
+#end
+#end
+#set ($enum = true)
+#if ($valueobject == "Boolean")
+#set ($enum = false)
+#end
+#else
+#set ($enum = false)
+#end
+##
+## Check whether the attribute has default value.
+##
+#set ($hasDefaultValue = false)
+#foreach ($parent in ${attribute.getParents().withoutMultiples()})
+#if (${odfmodel.getDefaultAttributeValue($attribute, $parent)})
+#set ($hasDefaultValue = true)
+#end
+#end
+##
+#set ($defaultValueSet = $odfmodel.getDefaultAttributeValues($attribute))
+#if ($hasDefaultValue and $defaultValueSet.size() == 1)
+#foreach ($value in $defaultValueSet)
+#set ($uniqueDefaultValue = $value)
+#end
+#end
+##
+#include('copyright.txt')
+/*
+ * This file is automatically generated.
+ * Don't edit manually.
+ */
+package org.odftoolkit.odfdom.pkg.dsig;
+
+import org.odftoolkit.odfdom.pkg.OdfAttribute;
+#if ($hasDefaultValue)
+import org.odftoolkit.odfdom.pkg.OdfElement;
+#end
+import org.odftoolkit.odfdom.pkg.OdfFileDom;
+import org.odftoolkit.odfdom.pkg.OdfName;
+
+/**
+ * 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}");
+#if ($hasDefaultValue)
+#if ($defaultValueSet.size()>1)
+#foreach ($defaultValue in $defaultValueSet)
+#set ($constant = $signaturemodel.constantCase($defaultValue))
+#if (($defaultValue=="true" or $defaultValue=="false") and $enum == false)
+	public static final String DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)}= "$defaultValue";
+#else
+	public static final String DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)}=	Value.${signaturemodel.escapeKeyword($constant)}.toString();
+#end
+#end
+#else
+#if ($uniqueDefaultValue=="&#34;")
+	public static final String DEFAULT_VALUE = "\${uniqueDefaultValue}";
+#else
+	public static final String DEFAULT_VALUE = "$uniqueDefaultValue";
+#end
+#end
+#end
+
+	/**
+	 * Create the instance of OpenDocument attribute {@odf.attribute ${attribute}}.
+	 *
+	 * @param ownerDocument       The type is <code>OdfFileDom</code>
+	 */
+	public $classname(OdfFileDom ownerDocument) {
+		super(ownerDocument, ATTRIBUTE_NAME);
+	}
+
+	/**
+	 * Returns the attribute name.
+	 *
+	 * @return the <code>OdfName</code> for {@odf.attribute ${attribute}}.
+	 */
+	@Override
+	public OdfName getOdfName() {
+		return ATTRIBUTE_NAME;
+	}
+
+	/**
+	 * @return Returns the name of this attribute.
+	 */
+	@Override
+	public String getName() {
+		return ATTRIBUTE_NAME.getLocalName();
+	}
+##
+#if ($enum)
+
+	/**
+	 * The value set of {@odf.attribute ${attribute}}.
+	 */
+	public enum Value {
+#set ($separator="		")
+#foreach($value in $values)
+#if (${value.toString().length()} == 1)
+#set ($constant = $value)
+#else
+#set ($constant = $signaturemodel.constantCase($value))
+#end${separator}${signaturemodel.escapeKeyword($constant)}("${signaturemodel.escapeLiteral($value)}")#set ($separator=", ")
+#end ;
+
+		private String mValue;
+
+		Value(String value) {
+			mValue = value;
+		}
+
+		@Override
+		public String toString() {
+			return mValue;
+		}
+
+		public static Value enumValueOf(String value) {
+			for(Value aIter : values()) {
+				if (value.equals(aIter.toString())) {
+				return aIter;
+				}
+			}
+			return null;
+		}
+	}
+
+	/**
+	 * @param attrValue The <code>Enum</code> value of the attribute.
+	 */
+	public void setEnumValue(Value attrValue) {
+		setValue(attrValue.toString());
+	}
+
+	/**
+	 * @return Returns the <code>Enum</code> value of the attribute
+	 */
+	public Value getEnumValue() {
+		return Value.enumValueOf(this.getValue());
+	}
+#end
+##
+## Handle Non-String-Attributes
+#set ($valuetypes = ${javamodel.getValuetypes($datatypes)})
+#if ($valueobject != "Boolean")
+#foreach ($valuetype in $valuetypes)
+#set ($valueobject = $valuetype)
+#end
+#end
+#if ($valueobject != "String" && $valueobject != "Double" && $valueobject != "Integer" && $valueobject != "Boolean")
+#set ($valueobject = "String")
+#end
+#if ($valueobject != "String")
+#set ($simplevalue = ${javamodel.getPrimitiveType($valueobject)})
+##
+
+	/**
+	 * @param value The <code>${simplevalue}</code> value of the attribute.
+	 */
+	public void set${signaturemodel.camelCase($simplevalue)}Value(${simplevalue} value) {
+		super.setValue(String.valueOf(value));
+	}
+
+	/**
+	 * @return Returns the <code>${simplevalue}</code> value of the attribute
+	 */
+	public ${simplevalue} ${simplevalue}Value() {
+		String val = super.getValue();
+		try {
+			return ${valueobject}.parse${signaturemodel.camelCase($simplevalue)}(val);
+		} catch (NumberFormatException e) {
+			// TODO: validation handling/logging
+			throw (e);
+		}
+	}
+#end
+##
+
+	/**
+	 * @param attrValue The <code>String</code> value of the attribute.
+	 * @throws IllegalArgumentException If the provided attribute value is invalid
+	 */
+	@Override
+	public void setValue(String attrValue) {
+#if ($enum)
+#if ($hasdatatype)
+## enum and datatype
+		// Since we have not only enumValues, but also a DataType, we use String as common base and don't validate.
+		super.setValue(attrValue);
+#else
+## enum and no datatype
+		try {
+			super.setValue(Value.enumValueOf(attrValue).toString());
+		} catch (NullPointerException e) {
+			throw new IllegalArgumentException(e);
+		}
+#end
+#else
+		try {
+			super.setValue(attrValue);
+		} catch (NullPointerException e) {
+			// TODO: validation handling/logging
+			throw new IllegalArgumentException(e);
+		} catch (IllegalArgumentException e) {
+			// TODO: validation handling/logging
+			throw (e);
+		}
+#end
+	}
+
+	/**
+	 * @return Returns the <code>String</code> value of the attribute
+	 */
+	@Override
+	public String getValue() {
+#if ($enum)
+#if ($hasdatatype)
+## enum and datatype
+		// Since we have not only enumValues, but also a DataType, we use String as common base and don't validate.
+		return super.getValue();
+#else
+## enum and no datatype
+		try {
+			return Value.enumValueOf(super.getValue()).toString();
+		} catch (NullPointerException e) {
+			throw new IllegalArgumentException("the value of ${attribute} is not valid");
+		}
+#end
+#else
+		try {
+			return super.getValue();
+		} catch (IllegalArgumentException e) {
+			// TODO: validation handling/logging
+			throw new NumberFormatException("the value of ${attribute} is not valid");
+		}
+#end
+	}
+
+#if ($hasDefaultValue)
+	/**
+	 * Returns the default value of {@odf.attribute ${attribute}}.
+	 *
+	 * @return the default value as <code>String</code> dependent of its element name
+	 *         return <code>null</code> if the default value does not exist
+	 */
+	@Override
+	public String getDefault() {
+		OdfElement parentElement = (OdfElement)getOwnerElement();
+		String defaultValue = null;
+		if (parentElement != null) {
+#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))}";
+			}
+#end
+#end
+#else
+			defaultValue = "${signaturemodel.escapeLiteral($uniqueDefaultValue)}";
+#end
+		}
+		return defaultValue;
+	}
+
+	/**
+	 * Default value indicator. As the attribute default value is dependent from its element, the attribute has only a default, when a parent element exists.
+	 *
+	 * @return <code>true</code> if {@odf.attribute ${attribute}} has an element parent
+	 *         otherwise return <code>false</code> as undefined.
+	 */
+	@Override
+	public boolean hasDefault() {
+		return getOwnerElement() == null ? false : true;
+	}
+#else
+	/**
+	 * Returns the default value of {@odf.attribute ${attribute}}.
+	 *
+	 * @return the default value as <code>String</code> dependent of its element name
+	 *         return <code>null</code> if the default value does not exist
+	 */
+	@Override
+	public String getDefault() {
+		return null;
+	}
+
+	/**
+	 * Default value indicator. As the attribute default value is dependent from its element, the attribute has only a default, when a parent element exists.
+	 *
+	 * @return <code>true</code> if {@odf.attribute ${attribute}} has an element parent
+	 *         otherwise return <code>false</code> as undefined.
+	 */
+	@Override
+	public boolean hasDefault() {
+		return false;
+	}
+#end
+
+	/**
+	 * @return Returns whether this attribute is known to be of type ID (i.e. xml:id ?)
+	 */
+	@Override
+	public boolean isId() {
+#if ($hasdatatype and $datatypes.size() > 0)
+#set ($datatype="")
+#foreach($value in $datatypes)
+#set ($datatype=$value)
+#end
+#if ($datatype == "ID")
+		return true;
+#else
+		return false;
+#end
+#else
+		return false;
+#end
+	}
+}

Added: incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm?rev=1244419&view=auto
==============================================================================
--- incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm (added)
+++ incubator/odf/trunk/generator/schema2template/src/main/resources/examples/odf/odfdom-java/pkg/odfdom-dsig-element-template.vm Wed Feb 15 09:43:09 2012
@@ -0,0 +1,370 @@
+##################################################################
+## 
+## 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.
+##
+##################################################################
+## Template to create the Java class representing an ODF signature element
+##
+## 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 ($classname = "${model.camelCase($element)}Element")
+##
+## Set child element and child attributes
+#set ($children = ${element.getChildElements().withoutMultiples()})
+#set ($attributes = ${element.getAttributes().withoutMultiples()})
+##
+## Set base class OdfElement
+#set ($baseclassname = "OdfElement")
+#set ($baseHasMandatoryAttr = false)
+##
+## ...or configured base class
+#if (${javamodel.getBaseclassOf($element)})
+#set ($base = ${javamodel.getBaseclassOf($element)})
+#end
+## Configured manually generated base class?
+#if ($base == "container")
+#set ($_specialbase = true)
+#set ($baseclassname = "OdfContainerElementBase")
+#set ($baseimport = "org.odftoolkit.odfdom.pkg.$baseclassname")
+#set ($baseHasMandatoryAttr = false)
+#end
+##
+## Test if this element has mandatory (non optional) attributes
+#set ($hasMandatoryAttr = false)
+#foreach ($attribute in $attributes)
+#if (${element.isMandatory($attribute)})
+#set ($hasMandatoryAttr = true)
+#set ($mandatoryAttr = $attribute)
+#end
+#end
+##
+## Begin Code
+#include('copyright.txt')
+/*
+ * This file is automatically generated.
+ * Don't edit manually.
+ */
+package org.odftoolkit.odfdom.pkg.dsig;
+
+##
+## ---------------------------------------------------
+##  Imports
+## ---------------------------------------------------
+##
+import org.odftoolkit.odfdom.pkg.OdfElement;
+import org.odftoolkit.odfdom.pkg.OdfFileDom;
+import org.odftoolkit.odfdom.pkg.OdfName;
+
+##
+## If there is a base class which is not in the current package
+#if ($baseimport)
+import ${baseimport};
+#end
+
+##
+## ---------------------------------------------------
+##  Class
+## ---------------------------------------------------
+##
+/**
+ * Data signature implementation of OpenDocument element  {@odf.element ${context}}.
+ *
+#if ($anychild)
+ * This class can have any org.w3c.dom.Element child element.
+#end
+#if ($anyattribute)
+ * This class can have any org.w3c.dom.Attribute attribute.
+#end
+ */
+public class $classname extends $baseclassname {
+
+	public static final OdfName ELEMENT_NAME = OdfName.newName("${NS}", "${PREFIX}:${element}");
+
+	/**
+	 * Create the instance of <code>$classname</code>
+	 *
+	 * @param  ownerDoc     The type is <code>OdfFileDom</code>
+	 */
+	public $classname(OdfFileDom ownerDoc) {
+		super(ownerDoc, ELEMENT_NAME);
+	}
+
+	/**
+	 * Get the element name
+	 *
+	 * @return  return   <code>OdfName</code> the name of element {@odf.element ${context}}.
+	 */
+	public OdfName getOdfName() {
+		return ELEMENT_NAME;
+	}
+##
+## ---------------------------------------------------
+##  Add init method if this element or the base
+##  element has mandatory attributes
+##  TODO: NO caller use this method.
+## ---------------------------------------------------
+##
+## ---------------------------------------------------
+##  Attribute getters and setters
+## ---------------------------------------------------
+##
+#foreach ($attr in $attributes)
+#set($attri = ${signaturemodel.getAttribute($attr.getQName())})
+#set ($valueObject = "String")
+#set ($simpleValue = "")
+#set ($dataTypes = ${attri.getDatatypes().withoutMultiples()})
+#set ($valueTypes = ${javamodel.getValuetypes($dataTypes)})
+#foreach ($valueType in $valueTypes)
+#set ($valueObject = $valueType)
+#end
+## use attri get all of the values.
+#set($values = ${attri.getValues().withoutMultiples()})
+#if ($values.size() ==2 && $dataTypes.size()==0)
+#set ($trueFlag = false)
+#set ($falseFlag = false)
+#foreach ($value in $values)
+#if ($value==true)
+#set ($trueFlag = true)
+#end
+#if ($value==false)
+#set ($falseFlag = true)
+#end
+#end
+#if ($trueFlag and $falseFlag)
+#set ($hasdatatype = true)
+#set ($valueObject = "Boolean")
+#end
+#end
+#if ($valueObject != "String" && $valueObject != "Double" && $valueObject != "Integer" && $valueObject != "Boolean")
+#set ($valueObject = "String")
+#end
+#if ($valueObject != "String")
+#set ($simpleValue = ${javamodel.getPrimitiveType($valueObject)})
+#end
+#if ($attr != "*")
+#set ($attribute = ${attr.withMultiples()})
+#set ($aNS = ${attribute.getNamespace()})
+#set ($aClassname = "${signaturemodel.camelCase($attribute)}Attribute")
+#set ($aParam = "${signaturemodel.javaCase($attribute)}Value")
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>$aClassname</code> , See {@odf.attribute ${attribute.getQName()}}
+	 *
+#if (${element.isMandatory($attribute)})
+	 * Attribute is mandatory.
+	 *
+#end
+	 * @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);
+		if (attr != null) {
+#if ($simpleValue!="")
+			return ${valueObject}.valueOf(attr.${simpleValue}Value());
+#else
+			return ${valueObject}.valueOf(attr.getValue());
+#end
+		}
+#if ($odfmodel.getDefaultAttributeValue($attribute, $element))
+#set ($defaultValue = ${signaturemodel.escapeLiteral($odfmodel.getDefaultAttributeValue($attribute, $element))})
+#set ($defaultValueSet = $odfmodel.getDefaultAttributeValues($attribute))
+#if ($defaultValueSet.size()>1)
+#set ($constant = $signaturemodel.constantCase($defaultValue))
+#if ($valueObject == "String")
+		return ${aClassname}.DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)};
+#else
+		return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE_${signaturemodel.escapeKeyword($constant)});
+#end
+#else
+#if ($valueObject == "String")
+		return ${aClassname}.DEFAULT_VALUE;
+#else
+		return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE);
+#end
+#end
+#else
+		return null;
+#end
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>$aClassname</code> , See {@odf.attribute ${attribute.getQName()}}
+	 *
+	 * @param $aParam   The type is <code>$valueObject</code>
+	 */
+	public void set${aClassname}($valueObject $aParam) {
+		$aClassname attr = new ${aClassname}((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+#if ($valueObject == "String")
+		attr.setValue($aParam);
+#else
+		attr.set${signaturemodel.camelCase($simpleValue)}Value($aParam.${simpleValue}Value());
+#end
+	}
+#end
+#end
+
+##
+## ---------------------------------------------------
+##  Methods for child element creation
+## ---------------------------------------------------
+##
+#foreach($ch in $children)
+#if ($ch != "*")
+#set ($child = ${ch.withMultiples()})
+#set ($cClassname = "${signaturemodel.camelCase($child)}Element")
+#set ($cVar = ${signaturemodel.javaCase($child)})
+#set ($ch_attributes = ${child.getAttributes().withoutMultiples()})
+##set has parameter flag
+#set ($hasParams = false)
+#foreach ($ch_attribute in $ch_attributes)
+#if (${child.isMandatory($ch_attribute)})
+#set ($hasParams = true)
+#end
+#end
+#if ($hasParams)
+	/**
+	 * Create child element {@odf.element ${child}}.
+	 *
+#set ($seperateFlag="")
+#set ($params="")
+#foreach ($ch_attr in $ch_attributes)
+#if (${child.isMandatory($ch_attr)})
+#set($ch_attri = ${signaturemodel.getAttribute($ch_attr.getQName())})
+#set ($ch_ValueObject = "String")
+#set ($ch_SimpleValue = "")
+#set ($ch_DataTypes = ${ch_attri.getDatatypes().withoutMultiples()})
+#set ($ch_ValueTypes = ${javamodel.getValuetypes($ch_DataTypes)})
+#foreach ($ch_ValueType in $ch_ValueTypes)
+#set ($ch_ValueObject = $ch_ValueType)
+#end
+## use ch_attri get all of the values.
+#set($ch_Values = ${ch_attri.getValues().withoutMultiples()})
+#if ($ch_Values.size() ==2 && $ch_DataTypes.size()==0)
+#set ($trueFlag = false)
+#set ($falseFlag = false)
+#foreach ($ch_Value in $ch_Values)
+#if ($ch_Value==true)
+#set ($trueFlag = true)
+#end
+#if ($ch_Value==false)
+#set ($falseFlag = true)
+#end
+#end
+#if ($trueFlag and $falseFlag)
+#set ($ch_Hasdatatype = true)
+#set ($ch_ValueObject = "Boolean")
+#end
+#end
+#if ($ch_ValueObject != "String" && $ch_ValueObject != "Double" && $ch_ValueObject != "Integer" && $ch_ValueObject != "Boolean")
+#set ($ch_ValueObject = "String")
+#end
+#if ($ch_ValueObject != "String")
+#set ($ch_SimpleValue = ${javamodel.getPrimitiveType($ch_ValueObject)})
+#end
+#if ($ch_attr != "*")
+#set ($attribute = ${ch_attr.withMultiples()})
+#set ($aNS = ${attribute.getNamespace()})
+#set ($aClassname = "${signaturemodel.camelCase($attribute)}Attribute")
+#set ($aParam = "${signaturemodel.javaCase($attribute)}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}")
+#else
+#set ($params="${params}${seperateFlag}${ch_ValueObject} ${aParam}")
+#end
+#set ($seperateFlag=", ")
+#end
+#end
+#end
+## Compare element from old and new Spec. A direct comparison is not possible (both encapsulate different RelaxNG Expressions)
+## but we can compare by name
+#if (!$oldelement || !${oldelement.getChildElements().containsName($child)})
+	 * Child element is new in Odf 1.2
+	 *
+#end
+#if (${element.isMandatory($child)})
+	 * Child element is mandatory.
+	 *
+#end
+	 * @return the element {@odf.element ${child}}
+	 */
+	 public $cClassname new${cClassname}($params) {
+		$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")
+		${cVar}.set$aClassname($aParam);
+#end
+#end
+		this.appendChild($cVar);
+		return $cVar;
+	}
+
+#else
+	/**
+	 * Create child element {@odf.element ${child}}.
+	 *
+## Compare element from old and new Spec. A direct comparison is not possible (both encapsulate different RelaxNG Expressions)
+## but we can compare by name
+#if (!$oldelement || !${oldelement.getChildElements().containsName($child)})
+	 * Child element is new in Odf 1.2
+	 *
+#end
+#if (${element.isMandatory($child)})
+	 * Child element is mandatory.
+	 *
+#end
+	 * @return the element {@odf.element ${child}}
+	 */
+	public $cClassname new${cClassname}() {
+		$cClassname $cVar = ((OdfFileDom) this.ownerDocument).newOdfElement(${cClassname}.class);
+		this.appendChild($cVar);
+		return $cVar;
+	}
+
+#end
+#end
+#end
+##
+## -----------------------------------------------------
+##  New: newTextNode
+## -----------------------------------------------------
+##
+#if ($element.canHaveText())
+	/**
+	 * 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("")) {
+			this.appendChild(this.getOwnerDocument().createTextNode(content));
+		}
+	 }
+#end
+}



Mime
View raw message