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 [8/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
Added: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/URIExtractorImpl.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/URIExtractorImpl.java?rev=1418326&view=auto
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/URIExtractorImpl.java (added)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/URIExtractorImpl.java Fri Dec  7 14:28:07 2012
@@ -0,0 +1,217 @@
+/************************************************************************
+ *
+ * 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.rdfa;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.StartElement;
+
+import net.rootdev.javardfa.Constants;
+import net.rootdev.javardfa.Resolver;
+import net.rootdev.javardfa.Setting;
+
+import org.apache.commons.validator.routines.UrlValidator;
+
+/**
+ * URIExtractorImpl modified from net.rootdev.javardfa.uri.URIExtractor10
+ */
+class URIExtractorImpl implements URIExtractor {
+	private Set<Setting> settings;
+	private final Resolver resolver;
+	private Map<String, String> xmlnsMap = Collections.EMPTY_MAP;
+	private boolean isForSAX;
+	private UrlValidator urlValidator;
+
+	public URIExtractorImpl(Resolver resolver, boolean isForSAX) {
+		this.resolver = resolver;
+		this.isForSAX = isForSAX;
+		this.urlValidator = new UrlValidator();
+	}
+
+	public void setForSAX(boolean isForSAX) {
+		this.isForSAX = isForSAX;
+	}
+
+	public void setSettings(Set<Setting> settings) {
+		this.settings = settings;
+	}
+
+	public String getURI(StartElement element, Attribute attr,
+			EvalContext context) {
+		QName attrName = attr.getName();
+		if (Util.qNameEquals(attrName, Constants.about)) // Safe CURIE or URI
+		{
+			return expandSafeCURIE(element, attr.getValue(), context);
+		}
+		if (Util.qNameEquals(attrName, Constants.datatype)) // A CURIE
+		{
+			return expandCURIE(element, attr.getValue(), context);
+		}
+		throw new RuntimeException("Unexpected attribute: " + attr);
+	}
+
+	private boolean isValidURI(String uri){
+		return this.urlValidator.isValid(uri);
+	}
+	
+	public List<String> getURIs(StartElement element, Attribute attr,
+			EvalContext context) {
+			
+		List<String> uris = new LinkedList<String>();	
+		
+		String[] curies = attr.getValue().split("\\s+");
+		boolean permitReserved = Util
+				.qNameEquals(Constants.rel, attr.getName())
+				|| Util.qNameEquals(Constants.rev, attr.getName());
+		for (String curie : curies) {
+			if (Constants.SpecialRels.contains(curie.toLowerCase())) {
+				if (permitReserved)
+					uris.add("http://www.w3.org/1999/xhtml/vocab#"
+							+ curie.toLowerCase());
+			} else {
+				String uri = expandCURIE(element, curie, context);
+				if (uri != null) {
+					uris.add(uri);
+				}
+			}
+		}
+		return uris;
+	}
+
+	public String expandCURIE(StartElement element, String value,
+			EvalContext context) {
+		
+		if (value.startsWith("_:")) {
+			if (!settings.contains(Setting.ManualNamespaces))
+				return value;
+			if (element.getNamespaceURI("_") == null)
+				return value;
+		}
+		if (settings.contains(Setting.FormMode) && // variable
+				value.startsWith("?")) {
+			return value;
+		}
+		int offset = value.indexOf(":") + 1;
+		if (offset == 0) {
+			return null;
+		}
+		String prefix = value.substring(0, offset - 1);
+		
+
+		// Apparently these are not allowed to expand
+		if ("xml".equals(prefix) || "xmlns".equals(prefix))
+			return null;
+
+		String namespaceURI = null;
+		if (prefix.length() == 0) {
+			namespaceURI = "http://www.w3.org/1999/xhtml/vocab#";
+		} else {
+			namespaceURI = element.getNamespaceURI(prefix);
+			if (isForSAX) {
+				if (namespaceURI != null) {
+					if (xmlnsMap == Collections.EMPTY_MAP)
+						xmlnsMap = new HashMap<String, String>();
+					xmlnsMap.put(prefix, namespaceURI);
+				}
+			} else {
+				if (namespaceURI == null) {
+					namespaceURI = xmlnsMap.get(prefix);
+				}
+			}
+		}
+		if (namespaceURI == null) {
+			return null;
+			// throw new RuntimeException("Unknown prefix: " + prefix);
+		}
+
+		return namespaceURI + value.substring(offset);
+	}
+
+	public String expandSafeCURIE(StartElement element, String value,
+			EvalContext context) {
+		if (value.startsWith("[") && value.endsWith("]")) {
+			return expandCURIE(element, value.substring(1, value.length() - 1),
+					context);
+		} else {
+			if (value.length() == 0) {
+				return context.getBase();
+			}
+
+			if (settings.contains(Setting.FormMode) && value.startsWith("?")) {
+				return value;
+			}
+
+			return resolver.resolve(context.getBase(), value);
+		}
+	}
+
+	public String resolveURI(String uri, EvalContext context) {
+		return resolver.resolve(context.getBase(), uri);
+	}
+
+	public String getNamespaceURI(String prefix) {
+		if (xmlnsMap.containsKey(prefix)) {
+			return xmlnsMap.get(prefix);
+		} else {
+			return null;
+		}
+	}
+	
+	public void setNamespaceURI(String prefix, String namespaceURI){
+		if (xmlnsMap == Collections.EMPTY_MAP)
+			xmlnsMap = new HashMap<String, String>();
+		xmlnsMap.put(prefix, namespaceURI);
+	}
+
+}
+
+/*
+ * (c) Copyright 2009 University of Bristol All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The name of the author may not
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */

Added: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/Util.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/Util.java?rev=1418326&view=auto
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/Util.java (added)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/Util.java Fri Dec  7 14:28:07 2012
@@ -0,0 +1,145 @@
+/************************************************************************
+ *
+ * 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.rdfa;
+
+import java.net.URI;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import org.apache.clerezza.utils.UriException;
+import org.apache.clerezza.utils.UriUtil;
+
+public class Util {
+	
+	private static final String SLASH = "/";
+	
+	/**
+	 * Test whether two QNames are equal to each other. This is a bug fix for
+	 * java-rdfa library. "xhtml:about" and "about" should be considered as
+	 * RDFa, while java-rdfa recognizes only the later one.
+	 * 
+	 * @param at
+	 *            , the QName of an Attribute
+	 * @param name
+	 *            , the QName to be compared
+	 * @return
+	 */
+	public static boolean qNameEquals(QName at, QName name) {
+		if (!name.getNamespaceURI().equals(XMLConstants.DEFAULT_NS_PREFIX)) {
+			if (at.equals(name)) {
+				return true;
+			}
+		} else if (at.getLocalPart().equals(name.getLocalPart())) {
+			return true;
+		}
+		return false;
+	}
+	
+	/**
+	 * Get the RDF base uri of the given internalPath. Note that there would be
+	 * a SLASH at the end of the RDF base uri
+	 * 
+	 * @param pkgBaseUri
+	 *            , the base uri of the package
+	 * @param internalPath
+	 *            , the internalPath relative to the root document
+	 * @return
+	 */
+	public static String getRDFBaseUri(String pkgBaseUri, String internalPath) {
+		String subDirectory = internalPath.lastIndexOf(SLASH) == -1 ? "" : SLASH + internalPath.substring(0, internalPath.lastIndexOf(SLASH));
+		String baseUri = pkgBaseUri + subDirectory + SLASH;
+		return baseUri;
+	}
+	
+	/**
+	 * To test whether the subPath is a sut path of superPath
+	 * 
+	 * @param subPath
+	 *            , an internal path in the ODF package
+	 * @param superPath
+	 *            , an internal path in the ODF package
+	 * @return
+	 */
+	public static boolean isSubPathOf(String subPath, String superPath) {
+		if (superPath == null || subPath == null) {
+			return false;
+		}
+		return SLASH.equals(superPath) || (subPath.length() > superPath.length() && subPath.startsWith(superPath));
+	}
+	
+	/**
+	 * To fix the 3 slashes bug for File URI: For example:
+	 * file:/C:/work/test.txt -> file:///C:/work/test.txt
+	 * 
+	 * @param u - the File URI
+	 * @return the String of the URI
+	 */
+	public static String toExternalForm(URI u) {
+		StringBuffer sb = new StringBuffer();
+		if (u.getScheme() != null) {
+			sb.append(u.getScheme());
+			sb.append(':');
+		}
+		if (u.isOpaque()) {
+			sb.append(u.getSchemeSpecificPart());
+		} else {
+			if (u.getHost() != null) {
+				sb.append("//");
+				if (u.getUserInfo() != null) {
+					sb.append(u.getUserInfo());
+					sb.append('@');
+				}
+				boolean needBrackets = ((u.getHost().indexOf(':') >= 0) && !u.getHost().startsWith("[") && !u.getHost().endsWith("]"));
+				if (needBrackets)
+					sb.append('[');
+				sb.append(u.getHost());
+				if (needBrackets)
+					sb.append(']');
+				if (u.getPort() != -1) {
+					sb.append(':');
+					sb.append(u.getPort());
+				}
+			} else if (u.getAuthority() != null) {
+				sb.append("//");
+				sb.append(u.getAuthority());
+			} else {
+				sb.append("//");
+			}
+			if (u.getPath() != null)
+				sb.append(u.getPath());
+			if (u.getQuery() != null) {
+				sb.append('?');
+				sb.append(u.getQuery());
+			}
+		}
+		if (u.getFragment() != null) {
+			sb.append('#');
+			sb.append(u.getFragment());
+		}
+		String ret = sb.toString();
+		try {
+			ret = UriUtil.encodePath(ret);
+		} catch (UriException e) {
+		}
+		return ret;
+	}
+}

