incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svanteschub...@apache.org
Subject svn commit: r1418326 [4/8] - in /incubator/odf/trunk: ./ odfdom/ odfdom/src/main/java/org/odftoolkit/odfdom/dom/ odfdom/src/main/java/org/odftoolkit/odfdom/dom/element/table/ odfdom/src/main/java/org/odftoolkit/odfdom/dom/element/text/ odfdom/src/main/...
Date Fri, 07 Dec 2012 14:28:13 GMT
Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/element/text/TextParagraphElementBase.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/element/text/TextParagraphElementBase.java?rev=1418326&r1=1418325&r2=1418326&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/element/text/TextParagraphElementBase.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/element/text/TextParagraphElementBase.java Fri Dec  7 14:28:07 2012
@@ -1,279 +1,302 @@
-
-/************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- *
- * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Use is subject to license terms.
- *
- * Licensed 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. You can also
- * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
- *
- * 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.
- *
- ************************************************************************/
-
-/*
- * This file is automatically generated.
- * Don't edit manually.
- */
-package org.odftoolkit.odfdom.dom.element.text;
-
-import org.odftoolkit.odfdom.pkg.OdfFileDom;
-import org.odftoolkit.odfdom.pkg.OdfName;
-import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
-import org.odftoolkit.odfdom.pkg.OdfElement;
-import org.odftoolkit.odfdom.dom.element.OdfStyleBase;
-import org.odftoolkit.odfdom.dom.element.OdfStylableElement;
-import org.odftoolkit.odfdom.dom.style.OdfStyleFamily;
-import org.odftoolkit.odfdom.dom.element.OdfStyleableShapeElement;
-import org.odftoolkit.odfdom.dom.attribute.text.TextClassNamesAttribute;
-import org.odftoolkit.odfdom.dom.attribute.text.TextCondStyleNameAttribute;
-import org.odftoolkit.odfdom.dom.attribute.text.TextIdAttribute;
-import org.odftoolkit.odfdom.dom.attribute.text.TextStyleNameAttribute;
-import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlAboutAttribute;
-import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlContentAttribute;
-import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlDatatypeAttribute;
-import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlPropertyAttribute;
-import org.odftoolkit.odfdom.dom.attribute.xml.XmlIdAttribute;
-
-/**
- * DOM implementation of OpenDocument base element
- *
- */
-public abstract class TextParagraphElementBase extends OdfStylableElement {
-
-	/**
-	 * Create the instance of <code>TextParagraphElementBase</code>
-	 *
-	 * @param  ownerDoc     The type is <code>OdfFileDom</code>
-	 */
-	public TextParagraphElementBase(OdfFileDom ownerDoc, OdfName elementName, OdfStyleFamily styleFamily, OdfName styleAttrName) {
-		super(ownerDoc, elementName, styleFamily, styleAttrName);
-	}
-
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>TextClassNamesAttribute</code> , See {@odf.attribute text:class-names}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getTextClassNamesAttribute() {
-		TextClassNamesAttribute attr = (TextClassNamesAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "class-names");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>TextClassNamesAttribute</code> , See {@odf.attribute text:class-names}
-	 *
-	 * @param textClassNamesValue   The type is <code>String</code>
-	 */
-	public void setTextClassNamesAttribute(String textClassNamesValue) {
-		TextClassNamesAttribute attr = new TextClassNamesAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(textClassNamesValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>TextCondStyleNameAttribute</code> , See {@odf.attribute text:cond-style-name}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getTextCondStyleNameAttribute() {
-		TextCondStyleNameAttribute attr = (TextCondStyleNameAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "cond-style-name");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>TextCondStyleNameAttribute</code> , See {@odf.attribute text:cond-style-name}
-	 *
-	 * @param textCondStyleNameValue   The type is <code>String</code>
-	 */
-	public void setTextCondStyleNameAttribute(String textCondStyleNameValue) {
-		TextCondStyleNameAttribute attr = new TextCondStyleNameAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(textCondStyleNameValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>TextIdAttribute</code> , See {@odf.attribute text:id}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getTextIdAttribute() {
-		TextIdAttribute attr = (TextIdAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "id");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>TextIdAttribute</code> , See {@odf.attribute text:id}
-	 *
-	 * @param textIdValue   The type is <code>String</code>
-	 */
-	public void setTextIdAttribute(String textIdValue) {
-		TextIdAttribute attr = new TextIdAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(textIdValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>TextStyleNameAttribute</code> , See {@odf.attribute text:style-name}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getTextStyleNameAttribute() {
-		TextStyleNameAttribute attr = (TextStyleNameAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "style-name");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>TextStyleNameAttribute</code> , See {@odf.attribute text:style-name}
-	 *
-	 * @param textStyleNameValue   The type is <code>String</code>
-	 */
-	public void setTextStyleNameAttribute(String textStyleNameValue) {
-		TextStyleNameAttribute attr = new TextStyleNameAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(textStyleNameValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>XhtmlAboutAttribute</code> , See {@odf.attribute xhtml:about}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getXhtmlAboutAttribute() {
-		XhtmlAboutAttribute attr = (XhtmlAboutAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "about");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>XhtmlAboutAttribute</code> , See {@odf.attribute xhtml:about}
-	 *
-	 * @param xhtmlAboutValue   The type is <code>String</code>
-	 */
-	public void setXhtmlAboutAttribute(String xhtmlAboutValue) {
-		XhtmlAboutAttribute attr = new XhtmlAboutAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(xhtmlAboutValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>XhtmlContentAttribute</code> , See {@odf.attribute xhtml:content}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getXhtmlContentAttribute() {
-		XhtmlContentAttribute attr = (XhtmlContentAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "content");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>XhtmlContentAttribute</code> , See {@odf.attribute xhtml:content}
-	 *
-	 * @param xhtmlContentValue   The type is <code>String</code>
-	 */
-	public void setXhtmlContentAttribute(String xhtmlContentValue) {
-		XhtmlContentAttribute attr = new XhtmlContentAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(xhtmlContentValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>XhtmlDatatypeAttribute</code> , See {@odf.attribute xhtml:datatype}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getXhtmlDatatypeAttribute() {
-		XhtmlDatatypeAttribute attr = (XhtmlDatatypeAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "datatype");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>XhtmlDatatypeAttribute</code> , See {@odf.attribute xhtml:datatype}
-	 *
-	 * @param xhtmlDatatypeValue   The type is <code>String</code>
-	 */
-	public void setXhtmlDatatypeAttribute(String xhtmlDatatypeValue) {
-		XhtmlDatatypeAttribute attr = new XhtmlDatatypeAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(xhtmlDatatypeValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>XhtmlPropertyAttribute</code> , See {@odf.attribute xhtml:property}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getXhtmlPropertyAttribute() {
-		XhtmlPropertyAttribute attr = (XhtmlPropertyAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "property");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>XhtmlPropertyAttribute</code> , See {@odf.attribute xhtml:property}
-	 *
-	 * @param xhtmlPropertyValue   The type is <code>String</code>
-	 */
-	public void setXhtmlPropertyAttribute(String xhtmlPropertyValue) {
-		XhtmlPropertyAttribute attr = new XhtmlPropertyAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(xhtmlPropertyValue);
-	}
-
-	/**
-	 * Receives the value of the ODFDOM attribute representation <code>XmlIdAttribute</code> , See {@odf.attribute xml:id}
-	 *
-	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
-	 */
-	public String getXmlIdAttribute() {
-		XmlIdAttribute attr = (XmlIdAttribute) getOdfAttribute(OdfDocumentNamespace.XML, "id");
-		if (attr != null) {
-			return String.valueOf(attr.getValue());
-		}
-		return null;
-	}
-
-	/**
-	 * Sets the value of ODFDOM attribute representation <code>XmlIdAttribute</code> , See {@odf.attribute xml:id}
-	 *
-	 * @param xmlIdValue   The type is <code>String</code>
-	 */
-	public void setXmlIdAttribute(String xmlIdValue) {
-		XmlIdAttribute attr = new XmlIdAttribute((OdfFileDom) this.ownerDocument);
-		setOdfAttribute(attr);
-		attr.setValue(xmlIdValue);
-	}
-}
+
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ *
+ * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * Licensed 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. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+/*
+ * This file is automatically generated.
+ * Don't edit manually.
+ */
+package org.odftoolkit.odfdom.dom.element.text;
+
+import org.odftoolkit.odfdom.pkg.OdfFileDom;
+import org.odftoolkit.odfdom.pkg.OdfName;
+import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.pkg.OdfElement;
+import org.odftoolkit.odfdom.dom.element.OdfStyleBase;
+import org.odftoolkit.odfdom.dom.element.OdfStylableElement;
+import org.odftoolkit.odfdom.dom.style.OdfStyleFamily;
+import org.odftoolkit.odfdom.dom.element.OdfStyleableShapeElement;
+import org.odftoolkit.odfdom.dom.attribute.text.TextClassNamesAttribute;
+import org.odftoolkit.odfdom.dom.attribute.text.TextCondStyleNameAttribute;
+import org.odftoolkit.odfdom.dom.attribute.text.TextIdAttribute;
+import org.odftoolkit.odfdom.dom.attribute.text.TextStyleNameAttribute;
+import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlAboutAttribute;
+import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlContentAttribute;
+import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlDatatypeAttribute;
+import org.odftoolkit.odfdom.dom.attribute.xhtml.XhtmlPropertyAttribute;
+import org.odftoolkit.odfdom.dom.attribute.xml.XmlIdAttribute;
+
+/**
+ * DOM implementation of OpenDocument base element
+ *
+ */
+public abstract class TextParagraphElementBase extends OdfStylableElement {
+
+	/**
+	 * Create the instance of <code>TextParagraphElementBase</code>
+	 *
+	 * @param  ownerDoc     The type is <code>OdfFileDom</code>
+	 */
+	public TextParagraphElementBase(OdfFileDom ownerDoc, OdfName elementName, OdfStyleFamily styleFamily, OdfName styleAttrName) {
+		super(ownerDoc, elementName, styleFamily, styleAttrName);
+	}
+
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>TextClassNamesAttribute</code> , See {@odf.attribute text:class-names}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getTextClassNamesAttribute() {
+		TextClassNamesAttribute attr = (TextClassNamesAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "class-names");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>TextClassNamesAttribute</code> , See {@odf.attribute text:class-names}
+	 *
+	 * @param textClassNamesValue   The type is <code>String</code>
+	 */
+	public void setTextClassNamesAttribute(String textClassNamesValue) {
+		TextClassNamesAttribute attr = new TextClassNamesAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(textClassNamesValue);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>TextCondStyleNameAttribute</code> , See {@odf.attribute text:cond-style-name}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getTextCondStyleNameAttribute() {
+		TextCondStyleNameAttribute attr = (TextCondStyleNameAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "cond-style-name");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>TextCondStyleNameAttribute</code> , See {@odf.attribute text:cond-style-name}
+	 *
+	 * @param textCondStyleNameValue   The type is <code>String</code>
+	 */
+	public void setTextCondStyleNameAttribute(String textCondStyleNameValue) {
+		TextCondStyleNameAttribute attr = new TextCondStyleNameAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(textCondStyleNameValue);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>TextIdAttribute</code> , See {@odf.attribute text:id}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getTextIdAttribute() {
+		TextIdAttribute attr = (TextIdAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "id");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>TextIdAttribute</code> , See {@odf.attribute text:id}
+	 *
+	 * @param textIdValue   The type is <code>String</code>
+	 */
+	public void setTextIdAttribute(String textIdValue) {
+		TextIdAttribute attr = new TextIdAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(textIdValue);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>TextStyleNameAttribute</code> , See {@odf.attribute text:style-name}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getTextStyleNameAttribute() {
+		TextStyleNameAttribute attr = (TextStyleNameAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "style-name");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>TextStyleNameAttribute</code> , See {@odf.attribute text:style-name}
+	 *
+	 * @param textStyleNameValue   The type is <code>String</code>
+	 */
+	public void setTextStyleNameAttribute(String textStyleNameValue) {
+		TextStyleNameAttribute attr = new TextStyleNameAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(textStyleNameValue);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>XhtmlAboutAttribute</code> , See {@odf.attribute xhtml:about}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getXhtmlAboutAttribute() {
+		XhtmlAboutAttribute attr = (XhtmlAboutAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "about");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>XhtmlAboutAttribute</code> , See {@odf.attribute xhtml:about}
+	 *
+	 * @param xhtmlAboutValue   The type is <code>String</code>
+	 */
+	public void setXhtmlAboutAttribute(String xhtmlAboutValue) {
+		XhtmlAboutAttribute attr = new XhtmlAboutAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(xhtmlAboutValue);
+		((OdfFileDom) this.ownerDocument).updateInContentMetadataCache(this);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>XhtmlContentAttribute</code> , See {@odf.attribute xhtml:content}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getXhtmlContentAttribute() {
+		XhtmlContentAttribute attr = (XhtmlContentAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "content");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>XhtmlContentAttribute</code> , See {@odf.attribute xhtml:content}
+	 *
+	 * @param xhtmlContentValue   The type is <code>String</code>
+	 */
+	public void setXhtmlContentAttribute(String xhtmlContentValue) {
+		XhtmlContentAttribute attr = new XhtmlContentAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(xhtmlContentValue);
+		((OdfFileDom) this.ownerDocument).updateInContentMetadataCache(this);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>XhtmlDatatypeAttribute</code> , See {@odf.attribute xhtml:datatype}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getXhtmlDatatypeAttribute() {
+		XhtmlDatatypeAttribute attr = (XhtmlDatatypeAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "datatype");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>XhtmlDatatypeAttribute</code> , See {@odf.attribute xhtml:datatype}
+	 *
+	 * @param xhtmlDatatypeValue   The type is <code>String</code>
+	 */
+	public void setXhtmlDatatypeAttribute(String xhtmlDatatypeValue) {
+		XhtmlDatatypeAttribute attr = new XhtmlDatatypeAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(xhtmlDatatypeValue);
+		((OdfFileDom) this.ownerDocument).updateInContentMetadataCache(this);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>XhtmlPropertyAttribute</code> , See {@odf.attribute xhtml:property}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getXhtmlPropertyAttribute() {
+		XhtmlPropertyAttribute attr = (XhtmlPropertyAttribute) getOdfAttribute(OdfDocumentNamespace.XHTML, "property");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>XhtmlPropertyAttribute</code> , See {@odf.attribute xhtml:property}
+	 *
+	 * @param xhtmlPropertyValue   The type is <code>String</code>
+	 */
+	public void setXhtmlPropertyAttribute(String xhtmlPropertyValue) {
+		XhtmlPropertyAttribute attr = new XhtmlPropertyAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(xhtmlPropertyValue);
+		((OdfFileDom) this.ownerDocument).updateInContentMetadataCache(this);
+	}
+
+	/**
+	 * Receives the value of the ODFDOM attribute representation <code>XmlIdAttribute</code> , See {@odf.attribute xml:id}
+	 *
+	 * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
+	 */
+	public String getXmlIdAttribute() {
+		XmlIdAttribute attr = (XmlIdAttribute) getOdfAttribute(OdfDocumentNamespace.XML, "id");
+		if (attr != null) {
+			return String.valueOf(attr.getValue());
+		}
+		return null;
+	}
+
+	/**
+	 * Sets the value of ODFDOM attribute representation <code>XmlIdAttribute</code> , See {@odf.attribute xml:id}
+	 *
+	 * @param xmlIdValue   The type is <code>String</code>
+	 */
+	public void setXmlIdAttribute(String xmlIdValue) {
+		XmlIdAttribute attr = new XmlIdAttribute((OdfFileDom) this.ownerDocument);
+		setOdfAttribute(attr);
+		attr.setValue(xmlIdValue);
+	}
+	
+	/**
+	* Set text content. Only elements which are allowed to have text content offer this method.
+	*
+	*/
+	public void setTextContent(String content){
+		super.setTextContent(content);
+		((OdfFileDom) this.ownerDocument).updateInContentMetadataCache(this);
+	}
+
+	protected void onRemoveNode() {
+		super.onRemoveNode();
+		((OdfFileDom) this.ownerDocument).getInContentMetadataCache().remove(this);
+	}
+
+	protected void onInsertNode() {
+		super.onInsertNode();
+		((OdfFileDom) this.ownerDocument).updateInContentMetadataCache(this);
+	}
+}

Added: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/rdfa/BookmarkRDFMetadataExtractor.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/rdfa/BookmarkRDFMetadataExtractor.java?rev=1418326&view=auto
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/rdfa/BookmarkRDFMetadataExtractor.java (added)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/dom/rdfa/BookmarkRDFMetadataExtractor.java Fri Dec  7 14:28:07 2012
@@ -0,0 +1,320 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ * 
+ * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
+ * 
+ * Use is subject to license terms.
+ * 
+ * Licensed 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. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ * 
+ * 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.
+ *
+ ************************************************************************/
+package org.odftoolkit.odfdom.dom.rdfa;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.StartElement;
+
+import org.odftoolkit.odfdom.dom.DefaultElementVisitor;
+import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
+import org.odftoolkit.odfdom.dom.element.text.TextBookmarkEndElement;
+import org.odftoolkit.odfdom.dom.element.text.TextBookmarkStartElement;
+import org.odftoolkit.odfdom.pkg.OdfElement;
+import org.odftoolkit.odfdom.pkg.OdfFileDom;
+import org.odftoolkit.odfdom.pkg.rdfa.DOMAttributes;
+import org.odftoolkit.odfdom.pkg.rdfa.JenaSink;
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+
+/**
+ * This is a sub class of <code>DefaultElementVisitor</code>, which is used to
+ * extract metadata from {@odf.element text:bookmark-start} to
+ * {@odf.element text:bookmark-end} pair.
+ */
+public class BookmarkRDFMetadataExtractor extends DefaultElementVisitor {
+
+	protected static final char NewLineChar = '\n';
+	protected static final char TabChar = '\t';
+	private TextBookmarkStartElement bookmarkstart;
+	private boolean found;
+	protected final Map<TextBookmarkStartElement, ExtractorStringBuilder> builderMap;
+	protected final Map<TextBookmarkStartElement, String> stringMap;
+
+	private XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+
+	private JenaSink sink;
+
+	/**
+	 * This class is used to provide the string builder functions to extractor.
+	 * It will automatically process the last NewLineChar.
+	 * 
+	 * @since 0.3.5
+	 */
+	protected static class ExtractorStringBuilder {
+		private StringBuilder mBuilder;
+		private boolean lastAppendNewLine;
+
+		ExtractorStringBuilder() {
+			mBuilder = new StringBuilder();
+			lastAppendNewLine = false;
+		}
+
+		/**
+		 * Append a string
+		 * 
+		 * @param str
+		 *            - the string
+		 */
+		public void append(String str) {
+			mBuilder.append(str);
+		}
+
+		/**
+		 * Append a character
+		 * 
+		 * @param ch
+		 *            - the character
+		 */
+		public void append(char ch) {
+			mBuilder.append(ch);
+		}
+
+		/**
+		 * Append a new line character at the end
+		 */
+		public void appendLine() {
+			mBuilder.append(NewLineChar);
+			lastAppendNewLine = true;
+		}
+
+		/**
+		 * Return the string value.
+		 * <p>
+		 * If the last character is a new line character and is appended with
+		 * appendLine(), the last new line character will be removed.
+		 */
+		public String toString() {
+			if (lastAppendNewLine) {
+				mBuilder.deleteCharAt(mBuilder.length() - 1);
+			}
+			return mBuilder.toString();
+		}
+	}
+
+	/**
+	 * Create a BookmarkRDFMetadataExtractor instance, which RDF metadata
+	 * content of bookmarks can be extracted by
+	 * <code>getBookmarkRDFMetadata()</code>.
+	 * 
+	 * @param element
+	 *            the ODF element whose text will be extracted.
+	 * @return an instance of BookmarkRDFMetadataExtractor
+	 */
+	public static BookmarkRDFMetadataExtractor newBookmarkTextExtractor() {
+		return new BookmarkRDFMetadataExtractor();
+	}
+
+	/**
+	 * Return the RDF metadata of specified ODF element as a Jena Model.
+	 * 
+	 * @return the text content as a string
+	 */
+	public Model getBookmarkRDFMetadata(OdfFileDom dom) {
+		this.bookmarkstart = null;
+		this.found = false;
+		this.sink = dom.getSink();
+		visit(dom.getRootElement());
+		return getModel();
+	}
+
+	public Model getBookmarkRDFMetadata(TextBookmarkStartElement bookmarkstart) {
+		this.bookmarkstart = bookmarkstart;
+		this.found = false;
+		this.sink = ((OdfFileDom) bookmarkstart.getOwnerDocument()).getSink();
+		visit(((OdfFileDom) bookmarkstart.getOwnerDocument()).getRootElement());
+		return getModel();
+	}
+
+	private Model getModel() {
+		Model m = ModelFactory.createDefaultModel();
+		for (Entry<TextBookmarkStartElement, String> entry : stringMap
+				.entrySet()) {
+			String xhtmlAbout = entry.getKey().getXhtmlAboutAttribute();
+			String xhtmlProperty = entry.getKey().getXhtmlPropertyAttribute();
+			String xhtmlContent = entry.getKey().getXhtmlContentAttribute();
+			if (xhtmlAbout != null && xhtmlProperty != null) {
+				String qname = entry.getKey().getNodeName();
+				String namespaceURI = entry.getKey().getNamespaceURI();
+				String localname = entry.getKey().getLocalName();
+				String prefix = (qname.indexOf(':') == -1) ? "" : qname
+						.substring(0, qname.indexOf(':'));
+
+				StartElement e = eventFactory.createStartElement(prefix,
+						namespaceURI, localname,
+						fromAttributes(new DOMAttributes(entry.getKey()
+								.getAttributes())), null, sink.getContext());
+
+				xhtmlAbout = sink.getExtractor().expandSafeCURIE(e, xhtmlAbout,
+						sink.getContext());
+				xhtmlProperty = sink.getExtractor().expandCURIE(e,
+						xhtmlProperty, sink.getContext());
+				Resource s = m.createResource(xhtmlAbout);
+				Property p = m.createProperty(xhtmlProperty);
+				if (xhtmlContent != null) {
+					s.addLiteral(p, xhtmlContent);
+				} else {
+					s.addLiteral(p, entry.getValue());
+				}
+
+			}
+		}
+		return m;
+	}
+
+	private Iterator fromAttributes(Attributes attributes) {
+		List toReturn = new LinkedList();
+
+		for (int i = 0; i < attributes.getLength(); i++) {
+			String qname = attributes.getQName(i);
+			String prefix = qname.contains(":") ? qname.substring(0,
+					qname.indexOf(":")) : "";
+			Attribute attr = eventFactory.createAttribute(prefix,
+					attributes.getURI(i), attributes.getLocalName(i),
+					attributes.getValue(i));
+
+			if (!qname.equals("xmlns") && !qname.startsWith("xmlns:"))
+				toReturn.add(attr);
+		}
+
+		return toReturn.iterator();
+	}
+
+	/**
+	 * Constructor with an ODF element as parameter
+	 * 
+	 * @param element
+	 *            the ODF element whose text would be extracted.
+	 */
+	private BookmarkRDFMetadataExtractor() {
+		builderMap = new HashMap<TextBookmarkStartElement, ExtractorStringBuilder>();
+		stringMap = new HashMap<TextBookmarkStartElement, String>();
+	}
+
+	/**
+	 * The end users needn't to care of this method, if you don't want to
+	 * override the text content handling strategy of <code>OdfElement</code>.
+	 * 
+	 * @see org.odftoolkit.odfdom.dom.DefaultElementVisitor#visit(org.odftoolkit.odfdom.pkg.OdfElement)
+	 */
+	@Override
+	public void visit(OdfElement element) {
+		if (bookmarkstart != null && found) {
+			return;
+		}
+		if (this.bookmarkstart == null) {
+			if (element instanceof TextBookmarkStartElement) {
+				builderMap.put((TextBookmarkStartElement) element,
+						new ExtractorStringBuilder());
+			}
+
+		} else {
+			if (element == bookmarkstart) {
+				builderMap.put((TextBookmarkStartElement) element,
+						new ExtractorStringBuilder());
+			}
+		}
+		appendElementText(element);
+		if (element.getNamespaceURI()
+				.equals(OdfDocumentNamespace.META.getUri())
+				|| element.getNamespaceURI().equals(
+						OdfDocumentNamespace.DC.getUri())) {
+			// textBuilderAppendLine();
+		}
+	}
+
+	/**
+	 * Append the text content of this element to string buffer.
+	 * 
+	 * @param ele
+	 *            the ODF element whose text will be appended.
+	 */
+	private void appendElementText(OdfElement ele) {
+		Node node = ele.getFirstChild();
+		while (node != null) {
+			if (node.getNodeType() == Node.TEXT_NODE) {
+				textBuilderAppend(node.getNodeValue());
+			} else if (node.getNodeType() == Node.ELEMENT_NODE) {
+				if (node instanceof TextBookmarkEndElement) {
+					TextBookmarkEndElement end = (TextBookmarkEndElement) node;
+					endBookmark(end);
+				}
+
+				OdfElement element = (OdfElement) node;
+				element.accept(this);
+			}
+			node = node.getNextSibling();
+		}
+	}
+
+	private void textBuilderAppendLine() {
+		for (Entry<TextBookmarkStartElement, ExtractorStringBuilder> entry : builderMap
+				.entrySet()) {
+			entry.getValue().appendLine();
+		}
+	}
+
+	private void textBuilderAppend(char ch) {
+		for (Entry<TextBookmarkStartElement, ExtractorStringBuilder> entry : builderMap
+				.entrySet()) {
+			entry.getValue().append(ch);
+		}
+	}
+
+	private void textBuilderAppend(String str) {
+		for (Entry<TextBookmarkStartElement, ExtractorStringBuilder> entry : builderMap
+				.entrySet()) {
+			entry.getValue().append(str);
+		}
+	}
+
+	private void endBookmark(TextBookmarkEndElement end) {
+		TextBookmarkStartElement start = null;
+		for (Entry<TextBookmarkStartElement, ExtractorStringBuilder> entry : builderMap
+				.entrySet()) {
+			if (entry.getKey().getTextNameAttribute()
+					.equals(end.getTextNameAttribute())) {
+				start = entry.getKey();
+				break;
+			}
+		}
+		if (start != null) {
+			stringMap.put(start, builderMap.get(start).toString());
+			builderMap.remove(start);
+			if (bookmarkstart != null) {
+				found = true;
+			}
+		}
+	}
+}

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java?rev=1418326&r1=1418325&r2=1418326&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfFileDom.java Fri Dec  7 14:28:07 2012
@@ -1,591 +1,685 @@
-/************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- * 
- * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- * 
- * Use is subject to license terms.
- * 
- * Licensed 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. You can also
- * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
- * 
- * 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.
- *
- ************************************************************************/
-package org.odftoolkit.odfdom.pkg;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.xerces.dom.DocumentImpl;
-import org.odftoolkit.odfdom.dom.OdfContentDom;
-import org.odftoolkit.odfdom.dom.OdfMetaDom;
-import org.odftoolkit.odfdom.dom.OdfSchemaDocument;
-import org.odftoolkit.odfdom.dom.OdfSettingsDom;
-import org.odftoolkit.odfdom.dom.OdfStylesDom;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-
-/**
- * The DOM repesentation of an XML file within the ODF document.
- */
-public class OdfFileDom extends DocumentImpl implements NamespaceContext {
-
-	private static final long serialVersionUID = 766167617530147000L;
-	protected String mPackagePath;
-	protected OdfPackageDocument mPackageDocument;
-	protected OdfPackage mPackage;
-	protected XPath mXPath;
-	protected Map<String, String> mUriByPrefix;
-	protected Map<String, String> mPrefixByUri;
-	/** Contains only the duplicate prefix. 
-	 * The primary hold by mPrefixByUri still have to be added */
-	protected Map<String, Set<String>> mDuplicatePrefixesByUri;
-
-	/**
-	 * Creates the DOM representation of an XML file of an Odf document.
-	 *
-	 * @param packageDocument   the document the XML files belongs to
-	 * @param packagePath   the internal package path to the XML file
-	 */
-	protected OdfFileDom(OdfPackageDocument packageDocument, String packagePath) {
-		super(false);
-		if (packageDocument != null && packagePath != null) {
-
-			mPackageDocument = packageDocument;
-			mPackage = packageDocument.getPackage();
-			mPackagePath = packagePath;
-			mUriByPrefix = new HashMap<String, String>();
-			mPrefixByUri = new HashMap<String, String>();
-			mDuplicatePrefixesByUri = new HashMap<String, Set<String>>();
-			initialize();
-			// Register every DOM to OdfPackage,
-			// so a package close might save this DOM (similar as OdfDocumentPackage)
-			this.addDomToCache(mPackageDocument.mPackage, packagePath);
-		} else {
-			throw new IllegalArgumentException("Arguments are not allowed to be NULL for OdfFileDom constructor!");
-		}
-	}
-
-	/** Adds the document to the pool of open documents of the package.
-	A document of a certain path is opened only once to avoid data duplication.
-	 */
-	private void addDomToCache(OdfPackage pkg, String internalPath) {
-		pkg.cacheDom(this, internalPath);
-	}
-
-	public static OdfFileDom newFileDom(OdfPackageDocument packageDocument, String packagePath) {
-		OdfFileDom newFileDom = null;
-		// before creating a new dom, make sure that there no DOM opened for this file already
-		Document existingDom = packageDocument.getPackage().getCachedDom(packagePath);
-		if (existingDom == null) {
-			// ToDo: bug 264 - register OdfFileDom to this class
-			if (packagePath.equals("content.xml") || packagePath.endsWith("/content.xml")) {
-				newFileDom = new OdfContentDom((OdfSchemaDocument) packageDocument, packagePath);
-			} else if (packagePath.equals("styles.xml") || packagePath.endsWith("/styles.xml")) {
-				newFileDom = new OdfStylesDom((OdfSchemaDocument) packageDocument, packagePath);
-			} else if (packagePath.equals("meta.xml") || packagePath.endsWith("/meta.xml")) {
-				newFileDom = new OdfMetaDom((OdfSchemaDocument) packageDocument, packagePath);
-			} else if (packagePath.equals("settings.xml") || packagePath.endsWith("/settings.xml")) {
-				newFileDom = new OdfSettingsDom((OdfSchemaDocument) packageDocument, packagePath);
-			} else {
-				newFileDom = new OdfFileDom(packageDocument, packagePath);
-			}
-		} else {
-			if (existingDom instanceof OdfFileDom) {
-				newFileDom = (OdfFileDom) existingDom;
-//ToDO: Issue 264 - Otherwise if NOT an OdfFileDom serialize old DOM AND CREATE A NEW ONE?!
-// Or shall we always reference to the dom, than we can not inherit from Document? Pro/Con?s
-//			}else{
-//				// Create an OdfFileDOM from an existing DOM
-//				newFileDom =
-			}
-
-		}
-		return newFileDom;
-	}
-
-	protected void initialize() {
-		InputStream fileStream = null;
-		try {
-			fileStream = mPackage.getInputStream(mPackagePath);
-			if (fileStream != null) {
-				XMLReader xmlReader = mPackage.getXMLReader();
-				xmlReader.setContentHandler(new OdfFileSaxHandler(this));
-				InputSource xmlSource = new InputSource(fileStream);
-				xmlReader.parse(xmlSource);
-			}
-
-		} catch (Exception ex) {
-			Logger.getLogger(OdfPackageDocument.class.getName()).log(Level.SEVERE, null, ex);
-		} finally {
-			try {
-				if (fileStream != null) {
-					fileStream.close();
-				}
-			} catch (IOException ex) {
-				Logger.getLogger(OdfPackageDocument.class.getName()).log(Level.SEVERE, null, ex);
-			}
-		}
-	}
-
-	/**
-	 * Retrieves the <code>OdfPackageDocument</code> of the XML file.
-	 * A package document is usually represented as a directory with a mediatype.
-	 *
-	 * @return The document holding the XML file.
-	 *
-	 */
-	public OdfPackageDocument getDocument() {
-		return mPackageDocument;
-	}
-
-	/**
-	 * Retrieves the <code>String</code> of Package Path
-	 * 
-	 * @return The path of the XML file relative to the package root
-	 */
-	public String getPackagePath() {
-		return mPackagePath;
-	}
-
-	/**
-	 * Retrieves the ODF root element.
-	 *
-	 * @return The <code>OdfElement</code> being the root of the document.
-	 */
-	public OdfElement getRootElement() {
-		return (OdfElement) getDocumentElement();
-	}
-
-	/**
-	 * Create ODF element with namespace uri and qname
-	 *
-	 * @param name The element name
-	 *
-	 */
-	@Override
-	public OdfElement createElement(String name) throws DOMException {
-		return createElementNS(OdfName.newName(name));
-	}
-
-	/**
-	 * Create ODF element with namespace uri and qname
-	 *
-	 * @param nsuri The namespace uri
-	 * @param qname The element qname
-	 *
-	 */
-	@Override
-	public OdfElement createElementNS(String nsuri, String qname) throws DOMException {
-		return createElementNS(OdfName.newName(nsuri, qname));
-	}
-
-	/**
-	 * Create ODF element with ODF name
-	 * @param name The <code>OdfName</code>
-	 * @return The <code>OdfElement</code>
-	 * @throws DOMException
-	 */
-	public OdfElement createElementNS(OdfName name) throws DOMException {
-		return OdfXMLFactory.newOdfElement(this, name);
-	}
-
-	/**
-	 * Create the ODF attribute with its name
-	 *
-	 * @param name  the attribute qname
-	 * @return The <code>OdfAttribute</code>
-	 * @throws  DOMException
-	 */
-	@Override
-	public OdfAttribute createAttribute(String name) throws DOMException {
-		return createAttributeNS(OdfName.newName(name));
-	}
-
-	/**
-	 * Create the ODF attribute with namespace uri and qname
-	 * 
-	 * @param nsuri  The namespace uri
-	 * @param qname  the attribute qname
-	 * @return The <code>OdfAttribute</code>
-	 * @throws  DOMException
-	 */
-	@Override
-	public OdfAttribute createAttributeNS(String nsuri, String qname) throws DOMException {
-		return createAttributeNS(OdfName.newName(nsuri, qname));
-	}
-
-	/**
-	 * Create the ODF attribute with ODF name
-	 * @param name The <code>OdfName</code>
-	 * @return  The <code>OdfAttribute</code>
-	 * @throws DOMException
-	 */
-	public OdfAttribute createAttributeNS(OdfName name) throws DOMException {
-		return OdfXMLFactory.newOdfAttribute(this, name);
-	}
-
-	@SuppressWarnings("unchecked")
-	public <T extends OdfElement> T newOdfElement(Class<T> clazz) {
-		//return (T) OdfXMLFactory.getNodeFromClass(this, clazz);
-		try {
-			Field fname = clazz.getField("ELEMENT_NAME");
-			OdfName name = (OdfName) fname.get(null);
-			return (T) createElementNS(name);
-		} catch (Exception ex) {
-			if (ex instanceof RuntimeException) {
-				throw (RuntimeException) ex;
-			}
-			return null;
-		}
-	}
-
-	@Override
-	public String toString() {
-		return ((OdfElement) this.getDocumentElement()).toString();
-	}
-
-	// JDK Namespace handling
-	/**
-	 * Create an XPath instance to select one or more nodes from an ODF document.
-	 * Therefore the namespace context is set to the OdfNamespace
-	 * @return an XPath instance with namespace context set to include the standard
-	 * ODFDOM prefixes.
-	 */
-	public XPath getXPath() {
-		if (mXPath == null) {
-			mXPath = XPathFactory.newInstance().newXPath();
-		}
-		return mXPath;
-	}
-
-	/**
-	 * <p>Get Namespace URI bound to a prefix in the current scope (the XML file).</p>
-	 *
-	 * <p>When requesting a Namespace URI by prefix, the following
-	 * table describes the returned Namespace URI value for all
-	 * possible prefix values:</p>
-	 *
-	 * <table border="2" rules="all" cellpadding="4">
-	 *   <thead>
-	 *     <tr>
-	 *       <td align="center" colspan="2">
-	 *         <code>getNamespaceURI(prefix)</code>
-	 *         return value for specified prefixes
-	 *       </td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td>prefix parameter</td>
-	 *       <td>Namespace URI return value</td>
-	 *     </tr>
-	 *   </thead>
-	 *   <tbody>
-	 *     <tr>
-	 *       <td><code>DEFAULT_NS_PREFIX</code> ("")</td>
-	 *       <td>default Namespace URI in the current scope or
-	 *         <code>{@link
-	 *         javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")}
-	 *         </code>
-	 *         when there is no default Namespace URI in the current scope</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td>bound prefix</td>
-	 *       <td>Namespace URI bound to prefix in current scope</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td>unbound prefix</td>
-	 *       <td>
-	 *         <code>{@link
-	 *         javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")}
-	 *         </code>
-	 *       </td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
-	 *       <td><code>XMLConstants.XML_NS_URI</code>
-	 *           ("http://www.w3.org/XML/1998/namespace")</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
-	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
-	 *         ("http://www.w3.org/2000/xmlns/")</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>null</code></td>
-	 *       <td><code>IllegalArgumentException</code> is thrown</td>
-	 *     </tr>
-	 *    </tbody>
-	 * </table>
-	 *
-	 * @param prefix prefix to look up
-	 *
-	 * @return Namespace URI bound to prefix in the current scope
-	 *
-	 * @throws IllegalArgumentException When <code>prefix</code> is
-	 *   <code>null</code>
-	 */
-	public String getNamespaceURI(String prefix) {
-		String nsURI = null;
-		nsURI = mUriByPrefix.get(prefix);
-		if (nsURI == null) {
-			// look in Duplicate URI prefixes
-			Set<String> urisWithDuplicatePrefixes = this.mDuplicatePrefixesByUri.keySet();
-			for (String aURI : urisWithDuplicatePrefixes) {
-				Set<String> prefixes = this.mDuplicatePrefixesByUri.get(aURI);
-				// check if requested prefix exists in hashset
-				if (prefixes.contains(prefix)) {
-					nsURI = aURI;
-					break;
-				}
-			}
-		}
-		// there is a possibility it still may be null - so we check
-		if (nsURI == null) {
-			nsURI = XMLConstants.NULL_NS_URI;
-		}
-		return nsURI;
-	}
-
-	/**
-	 * <p>Get prefix bound to Namespace URI in the current scope (the XML file).</p>
-	 * <p>Multiple prefixes bound to Namespace URI will be normalized to the first prefix defined.</p>
-	 *
-	 * <p>When requesting a prefix by Namespace URI, the following
-	 * table describes the returned prefix value for all Namespace URI
-	 * values:</p>
-	 *
-	 * <table border="2" rules="all" cellpadding="4">
-	 *   <thead>
-	 *     <tr>
-	 *       <th align="center" colspan="2">
-	 *         <code>getPrefix(namespaceURI)</code> return value for
-	 *         specified Namespace URIs
-	 *       </th>
-	 *     </tr>
-	 *     <tr>
-	 *       <th>Namespace URI parameter</th>
-	 *       <th>prefix value returned</th>
-	 *     </tr>
-	 *   </thead>
-	 *   <tbody>
-	 *     <tr>
-	 *       <td>&lt;default Namespace URI&gt;</td>
-	 *       <td><code>XMLConstants.DEFAULT_NS_PREFIX</code> ("")
-	 *       </td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td>bound Namespace URI</td>
-	 *       <td>prefix bound to Namespace URI in the current scope,
-	 *           if multiple prefixes are bound to the Namespace URI in
-	 *           the current scope, a single arbitrary prefix, whose
-	 *           choice is implementation dependent, is returned</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td>unbound Namespace URI</td>
-	 *       <td><code>null</code></td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>XMLConstants.XML_NS_URI</code>
-	 *           ("http://www.w3.org/XML/1998/namespace")</td>
-	 *       <td><code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
-	 *           ("http://www.w3.org/2000/xmlns/")</td>
-	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>null</code></td>
-	 *       <td><code>IllegalArgumentException</code> is thrown</td>
-	 *     </tr>
-	 *   </tbody>
-	 * </table>
-	 *
-	 * @param namespaceURI URI of Namespace to lookup
-	 *
-	 * @return prefix bound to Namespace URI in current context
-	 *
-	 * @throws IllegalArgumentException When <code>namespaceURI</code> is
-	 *   <code>null</code>
-	 */
-	public String getPrefix(String namespaceURI) {
-		return mPrefixByUri.get(namespaceURI);
-	}
-
-	/**
-	 * <p>Get all prefixes bound to a Namespace URI in the current
-	 * scope. (the XML file)</p>
-	 * <p>NOTE: Multiple prefixes bound to a similar Namespace URI will be normalized to the first prefix defined.
-	 * Still the namespace attributes exist in the XML as inner value prefixes might be used.</p>
-	 *
-	 * <p><strong>The <code>Iterator</code> is
-	 * <em>not</em> modifiable.  e.g. the
-	 * <code>remove()</code> method will throw
-	 * <code>UnsupportedOperationException</code>.</strong></p>
-	 *
-	 * <p>When requesting prefixes by Namespace URI, the following
-	 * table describes the returned prefixes value for all Namespace
-	 * URI values:</p>
-	 *
-	 * <table border="2" rules="all" cellpadding="4">
-	 *   <thead>
-	 *     <tr>
-	 *       <th align="center" colspan="2"><code>
-	 *         getPrefixes(namespaceURI)</code> return value for
-	 *         specified Namespace URIs</th>
-	 *     </tr>
-	 *     <tr>
-	 *       <th>Namespace URI parameter</th>
-	 *       <th>prefixes value returned</th>
-	 *     </tr>
-	 *   </thead>
-	 *   <tbody>
-	 *     <tr>
-	 *       <td>bound Namespace URI,
-	 *         including the &lt;default Namespace URI&gt;</td>
-	 *       <td>
-	 *         <code>Iterator</code> over prefixes bound to Namespace URI in
-	 *         the current scope in an arbitrary,
-	 *         <strong>implementation dependent</strong>,
-	 *         order
-	 *       </td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td>unbound Namespace URI</td>
-	 *       <td>empty <code>Iterator</code></td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>XMLConstants.XML_NS_URI</code>
-	 *           ("http://www.w3.org/XML/1998/namespace")</td>
-	 *       <td><code>Iterator</code> with one element set to
-	 *         <code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
-	 *           ("http://www.w3.org/2000/xmlns/")</td>
-	 *       <td><code>Iterator</code> with one element set to
-	 *         <code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
-	 *     </tr>
-	 *     <tr>
-	 *       <td><code>null</code></td>
-	 *       <td><code>IllegalArgumentException</code> is thrown</td>
-	 *     </tr>
-	 *   </tbody>
-	 * </table>
-	 *
-	 * @param namespaceURI URI of Namespace to lookup
-	 *
-	 * @return <code>Iterator</code> for all prefixes bound to the
-	 *   Namespace URI in the current scope
-	 *
-	 * @throws IllegalArgumentException When <code>namespaceURI</code> is
-	 *   <code>null</code>
-	 */
-	public Iterator<String> getPrefixes(String namespaceURI) {
-		Set<String> prefixes = mDuplicatePrefixesByUri.get(namespaceURI);
-		if (prefixes == null) {
-			prefixes = new HashSet<String>();
-		}
-		String givenPrefix = mPrefixByUri.get(namespaceURI);
-		if(givenPrefix != null){
-			prefixes.add(givenPrefix);
-		}
-		return prefixes.iterator();
-	}
-
-	/** @return a map of namespaces, where the URI is the key and the prefix is the value */
-	Map<String, String> getMapNamespacePrefixByUri() {
-		return mPrefixByUri;
-	}
-
-	/** Adds a new Namespace to the DOM. Making the prefix usable with JDK <code>XPath</code>.
-	 * All namespace attributes will be written to the root element during later serialization of the DOM by the <code>OdfPackage</code>.
-	 * @param prefix of the namespace to be set to this DOM
-	 * @param uri of the namespace to be set to this DOM
-	 * @return the namespace that was set. If an URI was registered before to the DOM, the previous prefix will be taken.
-	 * In case of a given prefix that was already registered, but related to a new URI, the prefix will be adapted.
-	 * The new prefix receives the suffix '__' plus integer, e.g. "__1" for the first duplicate and "__2" for the second.
-	 */
-	public OdfNamespace setNamespace(String prefix, String uri) {
-		//collision detection, when a new prefix/URI pair exists
-		OdfNamespace newNamespace = null;
-		//Scenario a) the URI already registered, use existing prefix
-		// but save all others for the getPrefixes function. There might be still some
-		// in attribute values using prefixes, that were not exchanged.
-		String existingPrefix = mPrefixByUri.get(uri);
-		if (existingPrefix != null) {
-			//Use the existing prefix of the used URL, neglect the given
-			newNamespace = OdfNamespace.newNamespace(existingPrefix, uri);
-
-			//Add the new prefix to the duplicate prefix map for getPrefixes(String uri)
-			Set<String> prefixes = mDuplicatePrefixesByUri.get(uri);
-			if (prefixes == null) {
-				prefixes = new HashSet<String>();
-				mDuplicatePrefixesByUri.put(uri, prefixes);
-			}
-			prefixes.add(prefix);
-		} else {
-			//Scenario b) the prefix already exists and the URI does not exist
-			String existingURI = mUriByPrefix.get(prefix);
-			if (existingURI != null && !existingURI.equals(uri)) {
-				//Change the prefix appending "__" plus counter.
-				int i = 1;
-				do {
-					int suffixStart = prefix.lastIndexOf("__");
-					if (suffixStart != -1) {
-						prefix = prefix.substring(0, suffixStart);
-					}
-					//users have to take care for their attribute values using namespace prefixes.
-					prefix = prefix + "__" + i;
-					i++;
-					existingURI = mUriByPrefix.get(prefix);
-				} while (existingURI != null && !existingURI.equals(uri));
-			}
-			newNamespace = OdfNamespace.newNamespace(prefix, uri);
-			mPrefixByUri.put(uri, prefix);
-			mUriByPrefix.put(prefix, uri);
-		}
-		// if the file Dom is already associated to parsed XML add the new namespace to the root element
-		Element root = getRootElement();
-		if (root != null) {
-			root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, uri);
-		}
-		return newNamespace;
-	}
-
-	/** Adds a new Namespace to the DOM. Making the prefix usable with JDK <code>XPath</code>.
-	 * All namespace attributes will be written to the root element during later serialization of the DOM by the <code>OdfPackage</code>.
-	 * @param name the namespace to be set
-	 * @return the namespace that was set. If an URI was registered before to the DOM, the previous prefix will be taken.
-	 * In case of a given prefix that was already registered, but related to a new URI, the prefix will be adapted.
-	 * The new prefix receives the suffix '__' plus integer, e.g. "__1" for the first duplicate and "__2" for the second.
-	 */
-	public OdfNamespace setNamespace(NamespaceName name) {
-		return setNamespace(name.getPrefix(), name.getUri());
-	}
-
-}
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ * 
+ * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
+ * 
+ * Use is subject to license terms.
+ * 
+ * Licensed 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. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ * 
+ * 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.
+ *
+ ************************************************************************/
+package org.odftoolkit.odfdom.pkg;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.xerces.dom.DocumentImpl;
+import org.odftoolkit.odfdom.dom.OdfContentDom;
+import org.odftoolkit.odfdom.dom.OdfMetaDom;
+import org.odftoolkit.odfdom.dom.OdfSchemaDocument;
+import org.odftoolkit.odfdom.dom.OdfSettingsDom;
+import org.odftoolkit.odfdom.dom.OdfStylesDom;
+import org.odftoolkit.odfdom.dom.rdfa.BookmarkRDFMetadataExtractor;
+import org.odftoolkit.odfdom.pkg.manifest.OdfManifestDom;
+import org.odftoolkit.odfdom.pkg.rdfa.DOMRDFaParser;
+import org.odftoolkit.odfdom.pkg.rdfa.JenaSink;
+import org.odftoolkit.odfdom.pkg.rdfa.MultiContentHandler;
+import org.odftoolkit.odfdom.pkg.rdfa.SAXRDFaParser;
+import org.odftoolkit.odfdom.pkg.rdfa.Util;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+import com.hp.hpl.jena.rdf.model.Model;
+
+/**
+ * The DOM representation of an XML file within the ODF document.
+ */
+public class OdfFileDom extends DocumentImpl implements NamespaceContext {
+
+	private static final long serialVersionUID = 766167617530147000L;
+	protected String mPackagePath;
+	protected OdfPackageDocument mPackageDocument;
+	protected OdfPackage mPackage;
+	protected XPath mXPath;
+	protected Map<String, String> mUriByPrefix;
+	protected Map<String, String> mPrefixByUri;
+	/** Contains only the duplicate prefix. 
+	 * The primary hold by mPrefixByUri still have to be added
+	 */
+	protected Map<String, Set<String>> mDuplicatePrefixesByUri;
+	/**
+	* The cache of in content metadata: key: a Node in the dom ; value: the
+	* Jena RDF model of triples of the Node
+	*/
+	protected Map<Node, Model> inCententMetadataCache;
+
+	protected JenaSink sink;
+	
+	/**
+	 * Creates the DOM representation of an XML file of an Odf document.
+	 *
+	 * @param packageDocument   the document the XML files belongs to
+	 * @param packagePath   the internal package path to the XML file
+	 */
+	protected OdfFileDom(OdfPackageDocument packageDocument, String packagePath) {
+		super(false);
+		if (packageDocument != null && packagePath != null) {
+
+			mPackageDocument = packageDocument;
+			mPackage = packageDocument.getPackage();
+			mPackagePath = packagePath;
+			mUriByPrefix = new HashMap<String, String>();
+			mPrefixByUri = new HashMap<String, String>();
+			mDuplicatePrefixesByUri = new HashMap<String, Set<String>>();
+			inCententMetadataCache = new IdentityHashMap<Node, Model>();
+			initialize();
+			// Register every DOM to OdfPackage,
+			// so a package close might save this DOM (similar as OdfDocumentPackage)
+			this.addDomToCache(mPackageDocument.mPackage, packagePath);
+		} else {
+			throw new IllegalArgumentException("Arguments are not allowed to be NULL for OdfFileDom constructor!");
+		}
+	}
+
+	/**
+	* Creates the DOM representation of an XML file of an Odf document.
+	*
+	* @param pkg
+	* the package the XML files belongs to
+	* @param packagePath
+	* the internal package path to the XML file
+	*/
+	protected OdfFileDom(OdfPackage pkg, String packagePath) {
+		super(false);
+		if (pkg != null && packagePath != null) {
+			mPackageDocument = null;
+			mPackage = pkg;
+			mPackagePath = packagePath;
+			mUriByPrefix = new HashMap<String, String>();
+			mPrefixByUri = new HashMap<String, String>();
+			mDuplicatePrefixesByUri = new HashMap<String, Set<String>>();
+			inCententMetadataCache = new HashMap<Node, Model>();
+			initialize();
+			// Register every DOM to OdfPackage,
+			// so a package close might save this DOM (similar as
+			// OdfDocumentPackage)
+			addDomToCache(mPackage, packagePath);
+		} else {
+			throw new IllegalArgumentException("Arguments are not allowed to be NULL for OdfFileDom constructor!");
+		}
+	}
+
+	/** 
+	 *Adds the document to the pool of open documents of the package.
+	 *A document of a certain path is opened only once to avoid data duplication.
+	 */
+	private void addDomToCache(OdfPackage pkg, String internalPath) {
+		pkg.cacheDom(this, internalPath);
+	}
+
+	public static OdfFileDom newFileDom(OdfPackageDocument packageDocument, String packagePath) {
+		OdfFileDom newFileDom = null;
+		// before creating a new dom, make sure that there no DOM opened for this file already
+		Document existingDom = packageDocument.getPackage().getCachedDom(packagePath);
+		if (existingDom == null) {
+			// ToDo: bug 264 - register OdfFileDom to this class
+			if (packagePath.equals("content.xml") || packagePath.endsWith("/content.xml")) {
+				newFileDom = new OdfContentDom((OdfSchemaDocument) packageDocument, packagePath);
+			} else if (packagePath.equals("styles.xml") || packagePath.endsWith("/styles.xml")) {
+				newFileDom = new OdfStylesDom((OdfSchemaDocument) packageDocument, packagePath);
+			} else if (packagePath.equals("meta.xml") || packagePath.endsWith("/meta.xml")) {
+				newFileDom = new OdfMetaDom((OdfSchemaDocument) packageDocument, packagePath);
+			} else if (packagePath.equals("settings.xml") || packagePath.endsWith("/settings.xml")) {
+				newFileDom = new OdfSettingsDom((OdfSchemaDocument) packageDocument, packagePath);
+			} else {
+				newFileDom = new OdfFileDom(packageDocument, packagePath);
+			}
+		} else {
+			if (existingDom instanceof OdfFileDom) {
+				newFileDom = (OdfFileDom) existingDom;
+//ToDO: Issue 264 - Otherwise if NOT an OdfFileDom serialize old DOM AND CREATE A NEW ONE?!
+// Or shall we always reference to the dom, than we can not inherit from Document? Pro/Con?s
+//			}else{
+//				// Create an OdfFileDOM from an existing DOM
+//				newFileDom =
+			}
+
+		}
+		return newFileDom;
+	}
+
+	protected void initialize() {
+		InputStream fileStream = null;
+		try {
+			fileStream = mPackage.getInputStream(mPackagePath);
+			if (fileStream != null) {
+				XMLReader xmlReader = mPackage.getXMLReader();
+				OdfFileSaxHandler odf = new OdfFileSaxHandler(this);
+				String baseUri = Util.getRDFBaseUri(mPackage.getBaseURI(),mPackagePath);
+				sink = new JenaSink(this);
+				odf.setSink(sink);
+				SAXRDFaParser rdfa = SAXRDFaParser.createInstance(sink);
+				rdfa.setBase(baseUri);
+				// the file is parsed by ODF ContentHandler, and then RDFa ContentHandler
+				MultiContentHandler multi = new MultiContentHandler(odf, rdfa);
+				xmlReader.setContentHandler(multi);
+				InputSource xmlSource = new InputSource(fileStream);
+				xmlReader.parse(xmlSource);
+			}
+		} catch (Exception ex) {
+			Logger.getLogger(OdfPackageDocument.class.getName()).log(Level.SEVERE, null, ex);
+		} finally {
+			try {
+				if (fileStream != null) {
+					fileStream.close();
+				}
+			} catch (IOException ex) {
+				Logger.getLogger(OdfPackageDocument.class.getName()).log(Level.SEVERE, null, ex);
+			}
+		}
+	}
+
+	/**
+	 * Retrieves the <code>OdfPackageDocument</code> of the XML file.
+	 * A package document is usually represented as a directory with a mediatype.
+	 *
+	 * @return The document holding the XML file.
+	 *
+	 */
+	public OdfPackageDocument getDocument() {
+		return mPackageDocument;
+	}
+
+	/**
+	 * Retrieves the <code>String</code> of Package Path
+	 * 
+	 * @return The path of the XML file relative to the package root
+	 */
+	public String getPackagePath() {
+		return mPackagePath;
+	}
+
+	/**
+	 * Retrieves the ODF root element.
+	 *
+	 * @return The <code>OdfElement</code> being the root of the document.
+	 */
+	public OdfElement getRootElement() {
+		return (OdfElement) getDocumentElement();
+	}
+
+	/**
+	 * Create ODF element with namespace uri and qname
+	 *
+	 * @param name The element name
+	 *
+	 */
+	@Override
+	public OdfElement createElement(String name) throws DOMException {
+		return createElementNS(OdfName.newName(name));
+	}
+
+	/**
+	 * Create ODF element with namespace uri and qname
+	 *
+	 * @param nsuri The namespace uri
+	 * @param qname The element qname
+	 *
+	 */
+	@Override
+	public OdfElement createElementNS(String nsuri, String qname) throws DOMException {
+		return createElementNS(OdfName.newName(nsuri, qname));
+	}
+
+	/**
+	 * Create ODF element with ODF name
+	 * @param name The <code>OdfName</code>
+	 * @return The <code>OdfElement</code>
+	 * @throws DOMException
+	 */
+	public OdfElement createElementNS(OdfName name) throws DOMException {
+		return OdfXMLFactory.newOdfElement(this, name);
+	}
+
+	/**
+	 * Create the ODF attribute with its name
+	 *
+	 * @param name  the attribute qname
+	 * @return The <code>OdfAttribute</code>
+	 * @throws  DOMException
+	 */
+	@Override
+	public OdfAttribute createAttribute(String name) throws DOMException {
+		return createAttributeNS(OdfName.newName(name));
+	}
+
+	/**
+	 * Create the ODF attribute with namespace uri and qname
+	 * 
+	 * @param nsuri  The namespace uri
+	 * @param qname  the attribute qname
+	 * @return The <code>OdfAttribute</code>
+	 * @throws  DOMException
+	 */
+	@Override
+	public OdfAttribute createAttributeNS(String nsuri, String qname) throws DOMException {
+		return createAttributeNS(OdfName.newName(nsuri, qname));
+	}
+
+	/**
+	 * Create the ODF attribute with ODF name
+	 * @param name The <code>OdfName</code>
+	 * @return  The <code>OdfAttribute</code>
+	 * @throws DOMException
+	 */
+	public OdfAttribute createAttributeNS(OdfName name) throws DOMException {
+		return OdfXMLFactory.newOdfAttribute(this, name);
+	}
+
+	@SuppressWarnings("unchecked")
+	public <T extends OdfElement> T newOdfElement(Class<T> clazz) {
+		//return (T) OdfXMLFactory.getNodeFromClass(this, clazz);
+		try {
+			Field fname = clazz.getField("ELEMENT_NAME");
+			OdfName name = (OdfName) fname.get(null);
+			return (T) createElementNS(name);
+		} catch (Exception ex) {
+			if (ex instanceof RuntimeException) {
+				throw (RuntimeException) ex;
+			}
+			return null;
+		}
+	}
+
+	@Override
+	public String toString() {
+		return ((OdfElement) this.getDocumentElement()).toString();
+	}
+
+	// JDK Namespace handling
+	/**
+	 * Create an XPath instance to select one or more nodes from an ODF document.
+	 * Therefore the namespace context is set to the OdfNamespace
+	 * @return an XPath instance with namespace context set to include the standard
+	 * ODFDOM prefixes.
+	 */
+	public XPath getXPath() {
+		if (mXPath == null) {
+			mXPath = XPathFactory.newInstance().newXPath();
+		}
+		return mXPath;
+	}
+
+	/**
+	 * <p>Get Namespace URI bound to a prefix in the current scope (the XML file).</p>
+	 *
+	 * <p>When requesting a Namespace URI by prefix, the following
+	 * table describes the returned Namespace URI value for all
+	 * possible prefix values:</p>
+	 *
+	 * <table border="2" rules="all" cellpadding="4">
+	 *   <thead>
+	 *     <tr>
+	 *       <td align="center" colspan="2">
+	 *         <code>getNamespaceURI(prefix)</code>
+	 *         return value for specified prefixes
+	 *       </td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td>prefix parameter</td>
+	 *       <td>Namespace URI return value</td>
+	 *     </tr>
+	 *   </thead>
+	 *   <tbody>
+	 *     <tr>
+	 *       <td><code>DEFAULT_NS_PREFIX</code> ("")</td>
+	 *       <td>default Namespace URI in the current scope or
+	 *         <code>{@link
+	 *         javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")}
+	 *         </code>
+	 *         when there is no default Namespace URI in the current scope</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td>bound prefix</td>
+	 *       <td>Namespace URI bound to prefix in current scope</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td>unbound prefix</td>
+	 *       <td>
+	 *         <code>{@link
+	 *         javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")}
+	 *         </code>
+	 *       </td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
+	 *       <td><code>XMLConstants.XML_NS_URI</code>
+	 *           ("http://www.w3.org/XML/1998/namespace")</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
+	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
+	 *         ("http://www.w3.org/2000/xmlns/")</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>null</code></td>
+	 *       <td><code>IllegalArgumentException</code> is thrown</td>
+	 *     </tr>
+	 *    </tbody>
+	 * </table>
+	 *
+	 * @param prefix prefix to look up
+	 *
+	 * @return Namespace URI bound to prefix in the current scope
+	 *
+	 * @throws IllegalArgumentException When <code>prefix</code> is
+	 *   <code>null</code>
+	 */
+	public String getNamespaceURI(String prefix) {
+		String nsURI = null;
+		nsURI = mUriByPrefix.get(prefix);
+		if (nsURI == null) {
+			// look in Duplicate URI prefixes
+			Set<String> urisWithDuplicatePrefixes = this.mDuplicatePrefixesByUri.keySet();
+			for (String aURI : urisWithDuplicatePrefixes) {
+				Set<String> prefixes = this.mDuplicatePrefixesByUri.get(aURI);
+				// check if requested prefix exists in hashset
+				if (prefixes.contains(prefix)) {
+					nsURI = aURI;
+					break;
+				}
+			}
+		}
+		// there is a possibility it still may be null - so we check
+		if (nsURI == null) {
+			nsURI = XMLConstants.NULL_NS_URI;
+		}
+		return nsURI;
+	}
+
+	/**
+	 * <p>Get prefix bound to Namespace URI in the current scope (the XML file).</p>
+	 * <p>Multiple prefixes bound to Namespace URI will be normalized to the first prefix defined.</p>
+	 *
+	 * <p>When requesting a prefix by Namespace URI, the following
+	 * table describes the returned prefix value for all Namespace URI
+	 * values:</p>
+	 *
+	 * <table border="2" rules="all" cellpadding="4">
+	 *   <thead>
+	 *     <tr>
+	 *       <th align="center" colspan="2">
+	 *         <code>getPrefix(namespaceURI)</code> return value for
+	 *         specified Namespace URIs
+	 *       </th>
+	 *     </tr>
+	 *     <tr>
+	 *       <th>Namespace URI parameter</th>
+	 *       <th>prefix value returned</th>
+	 *     </tr>
+	 *   </thead>
+	 *   <tbody>
+	 *     <tr>
+	 *       <td>&lt;default Namespace URI&gt;</td>
+	 *       <td><code>XMLConstants.DEFAULT_NS_PREFIX</code> ("")
+	 *       </td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td>bound Namespace URI</td>
+	 *       <td>prefix bound to Namespace URI in the current scope,
+	 *           if multiple prefixes are bound to the Namespace URI in
+	 *           the current scope, a single arbitrary prefix, whose
+	 *           choice is implementation dependent, is returned</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td>unbound Namespace URI</td>
+	 *       <td><code>null</code></td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>XMLConstants.XML_NS_URI</code>
+	 *           ("http://www.w3.org/XML/1998/namespace")</td>
+	 *       <td><code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
+	 *           ("http://www.w3.org/2000/xmlns/")</td>
+	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>null</code></td>
+	 *       <td><code>IllegalArgumentException</code> is thrown</td>
+	 *     </tr>
+	 *   </tbody>
+	 * </table>
+	 *
+	 * @param namespaceURI URI of Namespace to lookup
+	 *
+	 * @return prefix bound to Namespace URI in current context
+	 *
+	 * @throws IllegalArgumentException When <code>namespaceURI</code> is
+	 *   <code>null</code>
+	 */
+	public String getPrefix(String namespaceURI) {
+		return mPrefixByUri.get(namespaceURI);
+	}
+
+	/**
+	 * <p>Get all prefixes bound to a Namespace URI in the current
+	 * scope. (the XML file)</p>
+	 * <p>NOTE: Multiple prefixes bound to a similar Namespace URI will be normalized to the first prefix defined.
+	 * Still the namespace attributes exist in the XML as inner value prefixes might be used.</p>
+	 *
+	 * <p><strong>The <code>Iterator</code> is
+	 * <em>not</em> modifiable.  e.g. the
+	 * <code>remove()</code> method will throw
+	 * <code>UnsupportedOperationException</code>.</strong></p>
+	 *
+	 * <p>When requesting prefixes by Namespace URI, the following
+	 * table describes the returned prefixes value for all Namespace
+	 * URI values:</p>
+	 *
+	 * <table border="2" rules="all" cellpadding="4">
+	 *   <thead>
+	 *     <tr>
+	 *       <th align="center" colspan="2"><code>
+	 *         getPrefixes(namespaceURI)</code> return value for
+	 *         specified Namespace URIs</th>
+	 *     </tr>
+	 *     <tr>
+	 *       <th>Namespace URI parameter</th>
+	 *       <th>prefixes value returned</th>
+	 *     </tr>
+	 *   </thead>
+	 *   <tbody>
+	 *     <tr>
+	 *       <td>bound Namespace URI,
+	 *         including the &lt;default Namespace URI&gt;</td>
+	 *       <td>
+	 *         <code>Iterator</code> over prefixes bound to Namespace URI in
+	 *         the current scope in an arbitrary,
+	 *         <strong>implementation dependent</strong>,
+	 *         order
+	 *       </td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td>unbound Namespace URI</td>
+	 *       <td>empty <code>Iterator</code></td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>XMLConstants.XML_NS_URI</code>
+	 *           ("http://www.w3.org/XML/1998/namespace")</td>
+	 *       <td><code>Iterator</code> with one element set to
+	 *         <code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
+	 *           ("http://www.w3.org/2000/xmlns/")</td>
+	 *       <td><code>Iterator</code> with one element set to
+	 *         <code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
+	 *     </tr>
+	 *     <tr>
+	 *       <td><code>null</code></td>
+	 *       <td><code>IllegalArgumentException</code> is thrown</td>
+	 *     </tr>
+	 *   </tbody>
+	 * </table>
+	 *
+	 * @param namespaceURI URI of Namespace to lookup
+	 *
+	 * @return <code>Iterator</code> for all prefixes bound to the
+	 *   Namespace URI in the current scope
+	 *
+	 * @throws IllegalArgumentException When <code>namespaceURI</code> is
+	 *   <code>null</code>
+	 */
+	public Iterator<String> getPrefixes(String namespaceURI) {
+		Set<String> prefixes = mDuplicatePrefixesByUri.get(namespaceURI);
+		if (prefixes == null) {
+			prefixes = new HashSet<String>();
+		}
+		String givenPrefix = mPrefixByUri.get(namespaceURI);
+		if(givenPrefix != null){
+			prefixes.add(givenPrefix);
+		}
+		return prefixes.iterator();
+	}
+
+	/** @return a map of namespaces, where the URI is the key and the prefix is the value */
+	Map<String, String> getMapNamespacePrefixByUri() {
+		return mPrefixByUri;
+	}
+
+	/** Adds a new Namespace to the DOM. Making the prefix usable with JDK <code>XPath</code>.
+	 * All namespace attributes will be written to the root element during later serialization of the DOM by the <code>OdfPackage</code>.
+	 * @param prefix of the namespace to be set to this DOM
+	 * @param uri of the namespace to be set to this DOM
+	 * @return the namespace that was set. If an URI was registered before to the DOM, the previous prefix will be taken.
+	 * In case of a given prefix that was already registered, but related to a new URI, the prefix will be adapted.
+	 * The new prefix receives the suffix '__' plus integer, e.g. "__1" for the first duplicate and "__2" for the second.
+	 */
+	public OdfNamespace setNamespace(String prefix, String uri) {
+		//collision detection, when a new prefix/URI pair exists
+		OdfNamespace newNamespace = null;
+		//Scenario a) the URI already registered, use existing prefix
+		// but save all others for the getPrefixes function. There might be still some
+		// in attribute values using prefixes, that were not exchanged.
+		String existingPrefix = mPrefixByUri.get(uri);
+		if (existingPrefix != null) {
+			//Use the existing prefix of the used URL, neglect the given
+			newNamespace = OdfNamespace.newNamespace(existingPrefix, uri);
+
+			//Add the new prefix to the duplicate prefix map for getPrefixes(String uri)
+			Set<String> prefixes = mDuplicatePrefixesByUri.get(uri);
+			if (prefixes == null) {
+				prefixes = new HashSet<String>();
+				mDuplicatePrefixesByUri.put(uri, prefixes);
+			}
+			prefixes.add(prefix);
+		} else {
+			//Scenario b) the prefix already exists and the URI does not exist
+			String existingURI = mUriByPrefix.get(prefix);
+			if (existingURI != null && !existingURI.equals(uri)) {
+				//Change the prefix appending "__" plus counter.
+				int i = 1;
+				do {
+					int suffixStart = prefix.lastIndexOf("__");
+					if (suffixStart != -1) {
+						prefix = prefix.substring(0, suffixStart);
+					}
+					//users have to take care for their attribute values using namespace prefixes.
+					prefix = prefix + "__" + i;
+					i++;
+					existingURI = mUriByPrefix.get(prefix);
+				} while (existingURI != null && !existingURI.equals(uri));
+			}
+			newNamespace = OdfNamespace.newNamespace(prefix, uri);
+			mPrefixByUri.put(uri, prefix);
+			mUriByPrefix.put(prefix, uri);
+		}
+		// if the file Dom is already associated to parsed XML add the new namespace to the root element
+		Element root = getRootElement();
+		if (root != null) {
+			root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, uri);
+		}
+		return newNamespace;
+	}
+
+	/** Adds a new Namespace to the DOM. Making the prefix usable with JDK <code>XPath</code>.
+	 * All namespace attributes will be written to the root element during later serialization of the DOM by the <code>OdfPackage</code>.
+	 * @param name the namespace to be set
+	 * @return the namespace that was set. If an URI was registered before to the DOM, the previous prefix will be taken.
+	 * In case of a given prefix that was already registered, but related to a new URI, the prefix will be adapted.
+	 * The new prefix receives the suffix '__' plus integer, e.g. "__1" for the first duplicate and "__2" for the second.
+	 */
+	public OdfNamespace setNamespace(NamespaceName name) {
+		return setNamespace(name.getPrefix(), name.getUri());
+	}
+
+
+	/**
+	* Get in-content metadata cache model
+	*
+	* @return in-content metadata cache model
+	*/
+	public Map<Node, Model> getInContentMetadataCache() {
+		return this.inCententMetadataCache;
+	}
+
+	/**
+	* Update the in content metadata of the node. It should be called whenever
+	* the xhtml:xxx attrbutes values of the node are changed.
+	* @param the node, whose in content metadata will be updated
+	*/
+	public void updateInContentMetadataCache(Node node) {
+		this.getInContentMetadataCache().remove(node);
+		DOMRDFaParser parser = DOMRDFaParser.createInstance(this.sink);
+		String baseUri = Util.getRDFBaseUri(mPackage.getBaseURI(), mPackagePath);
+		parser.setBase(baseUri);
+		parser.parse(node);
+	}
+
+	/**
+	* @return the RDF metadata of all the bookmarks within the dom
+	*/
+	public Model getBookmarkRDFMetadata() {
+		return BookmarkRDFMetadataExtractor.newBookmarkTextExtractor().getBookmarkRDFMetadata(this);
+	}
+
+	/**
+	* The end users needn't to care of this method, which is used by
+	* BookmarkRDFMetadataExtractor
+	* @return the JenaSink
+	*/
+	public JenaSink getSink() {
+		return sink;
+	}
+}



Mime
View raw message