Added: incubator/odf/trunk/odfdom/src/main/resources/grddl/odf2rdf.xsl
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/resources/grddl/odf2rdf.xsl?rev=1418326&view=auto
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/resources/grddl/odf2rdf.xsl (added)
+++ incubator/odf/trunk/odfdom/src/main/resources/grddl/odf2rdf.xsl Fri Dec  7 14:28:07 2012
@@ -0,0 +1,304 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+
+  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.
+
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:
 text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:pkg="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" xmlns:odf="http://docs.oasis-open.org/ns/office/1.2/meta/odf#">
+	<output method="xml" encoding="UTF-8" media-type="application/rdf+xml" indent="yes" omit-xml-declaration="yes" />
+
+  <!-- The base URL of the OpenDocument's three XML files (directory within package) -->
+	<param name="sourceBaseURL" select="'.'" />
+	<param name="FILE_URL">
+		<choose>
+			<when test="substring($sourceBaseURL, string-length($sourceBaseURL), 1) = '/'">
+				<value-of select="concat($sourceBaseURL , substring-after(name(/*), 'office:document-'), '.xml')"/>
+			</when>
+			<otherwise>
+				<!-- add '/' to the end of the document URL -->
+				<value-of select="concat($sourceBaseURL ,'/', substring-after(name(/*), 'office:document-'), '.xml')"/>
+			</otherwise>
+		</choose>
+	</param>
+
+
+	<!-- Version 1.2.0 by Svante.Schubert AT gmail.com
+		 First two digits mark the supported ODF version  -->
+	<variable name="stylesheetVersion" select="'1.2.0'"/>
+
+	<template match="/">
+		<element name="rdf:RDF">
+			<attribute name="xml:base">
+				<value-of select="$sourceBaseURL"/>
+			</attribute>
+			<element name="pkg:Document">
+				<attribute name="rdf:about">
+					<value-of select="$sourceBaseURL"/>
+				</attribute>
+				<call-template name="setMimeType"/>
+				<apply-templates select="*/@office:version" mode="root"/>
+				<apply-templates select="/office:document-meta/office:meta/*" mode="meta-file"/>
+			</element>
+			<apply-templates mode="content-styles-files"/>
+		</element>
+	</template>
+
+	<template match="@office:version" mode="root">
+		<attribute name="office:version">
+			<value-of select="."/>
+		</attribute>
+	</template>
+
+	<template name="setMimeType">
+		<!-- Use new ODF 1.2 RDF mimeType property -->
+		<if test="@office:mimetype or name(/*/office:body/*)">
+			<attribute name="pkg:mimeType">
+				<choose>
+					<when test="@office:mimetype">
+						<value-of select="@office:mimetype"/>
+					</when>
+					<otherwise>
+						<value-of select="concat('vnd.oasis.opendocument.', substring-after(name(/*/office:body/*), 'office:'))"/>
+					</otherwise>
+				</choose>
+			</attribute>
+		</if>
+	</template>
+
+	 <!-- OpenDocument meta.xml handling -->
+	<template match="*" mode="meta-file">
+		<element name="{name()}">
+			<value-of select="text()"/>
+		</element>
+	</template>
+
+	<template match="*[* or @*]" mode="meta-file">
+		<element name="{name()}">
+			<apply-templates select="@* | text()" mode="meta-file-child"/>
+		</element>
+	</template>
+
+	<template match="@*" mode="meta-file-child">
+		<attribute name="{name()}">
+			<value-of select="."/>
+		</attribute>
+	</template>
+
+	<template match="text()" mode="meta-file-child">
+		<attribute name="meta:value">
+			<value-of select="."/>
+		</attribute>
+	</template>
+
+	<!-- OpenDocument content.xml handling -->
+	<template match="/office:document-content/office:body/*" mode="content-styles-files">
+		<apply-templates mode="content-styles-files" />
+	</template>
+
+	<!-- OpenDocument styles.xml handling (header&footer)-->
+	<template match="/office:document-styles/office:master-styles/style:master-page/*" mode="content-styles-files">
+		<apply-templates mode="content-styles-files" />
+	</template>
+
+	<!-- ignore RDFa of deleted content -->
+	<template match="text:tracked-changes" mode="content-styles-files" />
+
+	<!-- RDFa -->
+	<template match="*" mode="content-styles-files">
+		<apply-templates mode="content-styles-files" />
+	</template>
+
+	<template match="text()" mode="content-styles-files"/>
+
+	<template match="*[@xhtml:about]" mode="content-styles-files">
+		<choose>
+			<when test="name() = 'text:bookmark-start'">
+				<call-template name="resolve-RDF-subject">
+					<with-param name="text">
+						<apply-templates select="following::node()[1]" mode="rdfa-bookmark-literal">
+							<with-param name="name" select="@text:name"/>
+						</apply-templates>
+					</with-param>
+				</call-template>
+			</when>
+			<otherwise>
+				<call-template name="resolve-RDF-subject">
+					<with-param name="text">
+						<apply-templates mode="rdfa-literal"/>
+					</with-param>
+				</call-template>
+			</otherwise>
+		</choose>
+	</template>
+
+	<template match="*" mode="rdfa-literal">
+		<apply-templates mode="rdfa-literal"/>
+	</template>
+
+	<template match="text()" mode="rdfa-literal">
+		<value-of select="."/>
+	</template>
+
+	<template match="*" mode="rdfa-bookmark-literal">
+		<param name="name"/>
+
+		<choose>
+			<when test="descendant::node()[1]">
+				<apply-templates select="descendant::node()[1]" mode="rdfa-bookmark-literal">
+					<with-param name="name" select="$name"/>
+				</apply-templates>
+			</when>
+			<otherwise>
+				<apply-templates select="following::node()[1]" mode="rdfa-bookmark-literal">
+					<with-param name="name" select="$name"/>
+				</apply-templates>
+			</otherwise>
+		</choose>
+	</template>
+
+	<template match="text()" mode="rdfa-bookmark-literal">
+		<param name="name"/>
+
+		<!-- heuristic instead of a check if parent may contain text -->
+		<if test="normalize-space(.) != ''">
+			<value-of select="."/>
+		</if>
+		<apply-templates select="following::node()[1]" mode="rdfa-bookmark-literal">
+			<with-param name="name" select="$name"/>
+		</apply-templates>
+	</template>
+
+	<template match="text:bookmark-end" mode="rdfa-bookmark-literal">
+		<param name="name"/>
+
+		<!-- end condition of the recursion, if the bookmark-end  -->
+		<if test="$name != @text:name">
+			<apply-templates select="following::node()[1]" mode="rdfa-bookmark-literal">
+				<with-param name="name" select="$name"/>
+			</apply-templates>
+		</if>
+	</template>
+
+	<template name="resolve-RDF-subject">
+		<param name="text" />
+
+		<!-- create RDF subject -->
+		<element name="rdf:Description">
+			<attribute name="rdf:about">
+				<call-template name="resolve-URI-or-Safe-CURIE">
+					<with-param name="URIorSafeCURIE" select="@xhtml:about"/>
+				</call-template>
+			</attribute>
+			<if test="@xhtml:content">
+				<attribute name="rdfs:label" namespace="http://www.w3.org/2000/01/rdf-schema#">
+					<value-of select="$text"/>
+				</attribute>
+			</if>
+			<call-template name="resolve-RDF-property">
+				<with-param name="CURIEs" select="@xhtml:property"/>
+				<with-param name="text" select="$text"/>
+			</call-template>
+		</element>
+	</template>
+
+	<template name="resolve-RDF-property">
+		<param name="CURIEs"/>
+		<param name="text"/>
+
+		<variable name="multiplePredicates" select="contains($CURIEs, ' ')"/>
+		<variable name="CURIE">
+			<choose>
+				<when test="$multiplePredicates">
+					<value-of select="normalize-space(substring-before($CURIEs, ' '))"/>
+				</when>
+				<otherwise>
+					<value-of select="$CURIEs"/>
+				</otherwise>
+			</choose>
+		</variable>
+		<variable name="ns">
+			<call-template name="get-namespace">
+				<with-param name="CURIE" select="normalize-space(substring-before($CURIEs, ' '))"/>
+			</call-template>
+		</variable>
+		<!-- RDF property -->
+		<element name="{$CURIE}" namespace="{$ns}">
+			<apply-templates select="@xhtml:datatype"/>
+			<choose>
+				<when test="@xhtml:content">
+					<value-of select="@xhtml:content"/>
+				</when>
+				<otherwise>
+					<value-of select="$text"/>
+				</otherwise>
+			</choose>
+		</element>
+
+		<if test="$multiplePredicates">
+			<call-template name="resolve-RDF-property">
+				<with-param name="CURIEs" select="normalize-space(substring-after($CURIEs, $CURIE))"/>
+				<with-param name="text" select="$text"/>
+			</call-template>
+		</if>
+	</template>
+
+	<template match="@xhtml:datatype">
+		<variable name="ns">
+			<call-template name="get-namespace">
+				<with-param name="CURIE" select="."/>
+			</call-template>
+		</variable>
+
+		<attribute name="rdf:datatype">
+			<value-of select="concat($ns, substring-after(., substring-before(.,':')))"/>
+		</attribute>
+	</template>
+
+	<template name="get-namespace">
+		<param name="CURIE"/>
+
+		<variable name="prefix" select="substring-before($CURIE,':')"/>
+		<choose>
+			<when test="string-length($prefix)&gt;0">
+				<value-of select="ancestor-or-self::*/namespace::*[name()=$prefix][1]"/>
+			</when>
+			<otherwise> <!-- default namespace -->
+				<value-of select="ancestor-or-self::*/namespace::*[name()=''][1]"/>
+			</otherwise>
+		</choose>
+	</template>
+
+	<template name="resolve-URI-or-Safe-CURIE">
+		<param name="URIorSafeCURIE"/>
+		<choose>
+			<when test="starts-with($URIorSafeCURIE,'[')"> <!-- a SafeCURIE -->
+				<value-of select="substring-after(substring-before($URIorSafeCURIE,']'),'[')"/>
+			</when>
+			<when test="starts-with($URIorSafeCURIE,'#')"> <!-- an ODF element -->
+				<value-of select="concat($FILE_URL,$URIorSafeCURIE)"/>
+			</when>
+			<when test="string-length($URIorSafeCURIE)=0"> <!-- an ODF document -->
+				<value-of select="$sourceBaseURL"/>
+			</when>
+			<otherwise> <!-- an IRI -->
+				<value-of select="$URIorSafeCURIE"/>
+			</otherwise>
+		</choose>
+	</template>
+
+	<template match="node()"/>
+</stylesheet>
\ No newline at end of file

Added: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/GRDDLTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/GRDDLTest.java?rev=1418326&view=auto
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/GRDDLTest.java (added)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/GRDDLTest.java Fri Dec  7 14:28:07 2012
@@ -0,0 +1,84 @@
+/************************************************************************
+ *
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.logging.Logger;
+
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.odftoolkit.odfdom.doc.OdfDocument;
+import org.odftoolkit.odfdom.doc.OdfTextDocument;
+import org.odftoolkit.odfdom.utils.ResourceUtilities;
+import org.xml.sax.InputSource;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
+import com.ibm.icu.impl.Assert;
+import java.util.logging.Level;
+
+public class GRDDLTest extends ModelTestBase {
+
+	private static final Logger LOG = Logger.getLogger(GRDDLTest.class
+			.getName());
+	private static final String SIMPLE_ODT = "test_rdfmeta.odt";
+
+	public GRDDLTest(String name) {
+		super(name);
+		// TODO Auto-generated constructor stub
+	}
+
+	@Test
+	public void testGRDDL()  {
+		try {
+			OdfXMLHelper helper = new OdfXMLHelper();
+			OdfTextDocument odt = (OdfTextDocument) OdfDocument
+					.loadDocument(ResourceUtilities.getAbsolutePath(SIMPLE_ODT));
+			InputSource inputSource = new InputSource(ResourceUtilities.getURI(
+					"grddl/odf2rdf.xsl").toString());
+			Templates multiFileAccessTemplate = TransformerFactory.newInstance()
+					.newTemplates(new SAXSource(inputSource));
+			ByteArrayOutputStream out = new ByteArrayOutputStream();
+	 
+			helper.transform(odt.getPackage(), "content.xml",
+					multiFileAccessTemplate, new StreamResult(out));
+
+			Model m1 = createMemModel();
+			m1.read(new InputStreamReader(new ByteArrayInputStream(out
+					.toByteArray()), "utf-8"), odt.getPackage().getBaseURI());
+			LOG.info("RDF Model:\n" + m1.toString());
+			TestCase.assertEquals(5, m1.size());
+		} catch (Exception ex) {
+			Assert.fail(ex.getMessage());
+			Logger.getLogger(GRDDLTest.class.getName()).log(Level.SEVERE, null, ex);
+		}
+	}
+}

Added: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/RDFMetadataTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/RDFMetadataTest.java?rev=1418326&view=auto
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/RDFMetadataTest.java (added)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/RDFMetadataTest.java Fri Dec  7 14:28:07 2012
@@ -0,0 +1,280 @@
+/************************************************************************
+ *
+ * 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.util.logging.Logger;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.odftoolkit.odfdom.doc.OdfDocument;
+import org.odftoolkit.odfdom.doc.OdfTextDocument;
+import org.odftoolkit.odfdom.dom.OdfContentDom;
+import org.odftoolkit.odfdom.dom.element.table.TableCoveredTableCellElement;
+import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
+import org.odftoolkit.odfdom.dom.element.text.TextBookmarkStartElement;
+import org.odftoolkit.odfdom.dom.element.text.TextHElement;
+import org.odftoolkit.odfdom.dom.element.text.TextMetaElement;
+import org.odftoolkit.odfdom.dom.element.text.TextPElement;
+import org.odftoolkit.odfdom.dom.rdfa.BookmarkRDFMetadataExtractor;
+import org.odftoolkit.odfdom.utils.ResourceUtilities;
+import org.w3c.dom.Node;
+
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.rdf.model.StmtIterator;
+import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
+import com.hp.hpl.jena.util.PrintUtil;
+
+public class RDFMetadataTest extends ModelTestBase {
+
+	private static final Logger LOG = Logger.getLogger(RDFMetadataTest.class
+			.getName());
+	private static final String SIMPLE_ODT = "test_rdfmeta.odt";
+
+	public RDFMetadataTest(String name) {
+		super(name);
+		// TODO Auto-generated constructor stub
+	}
+
+	@Test
+	public void testGetRDFMetaFromGRDDLXSLT() throws Exception {
+		OdfTextDocument odt = (OdfTextDocument) OdfDocument
+				.loadDocument(ResourceUtilities.getAbsolutePath(SIMPLE_ODT));
+		Model m1 = odt.getManifestRDFMetadata();
+		LOG.info("RDF Model - manifest:\n" + m1.toString());				
+		long size1 = m1.size();
+		TestCase.assertEquals(25, size1);
+
+		Model m2 = odt.getInContentMetadata();
+		LOG.info("RDF Model - rood document in-content:\n" + m1.toString());				
+		long size2 = m2.size();
+		TestCase.assertEquals(20, size2);
+
+		Model m = odt.getRDFMetadata();
+
+		// This triples are duplicated in m1 and m2:
+		// (test_rdfmeta.odt rdf:type
+		// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document)
+		// (test_rdfmeta.odt/embeded.odt rdf:type
+		// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document)
+//		int duplicated = 2;
+		Model m3 = m1.intersection(m2);
+		LOG.info("RDF Model - duplicated (manifest & in-content of root doc):\n" + m3.toString());
+// Uncertain about the previuos statement, as the duplicated RDF triple do not have an identical subject..
+//		TestCase.assertEquals(duplicated, m3.size());
+//		TestCase.assertEquals(size1 + size2 - duplicated, m.size());
+
+		// test the embeded document
+		OdfDocument subDoc = odt.loadSubDocument("embeded.odt");
+		m1 = subDoc.getManifestRDFMetadata();
+		size1 = m1.size();
+		TestCase.assertEquals(5, size1);
+
+		m2 = subDoc.getInContentMetadata();
+		size2 = m2.size();
+		LOG.info("RDF Model - embedded document in content:\n" + m2.toString());
+		TestCase.assertEquals(6, size2);
+
+		m = subDoc.getRDFMetadata();
+
+		// This triple is duplicated in m1 and m2:
+		// (test_rdfmeta.odt/embeded.odt rdf:type
+		// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document)
+//		duplicated = 1;
+		m3 = m1.intersection(m2);
+		LOG.info("RDF Model - intersection of in-content metadata of root & embedded document:\n" + m2.toString());
+		//TestCase.assertEquals(duplicated, m3.size());
+		//TestCase.assertEquals(size1 + size2 - duplicated, m.size());
+
+	}
+
+	@Test
+	public void testGetInContentMetaFromCache() throws Exception {
+		OdfTextDocument odt = (OdfTextDocument) OdfDocument
+				.loadDocument(ResourceUtilities.getAbsolutePath(SIMPLE_ODT));
+		Model m1 = odt.getInContentMetadataFromCache();
+
+		// We have the following 1 triple in cache:
+		// (http://dbpedia.org/page/J._R._R._Tolkien
+		// http://www.w3.org/2006/vcard/ns#fn 'John Ronald Reuel Tolkien')
+		TestCase.assertEquals(1, m1.size());
+
+		OdfContentDom contentDom = odt.getContentDom();
+		XPath xpath = contentDom.getXPath();
+		TextMetaElement tm = (TextMetaElement) xpath.evaluate(
+				"//text:p/text:meta[last()]", contentDom, XPathConstants.NODE);
+
+		tm.setXhtmlAboutAttribute("http://dbpedia.org/page/J._K._Rowling");
+		m1 = odt.getInContentMetadataFromCache();
+		PrintUtil.printOut(m1.listStatements());
+		TestCase.assertEquals("http://dbpedia.org/page/J._K._Rowling", m1
+				.listStatements().nextStatement().getSubject().getURI());
+
+		tm.setTextContent("Joanne Kathleen Rowling");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals("Joanne Kathleen Rowling", m1.listStatements()
+				.nextStatement().getObject().toString());
+
+		tm.setXhtmlPropertyAttribute("dc:name");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals("http://purl.org/dc/elements/1.1/name", m1
+				.listStatements().nextStatement().getPredicate().getURI());
+
+		Node parent = tm.getParentNode();
+		parent.removeChild(tm);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(0, m1.size());
+		parent.appendChild(tm);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		parent.removeChild(tm);
+
+		TextPElement pEle = contentDom.newOdfElement(TextPElement.class);
+		parent.appendChild(pEle);
+		pEle.setXhtmlAboutAttribute("[dbpedia:J._K._Rowling]");
+		pEle.setXhtmlPropertyAttribute("dbpprop:birthDate dbpprop:dateOfBirth");
+		pEle.setXhtmlDatatypeAttribute("xsd:date");
+		pEle.setXhtmlContentAttribute("1965-07-31");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(2, m1.size());
+		StmtIterator iter = m1.listStatements();
+		while (iter.hasNext()) {
+			Statement stmt = iter.nextStatement();
+			TestCase.assertEquals("http://dbpedia.org/page/J._K._Rowling", stmt
+					.getSubject().getURI());
+			TestCase.assertTrue(stmt.getObject().canAs(Literal.class));
+			Literal literal = stmt.getObject().as(Literal.class);
+			TestCase.assertEquals("http://www.w3.org/2001/XMLSchema#date",
+					literal.getDatatypeURI());
+			TestCase.assertEquals("1965-07-31", literal.getLexicalForm());
+		}
+		pEle.setXhtmlPropertyAttribute("dc:date");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		TestCase.assertEquals("http://purl.org/dc/elements/1.1/date", m1
+				.listStatements().nextStatement().getPredicate().getURI());
+
+		parent.removeChild(pEle);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(0, m1.size());
+		parent.appendChild(pEle);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		parent.removeChild(pEle);
+
+		TextHElement hEle = contentDom.newOdfElement(TextHElement.class);
+		parent.appendChild(hEle);
+		hEle.setXhtmlAboutAttribute("[dbpedia:J._K._Rowling]");
+		hEle.setXhtmlPropertyAttribute("dbpprop:children");
+		hEle.setXhtmlDatatypeAttribute("xsd:integer");
+		hEle.setTextContent("2");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		TestCase.assertEquals("http://dbpedia.org/page/J._K._Rowling", m1
+				.listStatements().nextStatement().getSubject().getURI());
+		TestCase.assertEquals("http://dbpedia.org/property/children", m1
+				.listStatements().nextStatement().getPredicate().getURI());
+		TestCase.assertTrue(m1.listStatements().nextStatement().getObject()
+				.canAs(Literal.class));
+		TestCase.assertEquals("2^^http://www.w3.org/2001/XMLSchema#integer", m1
+				.listStatements().nextStatement().getObject().toString());
+		hEle.setTextContent("3");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals("3^^http://www.w3.org/2001/XMLSchema#integer", m1
+				.listStatements().nextStatement().getObject().toString());
+
+		parent.removeChild(hEle);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(0, m1.size());
+		parent.appendChild(hEle);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		parent.removeChild(hEle);
+
+		TableTableCellElement ttce = contentDom
+				.newOdfElement(TableTableCellElement.class);
+		parent.appendChild(ttce);
+		ttce.setXhtmlAboutAttribute("[dbpedia:J._K._Rowling]");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(0, m1.size());
+		ttce.setXhtmlPropertyAttribute("dbpprop:nationality");
+		ttce.setTextContent("British");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		ttce.setXhtmlAboutAttribute("http://dbpedia.org/page/J._R._R._Tolkien");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		TestCase.assertEquals("http://dbpedia.org/page/J._R._R._Tolkien", m1
+				.listStatements().nextStatement().getSubject().getURI());
+
+		TableCoveredTableCellElement tctce = contentDom
+				.newOdfElement(TableCoveredTableCellElement.class);
+		parent.appendChild(tctce);
+		tctce.setXhtmlAboutAttribute("[dbpedia:J._R._R._Tolkien]");
+		tctce.setXhtmlPropertyAttribute("dbpprop:shortDescription");
+		tctce.setXhtmlContentAttribute("British philologist and author");
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(2, m1.size());
+
+		parent.removeChild(ttce);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		parent.appendChild(ttce);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(2, m1.size());
+		parent.removeChild(ttce);
+
+		parent.removeChild(tctce);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(0, m1.size());
+		parent.appendChild(tctce);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(1, m1.size());
+		parent.removeChild(tctce);
+		m1 = odt.getInContentMetadataFromCache();
+		TestCase.assertEquals(0, m1.size());
+
+	}
+
+	@Test
+	public void testGetBookmarkRDFMetadata() throws Exception {
+		OdfTextDocument odt = (OdfTextDocument) OdfDocument
+				.loadDocument(ResourceUtilities.getAbsolutePath(SIMPLE_ODT));
+		Model m = odt.getBookmarkRDFMetadata();
+		TestCase.assertEquals(2, m.size());
+
+		OdfContentDom contentDom = odt.getContentDom();
+		XPath xpath = contentDom.getXPath();
+		TextBookmarkStartElement tm = (TextBookmarkStartElement) xpath
+				.evaluate("//text:bookmark-start[last()]", contentDom,
+						XPathConstants.NODE);
+		BookmarkRDFMetadataExtractor extractor = BookmarkRDFMetadataExtractor
+				.newBookmarkTextExtractor();
+		m = extractor.getBookmarkRDFMetadata(tm);
+		TestCase.assertEquals(1, m.size());
+	}
+}

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java?rev=1418326&r1=1418325&r2=1418326&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java (original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/utils/ResourceUtilities.java Fri Dec  7 14:28:07 2012
@@ -1,113 +1,115 @@
-/************************************************************************
- *
- * 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.utils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/** Test utitility class providing resources for the test in- and output */
-public final class ResourceUtilities {
-
-	private ResourceUtilities() {
-	}
-
-	/** The relative path of the test file will be resolved and the absolute will be returned
-	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
-	 * @return the absolute path of the test file
-	 * @throws FileNotFoundException If the file could not be found
-	 */
-	public static String getAbsolutePath(String relativeFilePath) throws FileNotFoundException {
-		URI uri = null;
-		try {
-			uri = ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).toURI();
-		} catch (URISyntaxException ex) {
-			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		if (uri == null) {
-			throw new FileNotFoundException("Could not find the file '" + relativeFilePath + "'!");
-		}
-		return uri.getPath();
-	}
-
-	/** The relative path of the test file will be resolved and the absolute will be returned
-	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
-	 * @return the URI created based on the relativeFilePath
-	 * @throws URISyntaxException if no URI could be created from the given relative path
-	 */
-	public static URI getURI(String relativeFilePath) throws URISyntaxException {
-		String filePath = "file:" + ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).getPath();
-		return new URI(filePath);		
-		//return ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).toURI();
-	}
-
-	/** The relative path of the test file will be used to determine an absolute
-	 *  path to a temporary directory in the output directory.
-	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
-	 * @return absolute path to a test output
-	 * @throws IOException if no absolute Path could be created.
-	 */
-	public static String getTestOutput(String relativeFilePath) throws IOException {
-		return File.createTempFile(relativeFilePath, null).getAbsolutePath();
-	}
-
-	/** The Input of the test file will be resolved and the absolute will be returned
-	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
-	 * @return the absolute path of the test file
-	 */
-	public static InputStream getTestResourceAsStream(String relativeFilePath) {
-		return ResourceUtilities.class.getClassLoader().getResourceAsStream(relativeFilePath);
-	}
-
-	/** Relative to the test output directory a test file will be returned dependent on the relativeFilePath provided.
-	 * @param relativeFilePath Path of the test output resource relative to <code>target/test-classes/</code>.
-	 * @return the empty <code>File</code> of the test output (to be filled)
-	 */
-	public static File newTestOutputFile(String relativeFilePath) {
-		String filepath = null;
-		try {
-			filepath = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath() + relativeFilePath;
-		} catch (URISyntaxException ex) {
-			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		return new File(filepath);
-	}
-
-	/** 
-	 * @return the absolute path of the test output folder, which is usually <code>target/test-classes/</code>.
-	 */
-	public static String getTestOutputFolder() {
-		String testFolder = null;
-		try {
-			testFolder = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath();
-		} catch (URISyntaxException ex) {
-			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		return testFolder;		
-	}
-}
+/************************************************************************
+ *
+ * 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.utils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.odftoolkit.odfdom.pkg.rdfa.Util;
+
+/** Test utility class providing resources for the test in- and output */
+public final class ResourceUtilities {
+
+	private ResourceUtilities() {
+	}
+
+	/** The relative path of the test file will be resolved and the absolute will be returned
+	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
+	 * @return the absolute path of the test file
+	 * @throws FileNotFoundException If the file could not be found
+	 */
+	public static String getAbsolutePath(String relativeFilePath) throws FileNotFoundException {
+		URI uri = null;
+		try {
+			uri = ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).toURI();
+			uri = new URI(Util.toExternalForm(uri));
+		} catch (URISyntaxException ex) {
+			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
+		}
+		if (uri == null) {
+			throw new FileNotFoundException("Could not find the file '" + relativeFilePath + "'!");
+		}
+		return uri.getPath();
+	}
+
+	/** The relative path of the test file will be resolved and the absolute will be returned
+	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
+	 * @return the URI created based on the relativeFilePath
+	 * @throws URISyntaxException if no URI could be created from the given relative path
+	 */
+	public static URI getURI(String relativeFilePath) throws URISyntaxException {
+		String filePath = "file:" + ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).getPath();
+		filePath = Util.toExternalForm(new URI(filePath));
+		return new URI(filePath);		
+	}
+
+	/** The relative path of the test file will be used to determine an absolute
+	 *  path to a temporary directory in the output directory.
+	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
+	 * @return absolute path to a test output
+	 * @throws IOException if no absolute Path could be created.
+	 */
+	public static String getTestOutput(String relativeFilePath) throws IOException {
+		return File.createTempFile(relativeFilePath, null).getAbsolutePath();
+	}
+
+	/** The Input of the test file will be resolved and the absolute will be returned
+	 * @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
+	 * @return the absolute path of the test file
+	 */
+	public static InputStream getTestResourceAsStream(String relativeFilePath) {
+		return ResourceUtilities.class.getClassLoader().getResourceAsStream(relativeFilePath);
+	}
+
+	/** Relative to the test output directory a test file will be returned dependent on the relativeFilePath provided.
+	 * @param relativeFilePath Path of the test output resource relative to <code>target/test-classes/</code>.
+	 * @return the empty <code>File</code> of the test output (to be filled)
+	 */
+	public static File newTestOutputFile(String relativeFilePath) {
+		String filepath = null;
+		try {
+			filepath = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath() + relativeFilePath;
+		} catch (URISyntaxException ex) {
+			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
+		}
+		return new File(filepath);
+	}
+
+	/** 
+	 * @return the absolute path of the test output folder, which is usually <code>target/test-classes/</code>.
+	 */
+	public static String getTestOutputFolder() {
+		String testFolder = null;
+		try {
+			testFolder = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath();
+		} catch (URISyntaxException ex) {
+			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
+		}
+		return testFolder;		
+	}
+}

Added: incubator/odf/trunk/odfdom/src/test/resources/test_rdfmeta.odt
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/resources/test_rdfmeta.odt?rev=1418326&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/odf/trunk/odfdom/src/test/resources/test_rdfmeta.odt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/odf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/pom.xml?rev=1418326&r1=1418325&r2=1418326&view=diff
==============================================================================
--- incubator/odf/trunk/pom.xml (original)
+++ incubator/odf/trunk/pom.xml Fri Dec  7 14:28:07 2012
@@ -94,7 +94,7 @@
                         <configuration>
                             <excludes>
                                 <exclude>CHANGES.txt</exclude>
-				<exclude>.gitignore</exclude>
+								<exclude>.gitignore</exclude>
                             </excludes>
                         </configuration>
                         <executions>
@@ -247,24 +247,24 @@
 
                                             scp -r ${basedir}/target/${project.version} people.apache.org:public_html/odftoolkit/
 
-                                            A release vote template has been generated for you:    file://${basedir}/target/vote.txt
-                                        </echo>
-                                        <echo />
-                                    </tasks>                                 
-                                </configuration>
-                            </execution>
-                        </executions>
-                        <dependencies>
-                            <dependency>
-                                <groupId>org.apache.ant</groupId>
-                                <artifactId>ant-nodeps</artifactId>
-                                <version>1.8.1</version>
-                            </dependency>
-                        </dependencies>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>-->
-    </profiles>
+											A release vote template has been generated for you:    file://${basedir}/target/vote.txt
+										</echo>
+										<echo />
+									</tasks>                                 
+								</configuration>
+							</execution>
+						</executions>
+						<dependencies>
+							<dependency>
+								<groupId>org.apache.ant</groupId>
+								<artifactId>ant-nodeps</artifactId>
+								<version>1.8.1</version>
+							</dependency>
+						</dependencies>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>-->
+	</profiles>
 </project>
 

Modified: incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java?rev=1418326&r1=1418325&r2=1418326&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java (original)
+++ incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/utils/ResourceUtilities.java Fri Dec  7 14:28:07 2012
@@ -1,138 +1,141 @@
-/************************************************************************
- *
- * 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.simple.utils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/** Test utitility class providing resources for the test in- and output */
-public final class ResourceUtilities {
-	private ResourceUtilities() {
-	}
-
-	/**
-	 * The relative path of the test file will be resolved and the absolute will
-	 * be returned
-	 * 
-	 * @param relativeFilePath
-	 *            Path of the test resource relative to
-	 *            <code>src/test/resource/</code>.
-	 * @return the absolute path of the test file
-	 * @throws FileNotFoundException
-	 *             If the file could not be found
-	 */
-	public static String getAbsolutePath(String relativeFilePath) throws FileNotFoundException {
-		URI uri = null;
-		try {
-			uri = ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).toURI();
-		} catch (URISyntaxException ex) {
-			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		if (uri == null) {
-			throw new FileNotFoundException("Could not find the file '" + relativeFilePath + "'!");
-		}
-		return uri.getPath();
-	}
-
-	/**
-	 * The relative path of the test file will be resolved and the absolute will
-	 * be returned
-	 * 
-	 * @param relativeFilePath
-	 *            Path of the test resource relative to
-	 *            <code>src/test/resource/</code>.
-	 * @return the URI created based on the relativeFilePath
-	 * @throws URISyntaxException
-	 *             if no URI could be created from the given relative path
-	 */
-	public static URI getURI(String relativeFilePath) throws URISyntaxException {
-		String filePath = "file:" + ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).getPath();
-		return new URI(filePath);
-	}
-
-	/**
-	 * The relative path of the test file will be used to determine an absolute
-	 * path to a temporary directory in the output directory.
-	 * 
-	 * @param relativeFilePath
-	 *            Path of the test resource relative to
-	 *            <code>src/test/resource/</code>.
-	 * @return absolute path to a test output
-	 * @throws IOException
-	 *             if no absolute Path could be created.
-	 */
-	public static String getTestOutput(String relativeFilePath) throws IOException {
-		return File.createTempFile(relativeFilePath, null).getAbsolutePath();
-	}
-
-	/**
-	 * The Input of the test file will be resolved and the absolute will be
-	 * returned
-	 * 
-	 * @param relativeFilePath
-	 *            Path of the test resource relative to
-	 *            <code>src/test/resource/</code>.
-	 * @return the absolute path of the test file
-	 */
-	public static InputStream getTestResourceAsStream(String relativeFilePath) {
-		return ResourceUtilities.class.getClassLoader().getResourceAsStream(relativeFilePath);
-	}
-
-	/**
-	 * Relative to the test output directory a test file will be returned
-	 * dependent on the relativeFilePath provided.
-	 * 
-	 * @param relativeFilePath
-	 *            Path of the test output resource relative to
-	 *            <code>target/test-classes/</code>.
-	 * @return the empty <code>File</code> of the test output (to be filled)
-	 */
-	public static File newTestOutputFile(String relativeFilePath) {
-		String filepath = null;
-		try {
-			filepath = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath() + relativeFilePath;
-		} catch (URISyntaxException ex) {
-			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		return new File(filepath);
-	}
-
-	/**
-	 * @return the absolute path of the test output folder, which is usually
-	 *         <code>target/test-classes/</code>.
-	 */
-	public static String getTestOutputFolder() {
-		String testFolder = null;
-		try {
-			testFolder = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath();
-		} catch (URISyntaxException ex) {
-			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		return testFolder;
-	}
-}
+/************************************************************************
+ *
+ * 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.simple.utils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.odftoolkit.odfdom.pkg.rdfa.Util;
+
+/** Test utility class providing resources for the test in- and output */
+public final class ResourceUtilities {
+	private ResourceUtilities() {
+	}
+
+	/**
+	 * The relative path of the test file will be resolved and the absolute will
+	 * be returned
+	 * 
+	 * @param relativeFilePath
+	 *            Path of the test resource relative to
+	 *            <code>src/test/resource/</code>.
+	 * @return the absolute path of the test file
+	 * @throws FileNotFoundException
+	 *             If the file could not be found
+	 */
+	public static String getAbsolutePath(String relativeFilePath) throws FileNotFoundException {
+		URI uri = null;
+		try {
+			uri = ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).toURI();
+			uri = new URI(Util.toExternalForm(uri));
+		} catch (URISyntaxException ex) {
+			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
+		}
+		if (uri == null) {
+			throw new FileNotFoundException("Could not find the file '" + relativeFilePath + "'!");
+		}
+		return uri.getPath();
+	}
+
+	/**
+	 * The relative path of the test file will be resolved and the absolute will
+	 * be returned
+	 * 
+	 * @param relativeFilePath
+	 *            Path of the test resource relative to
+	 *            <code>src/test/resource/</code>.
+	 * @return the URI created based on the relativeFilePath
+	 * @throws URISyntaxException
+	 *             if no URI could be created from the given relative path
+	 */
+	public static URI getURI(String relativeFilePath) throws URISyntaxException {
+		String filePath = "file:" + ResourceUtilities.class.getClassLoader().getResource(relativeFilePath).getPath();
+		filePath = Util.toExternalForm(new URI(filePath));
+		return new URI(filePath);
+	}
+
+	/**
+	 * The relative path of the test file will be used to determine an absolute
+	 * path to a temporary directory in the output directory.
+	 * 
+	 * @param relativeFilePath
+	 *            Path of the test resource relative to
+	 *            <code>src/test/resource/</code>.
+	 * @return absolute path to a test output
+	 * @throws IOException
+	 *             if no absolute Path could be created.
+	 */
+	public static String getTestOutput(String relativeFilePath) throws IOException {
+		return File.createTempFile(relativeFilePath, null).getAbsolutePath();
+	}
+
+	/**
+	 * The Input of the test file will be resolved and the absolute will be
+	 * returned
+	 * 
+	 * @param relativeFilePath
+	 *            Path of the test resource relative to
+	 *            <code>src/test/resource/</code>.
+	 * @return the absolute path of the test file
+	 */
+	public static InputStream getTestResourceAsStream(String relativeFilePath) {
+		return ResourceUtilities.class.getClassLoader().getResourceAsStream(relativeFilePath);
+	}
+
+	/**
+	 * Relative to the test output directory a test file will be returned
+	 * dependent on the relativeFilePath provided.
+	 * 
+	 * @param relativeFilePath
+	 *            Path of the test output resource relative to
+	 *            <code>target/test-classes/</code>.
+	 * @return the empty <code>File</code> of the test output (to be filled)
+	 */
+	public static File newTestOutputFile(String relativeFilePath) {
+		String filepath = null;
+		try {
+			filepath = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath() + relativeFilePath;
+		} catch (URISyntaxException ex) {
+			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
+		}
+		return new File(filepath);
+	}
+
+	/**
+	 * @return the absolute path of the test output folder, which is usually
+	 *         <code>target/test-classes/</code>.
+	 */
+	public static String getTestOutputFolder() {
+		String testFolder = null;
+		try {
+			testFolder = ResourceUtilities.class.getClassLoader().getResource("").toURI().getPath();
+		} catch (URISyntaxException ex) {
+			Logger.getLogger(ResourceUtilities.class.getName()).log(Level.SEVERE, null, ex);
+		}
+		return testFolder;
+	}
+}



Mime
View raw message