You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2012/10/27 18:07:19 UTC
svn commit: r1402816 - in /pdfbox/branches/xmpbox-refactoring/xmpbox/src:
main/java/org/apache/padaf/xmpbox/ main/java/org/apache/padaf/xmpbox/schema/
main/java/org/apache/padaf/xmpbox/type/
main/java/org/apache/padaf/xmpbox/xml/ test/java/org/apache/p...
Author: gbailleul
Date: Sat Oct 27 16:07:18 2012
New Revision: 1402816
URL: http://svn.apache.org/viewvc?rev=1402816&view=rev
Log:
PDFBOX-1388:
added test on invalid xmp
simplified defined structures parsing
Added:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropertiesDescription.java
- copied, changed from r1402595, pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropMapping.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot2.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noroot.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacket.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacketend.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/tworoot.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedpropertyindefinedschema.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedschema.xml
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedstructuredindefinedschema.xml
Removed:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropMapping.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ReflectHelper.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Types.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomHelper.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomXmpParser.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/PdfaExtensionHelper.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/XmpSerializer.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/PropMappingTest.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XmpConstants.java Sat Oct 27 16:07:18 2012
@@ -37,6 +37,20 @@ public final class XmpConstants {
public static final String DEFAULT_RDF_PREFIX = "rdf";
public static final String DEFAULT_RDF_LOCAL_NAME = "RDF";
+
+ public static final String LIST_NAME = "li";
+
+ public static final String LANG_NAME = "lang";
+
+ public static final String ABOUT_NAME = "about";
+
+ public static final String DESCRIPTION_NAME = "Description";
+
+ public static final String RESOURCE_NAME = "Resource";
+
+ public static final String PARSE_TYPE = "parseType";
+
+ public static final String X_DEFAULT = "x-default";
private XmpConstants () {
// hide constructor
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java Sat Oct 27 16:07:18 2012
@@ -30,7 +30,6 @@ import org.apache.padaf.xmpbox.type.Card
import org.apache.padaf.xmpbox.type.PropertyType;
import org.apache.padaf.xmpbox.type.StructuredType;
import org.apache.padaf.xmpbox.type.TextType;
-import org.apache.padaf.xmpbox.type.TypeMapping;
import org.apache.padaf.xmpbox.type.Types;
import org.apache.padaf.xmpbox.type.URLType;
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java Sat Oct 27 16:07:18 2012
@@ -55,8 +55,6 @@ import org.apache.padaf.xmpbox.type.Type
*/
public class XMPSchema extends AbstractStructuredType {
- public static final String RDFABOUT = "about";
-
/**
* Create a new blank schema that can be populated.
*
@@ -111,7 +109,7 @@ public class XMPSchema extends AbstractS
* @return The RDF 'about' attribute.
*/
public Attribute getAboutAttribute() {
- return getAttribute(RDFABOUT);
+ return getAttribute(XmpConstants.ABOUT_NAME);
}
/**
@@ -120,7 +118,7 @@ public class XMPSchema extends AbstractS
* @return The RDF 'about' value.
*/
public String getAboutValue() {
- Attribute prop = getAttribute(RDFABOUT);
+ Attribute prop = getAttribute(XmpConstants.ABOUT_NAME);
if (prop != null) {
return prop.getValue();
}
@@ -137,7 +135,7 @@ public class XMPSchema extends AbstractS
*/
public void setAbout(Attribute about) throws BadFieldValueException {
if (XmpConstants.RDF_NAMESPACE.equals(about.getNamespace())) {
- if (RDFABOUT.equals(about.getName())) {
+ if (XmpConstants.ABOUT_NAME.equals(about.getName())) {
setAttribute(about);
return;
}
@@ -155,9 +153,9 @@ public class XMPSchema extends AbstractS
*/
public void setAboutAsSimple(String about) {
if (about == null) {
- removeAttribute(RDFABOUT);
+ removeAttribute(XmpConstants.ABOUT_NAME);
} else {
- setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "about", about));
+ setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, XmpConstants.ABOUT_NAME, about));
}
}
@@ -635,7 +633,7 @@ public class XMPSchema extends AbstractS
private void internalAddBagValue(String qualifiedBagName, String bagValue) {
ArrayProperty bag = (ArrayProperty) getAbstractProperty(qualifiedBagName);
- TextType li = createTextType ( "li", bagValue);
+ TextType li = createTextType ( XmpConstants.LIST_NAME, bagValue);
if (bag != null) {
bag.getContainer().addProperty(li);
} else {
@@ -745,7 +743,7 @@ public class XMPSchema extends AbstractS
public void addUnqualifiedSequenceValue(String simpleSeqName, String seqValue) {
String qualifiedSeqName = simpleSeqName;
ArrayProperty seq = (ArrayProperty) getAbstractProperty(qualifiedSeqName);
- TextType li = createTextType ( "li", seqValue);
+ TextType li = createTextType ( XmpConstants.LIST_NAME, seqValue);
if (seq != null) {
seq.getContainer().addProperty(li);
} else {
@@ -870,7 +868,7 @@ public class XMPSchema extends AbstractS
* The date to add to the sequence property.
*/
public void addUnqualifiedSequenceDateValue(String seqName, Calendar date) {
- addUnqualifiedSequenceValue(seqName, getMetadata().getTypeMapping().createDate(null, "rdf", "li", date));
+ addUnqualifiedSequenceValue(seqName, getMetadata().getTypeMapping().createDate(null, XmpConstants.DEFAULT_RDF_LOCAL_NAME, XmpConstants.LIST_NAME, date));
}
/**
@@ -916,16 +914,16 @@ public class XMPSchema extends AbstractS
boolean xdefaultFound = false;
// If alternatives contains x-default in first value
if (it.hasNext()) {
- if (it.next().getAttribute("lang").getValue().equals(
- "x-default")) {
+ if (it.next().getAttribute(XmpConstants.LANG_NAME).getValue().equals(
+ XmpConstants.X_DEFAULT)) {
return;
}
}
// Find the xdefault definition
while (it.hasNext() && !xdefaultFound) {
xdefault = it.next();
- if (xdefault.getAttribute("lang").getValue()
- .equals("x-default")) {
+ if (xdefault.getAttribute(XmpConstants.LANG_NAME).getValue()
+ .equals(XmpConstants.X_DEFAULT)) {
alt.removeProperty(xdefault);
xdefaultFound = true;
}
@@ -982,7 +980,7 @@ public class XMPSchema extends AbstractS
while (itCplx.hasNext()) {
tmp = itCplx.next();
// System.err.println(tmp.getAttribute("xml:lang").getStringValue());
- if (tmp.getAttribute("lang").getValue()
+ if (tmp.getAttribute(XmpConstants.LANG_NAME).getValue()
.equals(language)) {
// the same language has been found
if (value == null) {
@@ -991,10 +989,10 @@ public class XMPSchema extends AbstractS
} else {
prop.getContainer().removeProperty(tmp);
TextType langValue;
- langValue = createTextType ( "li",value);
+ langValue = createTextType ( XmpConstants.LIST_NAME,value);
langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI,
- "lang", language));
+ XmpConstants.LANG_NAME, language));
prop.getContainer().addProperty(langValue);
}
reorganizeAltOrder(prop.getContainer());
@@ -1003,8 +1001,8 @@ public class XMPSchema extends AbstractS
}
// if no definition found, we add a new one
TextType langValue;
- langValue = createTextType ( "li", value);
- langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI, "lang",
+ langValue = createTextType ( XmpConstants.LIST_NAME, value);
+ langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI, XmpConstants.LANG_NAME,
language));
prop.getContainer().addProperty(langValue);
reorganizeAltOrder(prop.getContainer());
@@ -1012,9 +1010,9 @@ public class XMPSchema extends AbstractS
} else {
prop = createArrayProperty( name,Cardinality.Alt);
TextType langValue;
- langValue = createTextType ( "li", value);
+ langValue = createTextType ( XmpConstants.LIST_NAME, value);
langValue
- .setAttribute(new Attribute(XMLConstants.XML_NS_URI, "lang", language));
+ .setAttribute(new Attribute(XMLConstants.XML_NS_URI, XmpConstants.LANG_NAME, language));
prop.getContainer().addProperty(langValue);
addProperty(prop);
}
@@ -1032,7 +1030,7 @@ public class XMPSchema extends AbstractS
* @return The value of the language property.
*/
public String getUnqualifiedLanguagePropertyValue(String name, String expectedLanguage) {
- String language = (expectedLanguage!=null)?expectedLanguage:"x-default";
+ String language = (expectedLanguage!=null)?expectedLanguage:XmpConstants.X_DEFAULT;
AbstractField property = getAbstractProperty(name);
if (property != null) {
if (property instanceof ArrayProperty) {
@@ -1043,7 +1041,7 @@ public class XMPSchema extends AbstractS
Attribute text;
while (langsDef.hasNext()) {
tmp = langsDef.next();
- text = tmp.getAttribute("lang");
+ text = tmp.getAttribute(XmpConstants.LANG_NAME);
if (text != null) {
if (text.getValue().equals(language)) {
return ((TextType) tmp).getStringValue();
@@ -1083,11 +1081,11 @@ public class XMPSchema extends AbstractS
Attribute text;
while (langsDef.hasNext()) {
tmp = langsDef.next();
- text = tmp.getAttribute("lang");
+ text = tmp.getAttribute(XmpConstants.LANG_NAME);
if (text != null) {
retval.add(text.getValue());
} else {
- retval.add("x-default");
+ retval.add(XmpConstants.X_DEFAULT);
}
}
return retval;
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java Sat Oct 27 16:07:18 2012
@@ -22,11 +22,9 @@
package org.apache.padaf.xmpbox.schema;
import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.padaf.xmpbox.XMPMetadata;
-import org.apache.padaf.xmpbox.type.PropMapping;
+import org.apache.padaf.xmpbox.type.PropertiesDescription;
import org.apache.padaf.xmpbox.type.PropertyType;
@@ -42,12 +40,10 @@ public class XMPSchemaFactory {
private Class<? extends XMPSchema> schemaClass;
- private PropMapping propDef;
+ private PropertiesDescription propDef;
private String nsName;
- private List<PropMapping> importedPropertyMapping = new ArrayList<PropMapping>();
-
/**
* Factory Constructor for basic known schemas
*
@@ -59,21 +55,12 @@ public class XMPSchemaFactory {
* Properties Types list associated
*/
public XMPSchemaFactory(String namespace,
- Class<? extends XMPSchema> schemaClass, PropMapping propDef) {
+ Class<? extends XMPSchema> schemaClass, PropertiesDescription propDef) {
this.namespace = namespace;
this.schemaClass = schemaClass;
this.propDef = propDef;
}
- public void importXMPSchemaFactory(XMPSchemaFactory externalFactory)
- throws XmpSchemaException {
- if (!this.namespace.equals(externalFactory.namespace)) {
- throw new XmpSchemaException("Unable to import a XMPSchemaFactory if the namespace is different." +
- " - expected : " + this.namespace + " - import : " + externalFactory.namespace);
- }
- this.importedPropertyMapping.add(externalFactory.propDef);
- }
-
/**
* Get namespace URI treated by this factory
*
@@ -91,16 +78,7 @@ public class XMPSchemaFactory {
* @return null if propery name is unknown
*/
public PropertyType getPropertyType(String name) {
- PropertyType result = propDef.getPropertyType(name);
- if (result == null) {
- for (PropMapping mapping : importedPropertyMapping) {
- result = mapping.getPropertyType(name);
- if (result != null) {
- break;
- }
- }
- }
- return result;
+ return propDef.getPropertyType(name);
}
/**
@@ -145,7 +123,7 @@ public class XMPSchemaFactory {
}
}
- public PropMapping getPropertyDefinition () {
+ public PropertiesDescription getPropertyDefinition () {
return this.propDef;
}
Copied: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropertiesDescription.java (from r1402595, pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropMapping.java)
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropertiesDescription.java?p2=pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropertiesDescription.java&p1=pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropMapping.java&r1=1402595&r2=1402816&rev=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropMapping.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PropertiesDescription.java Sat Oct 27 16:07:18 2012
@@ -36,9 +36,7 @@ import java.util.Map;
* Attribute management pre-implemented in order to give clues to make
* an attribute management system
*/
-public class PropMapping {
-
- private String namespace;
+public class PropertiesDescription {
private Map<String, PropertyType> types;
@@ -49,21 +47,11 @@ public class PropMapping {
* @param namespace
* namespace URI concerned by this PropMapping
*/
- public PropMapping(String namespace) {
- this.namespace = namespace;
+ public PropertiesDescription() {
types = new HashMap<String, PropertyType>();
}
/**
- * Give the NS URI associated to this Property Description
- *
- * @return the namespace URI concerned by this PropMapping
- */
- public String getConcernedNamespace() {
- return namespace;
- }
-
- /**
* Get All Properties Name
*
* @return a list of properties qualifiedName
@@ -98,8 +86,4 @@ public class PropMapping {
return types.get(name);
}
- public boolean containsKey (String name) {
- return types.containsKey(name);
- }
-
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java Sat Oct 27 16:07:18 2012
@@ -23,6 +23,7 @@ package org.apache.padaf.xmpbox.type;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.HashMap;
@@ -46,15 +47,15 @@ import org.apache.padaf.xmpbox.schema.Xm
public final class TypeMapping {
- private Map<Types, PropMapping> structuredMappings;
+ private Map<Types, PropertiesDescription> structuredMappings;
// ns -> type
private Map<String, Types> structuredNamespaces;
// ns -> type
private Map<String, String> definedStructuredNamespaces;
-
- private Map<String, PropMapping> definedStructuredMappings;
+
+ private Map<String, PropertiesDescription> definedStructuredMappings;
private XMPMetadata metadata;
@@ -77,23 +78,23 @@ public final class TypeMapping {
private void initialize () {
// structured types
- structuredMappings = new HashMap<Types, PropMapping>();
+ structuredMappings = new HashMap<Types, PropertiesDescription>();
structuredNamespaces = new HashMap<String, Types>();
for (Types type : Types.values()) {
if (type.isStructured()) {
- Class<?> clz = type.getImplementingClass();
+ Class<? extends AbstractStructuredType> clz = type.getImplementingClass().asSubclass(AbstractStructuredType.class);
StructuredType st = clz.getAnnotation(StructuredType.class);
String ns = st.namespace();
- PropMapping pm = ReflectHelper.initializePropMapping(ns, clz);
+ PropertiesDescription pm = initializePropMapping(clz);
structuredNamespaces.put(ns, type);
structuredMappings.put(type, pm);
}
}
-
+
// define structured types
definedStructuredNamespaces = new HashMap<String, String>();
- definedStructuredMappings = new HashMap<String, PropMapping>();
-
+ definedStructuredMappings = new HashMap<String, PropertiesDescription>();
+
// schema
schemaMap = new HashMap<String, XMPSchemaFactory>();
addNameSpace(XMPBasicSchema.class);
@@ -108,32 +109,24 @@ public final class TypeMapping {
}
- public void addToDefinedStructuredTypes (String typeName, String ns, PropMapping pm) {
+ public void addToDefinedStructuredTypes (String typeName, String ns, PropertiesDescription pm) {
definedStructuredNamespaces.put(ns, typeName);
definedStructuredMappings.put(typeName, pm);
}
- public String getDefinedDescriptionByNamespace (String namespace) {
- return this.definedStructuredNamespaces.get(namespace);
+ public PropertiesDescription getDefinedDescriptionByNamespace (String namespace) {
+ String dt = definedStructuredNamespaces.get(namespace);
+ return this.definedStructuredMappings.get(dt);
}
- public PropMapping getDefinedPropMapping (String name) {
- return this.definedStructuredMappings.get(name);
- }
-
- public AbstractStructuredType instanciateStructuredType (Types type, String typeName, String propertyName) throws BadFieldValueException {
+ public AbstractStructuredType instanciateStructuredType (Types type, String propertyName) throws BadFieldValueException {
try {
- if (type==Types.DefinedType) {
- PropMapping pm = definedStructuredMappings.get(typeName);
- return new DefinedStructuredType(metadata, pm.getConcernedNamespace(), null, propertyName);
- } else {
- Class<? extends AbstractStructuredType> propertyTypeClass = type.getImplementingClass().asSubclass(AbstractStructuredType.class);
- Constructor<? extends AbstractStructuredType> construct = propertyTypeClass.getConstructor(new Class<?> [] {
- XMPMetadata.class});
- AbstractStructuredType tmp = construct.newInstance(metadata);
- tmp.setPropertyName(propertyName);
- return tmp;
- }
+ Class<? extends AbstractStructuredType> propertyTypeClass = type.getImplementingClass().asSubclass(AbstractStructuredType.class);
+ Constructor<? extends AbstractStructuredType> construct = propertyTypeClass.getConstructor(new Class<?> [] {
+ XMPMetadata.class});
+ AbstractStructuredType tmp = construct.newInstance(metadata);
+ tmp.setPropertyName(propertyName);
+ return tmp;
} catch (InvocationTargetException e) {
throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
} catch (IllegalArgumentException e) {
@@ -149,6 +142,12 @@ public final class TypeMapping {
}
}
+ public AbstractStructuredType instanciateDefinedType (String propertyName, String namespace) {
+ return new DefinedStructuredType(metadata, namespace, null, propertyName);
+ }
+
+
+
public AbstractSimpleProperty instanciateSimpleProperty (String nsuri, String prefix, String name, Object value, Types type) {
// constructor parameters
Object [] params = new Object [] {
@@ -180,8 +179,9 @@ public final class TypeMapping {
}
}
+
public AbstractSimpleProperty instanciateSimpleField (Class<?> clz, String nsuri, String prefix,String propertyName, Object value) {
- PropMapping pm = ReflectHelper.initializePropMapping(null, clz);
+ PropertiesDescription pm = initializePropMapping(clz);
PropertyType simpleType = pm.getPropertyType(propertyName);
Types type = simpleType.type();
return instanciateSimpleProperty(nsuri, prefix, propertyName, value, type);
@@ -203,15 +203,15 @@ public final class TypeMapping {
return definedStructuredNamespaces.containsKey(namespace);
}
-// public String getTypeInArray (String type) {
-// int pos = type.indexOf(' ');
-// if (pos<0) {
-// // not array
-// return null;
-// } else {
-// return type.substring(pos+1);
-// }
-// }
+ // public String getTypeInArray (String type) {
+ // int pos = type.indexOf(' ');
+ // if (pos<0) {
+ // // not array
+ // return null;
+ // } else {
+ // return type.substring(pos+1);
+ // }
+ // }
public boolean isDefinedType (String name) {
return this.definedStructuredMappings.containsKey(name);
@@ -220,18 +220,18 @@ public final class TypeMapping {
private void addNameSpace(Class<? extends XMPSchema> classSchem) {
StructuredType st = classSchem.getAnnotation(StructuredType.class);
String ns = st.namespace();
- schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, ReflectHelper.initializePropMapping(ns, classSchem)));
+ schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem)));
}
public void addNewNameSpace(String ns,String prefered) {
- PropMapping mapping = new PropMapping(ns);
+ PropertiesDescription mapping = new PropertiesDescription();
schemaMap.put(ns, new XMPSchemaFactory(ns, XMPSchema.class, mapping));
}
- public PropMapping getStructuredPropMapping (Types type) {
+ public PropertiesDescription getStructuredPropMapping (Types type) {
return structuredMappings.get(type);
}
-
+
/**
* Return the specialized schema class representation if it's known (create
* and add it to metadata). In other cases, return null
@@ -269,6 +269,10 @@ public final class TypeMapping {
return schemaMap.containsKey(namespace);
}
+ public boolean isDefinedNamespace (String namespace) {
+ return isDefinedSchema(namespace) || isStructuredTypeNamespace(namespace)||isDefinedTypeNamespace(namespace);
+ }
+
/**
* Give type of specified property in specified schema (given by its
* namespaceURI)
@@ -300,6 +304,26 @@ public final class TypeMapping {
}
}
+ public PropertiesDescription initializePropMapping(Class<?> classSchem) {
+ PropertiesDescription propMap = new PropertiesDescription();
+ Field [] fields = classSchem.getFields();
+ String propName = null;
+ for (Field field : fields) {
+ if (field.isAnnotationPresent(PropertyType.class)) {
+ try {
+ propName = (String) field.get(propName);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(
+ "couldn't read one type declaration, please check accessibility and declaration of fields annoted in "
+ + classSchem.getName(), e);
+ }
+ PropertyType propType = field.getAnnotation(PropertyType.class);
+ propMap.addNewProperty(propName, propType);
+ }
+ }
+ return propMap;
+ }
+
public BooleanType createBoolean (String namespaceURI, String prefix,
String propertyName, boolean value) {
return new BooleanType(metadata, namespaceURI, prefix,propertyName, value);
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Types.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Types.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Types.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Types.java Sat Oct 27 16:07:18 2012
@@ -62,6 +62,10 @@ public enum Types {
return basic==Structured;
}
+ public boolean isDefined() {
+ return this==DefinedType;
+ }
+
public Types getBasic () {
return basic;
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomHelper.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomHelper.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomHelper.java Sat Oct 27 16:07:18 2012
@@ -58,12 +58,12 @@ public final class DomHelper {
}
public static boolean isRdfDescription (Element element) {
- return ("rdf".equals(element.getPrefix()) && "Description".equals(element.getLocalName()));
+ return (XmpConstants.DEFAULT_RDF_PREFIX.equals(element.getPrefix()) && XmpConstants.DESCRIPTION_NAME.equals(element.getLocalName()));
}
public static boolean isParseTypeResource (Element element) {
- Attr parseType = element.getAttributeNodeNS(XmpConstants.RDF_NAMESPACE, "parseType");
- if (parseType!=null && "Resource".equals(parseType.getValue())) {
+ Attr parseType = element.getAttributeNodeNS(XmpConstants.RDF_NAMESPACE, XmpConstants.PARSE_TYPE);
+ if (parseType!=null && XmpConstants.RESOURCE_NAME.equals(parseType.getValue())) {
// parseType resourc
return true;
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomXmpParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomXmpParser.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomXmpParser.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/DomXmpParser.java Sat Oct 27 16:07:18 2012
@@ -28,7 +28,7 @@ import org.apache.padaf.xmpbox.type.Attr
import org.apache.padaf.xmpbox.type.BadFieldValueException;
import org.apache.padaf.xmpbox.type.Cardinality;
import org.apache.padaf.xmpbox.type.ComplexPropertyContainer;
-import org.apache.padaf.xmpbox.type.PropMapping;
+import org.apache.padaf.xmpbox.type.PropertiesDescription;
import org.apache.padaf.xmpbox.type.PropertyType;
import org.apache.padaf.xmpbox.type.TypeMapping;
import org.apache.padaf.xmpbox.type.Types;
@@ -153,8 +153,6 @@ public class DomXmpParser {
try {
List<Element> properties = DomHelper.getElementChildren(description);
for (Element property : properties) {
- String prefix = property.getPrefix();
- String name = property.getLocalName();
String namespace = property.getNamespaceURI();
PropertyType type = checkPropertyDefinition(xmp, DomHelper.getQName(property));
// create the container
@@ -163,55 +161,12 @@ public class DomXmpParser {
}
XMPSchema schema = xmp.getSchema(namespace);
if (schema==null) {
- schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, prefix);
+ schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, property.getPrefix());
}
ComplexPropertyContainer container = schema.getContainer();
-
// create property
- nsFinder.push(property);
- try {
- if (type==null) {
- if (strictParsing) {
- throw new XmpParsingException(ErrorType.InvalidType, "No type defined for {"+namespace+"}"+name);
- } else {
- // use it as string
- manageSimpleType (xmp, property, Types.Text, container);
- }
- } else if (type.type()==Types.LangAlt) {
- manageLangAlt (xmp, property, container);
- } else if (type.card().isArray()) {
- manageArray(xmp,property,type,container);
- } else if (type.type().isSimple()) {
- manageSimpleType (xmp, property, type.type(), container);
- } else if (type.type().isStructured()) {
- if (DomHelper.isParseTypeResource(property)) {
- AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
- ast.setPrefix(prefix);
- container.addProperty(ast);
- } else {
- Element inner = DomHelper.getFirstChildElement(property);
- AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
- ast.setPrefix(prefix);
- container.addProperty(ast);
- }
- } else if (type.type()==Types.DefinedType) {
- if (DomHelper.isParseTypeResource(property)) {
- AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
- ast.setPrefix(prefix);
- container.addProperty(ast);
- } else {
- Element inner = DomHelper.getFirstChildElement(property);
- AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
- ast.setPrefix(prefix);
- container.addProperty(ast);
- }
- }
- } finally {
- nsFinder.pop();
- }
+ createProperty(xmp, property, type, container);
}
- } catch (BadFieldValueException e) {
- throw new XmpParsingException(ErrorType.InvalidType, "Parsing failed", e);
} catch (XmpSchemaException e) {
throw new XmpParsingException(ErrorType.Undefined,"Parsing failed", e);
} finally {
@@ -219,6 +174,56 @@ public class DomXmpParser {
}
}
+
+ private void createProperty (XMPMetadata xmp, Element property, PropertyType type, ComplexPropertyContainer container) throws XmpParsingException {
+ String prefix = property.getPrefix();
+ String name = property.getLocalName();
+ String namespace = property.getNamespaceURI();
+ // create property
+ nsFinder.push(property);
+ try {
+ if (type==null) {
+ if (strictParsing) {
+ throw new XmpParsingException(ErrorType.InvalidType, "No type defined for {"+namespace+"}"+name);
+ } else {
+ // use it as string
+ manageSimpleType (xmp, property, Types.Text, container);
+ }
+ } else if (type.type()==Types.LangAlt) {
+ manageLangAlt (xmp, property, container);
+ } else if (type.card().isArray()) {
+ manageArray(xmp,property,type,container);
+ } else if (type.type().isSimple()) {
+ manageSimpleType (xmp, property, type.type(), container);
+ } else if (type.type().isStructured()) {
+ if (DomHelper.isParseTypeResource(property)) {
+ AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
+ ast.setPrefix(prefix);
+ container.addProperty(ast);
+ } else {
+ Element inner = DomHelper.getFirstChildElement(property);
+ AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
+ ast.setPrefix(prefix);
+ container.addProperty(ast);
+ }
+ } else if (type.type()==Types.DefinedType) {
+ if (DomHelper.isParseTypeResource(property)) {
+ AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
+ ast.setPrefix(prefix);
+ container.addProperty(ast);
+ } else {
+ Element inner = DomHelper.getFirstChildElement(property);
+ AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
+ ast.setPrefix(prefix);
+ container.addProperty(ast);
+ }
+ }
+ } finally {
+ nsFinder.pop();
+ }
+
+ }
+
private void manageSimpleType (XMPMetadata xmp, Element property, Types type, ComplexPropertyContainer container) throws XmpParsingException {
TypeMapping tm = xmp.getTypeMapping();
String prefix = property.getPrefix();
@@ -234,12 +239,11 @@ public class DomXmpParser {
container.addProperty(sp);
}
- private void manageArray (XMPMetadata xmp, Element property, PropertyType type, ComplexPropertyContainer container) throws XmpParsingException, BadFieldValueException {
+ private void manageArray (XMPMetadata xmp, Element property, PropertyType type, ComplexPropertyContainer container) throws XmpParsingException {
TypeMapping tm = xmp.getTypeMapping();
String prefix = property.getPrefix();
String name = property.getLocalName();
String namespace = property.getNamespaceURI();
- // Cardinality at = tm.getArrayType(type);
Element bagOrSeq = DomHelper.getUniqueElementChild(property);
// ensure this is the good type of array
if (bagOrSeq==null) {
@@ -263,7 +267,7 @@ public class DomXmpParser {
}
}
- private void manageLangAlt (XMPMetadata xmp, Element property, ComplexPropertyContainer container) throws XmpParsingException, BadFieldValueException {
+ private void manageLangAlt (XMPMetadata xmp, Element property, ComplexPropertyContainer container) throws XmpParsingException {
manageArray(xmp,property,TypeMapping.createPropertyType(Types.LangAlt, Cardinality.Alt),container);
}
@@ -274,45 +278,12 @@ public class DomXmpParser {
try {
List<Element> properties = DomHelper.getElementChildren(description);
for (Element property : properties) {
- String prefix = property.getPrefix();
String name = property.getLocalName();
- String namespace = property.getNamespaceURI();
PropertyType dtype = checkPropertyDefinition(xmp, DomHelper.getQName(property));
PropertyType ptype = tm.getStructuredPropMapping(dtype.type()).getPropertyType(name);
// create property
- nsFinder.push(property);
- try {
- if (ptype==null) {
- if (strictParsing) {
- throw new XmpParsingException(ErrorType.NoType, "No type defined for {"+namespace+"}"+name);
- } else {
- // use it as string
- manageSimpleType (xmp, property, Types.Text, parentContainer);
- }
- } else if (ptype.type()==Types.LangAlt) {
- manageLangAlt (xmp, property, parentContainer);
- } else if (ptype.card().isArray()) {
- manageArray(xmp,property,ptype,parentContainer);
- } else if (ptype.type().isSimple()) {
- manageSimpleType (xmp, property, ptype.type(), parentContainer);
- } else if (ptype.type().isStructured()) {
- if (DomHelper.isParseTypeResource(property)) {
- AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
- ast.setPrefix(prefix);
- parentContainer.addProperty(ast);
- } else {
- Element inner = DomHelper.getFirstChildElement(property);
- AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
- ast.setPrefix(prefix);
- parentContainer.addProperty(ast);
- }
- }
- } finally {
- nsFinder.pop();
- }
+ createProperty(xmp, property, ptype, parentContainer);
}
- } catch (BadFieldValueException e) {
- throw new XmpParsingException(ErrorType.InvalidType, "Parsing failed", e);
} finally {
nsFinder.pop();
}
@@ -320,7 +291,7 @@ public class DomXmpParser {
- private AbstractField parseLiElement (XMPMetadata xmp, QName descriptor, Element liElement) throws XmpParsingException, BadFieldValueException {
+ private AbstractField parseLiElement (XMPMetadata xmp, QName descriptor, Element liElement) throws XmpParsingException {
if (DomHelper.isParseTypeResource(liElement)) {
return parseLiDescription(xmp, descriptor,liElement);
}
@@ -354,7 +325,7 @@ public class DomXmpParser {
}
}
- private AbstractStructuredType parseLiDescription (XMPMetadata xmp, QName descriptor, Element liElement) throws XmpParsingException, BadFieldValueException {
+ private AbstractStructuredType parseLiDescription (XMPMetadata xmp, QName descriptor, Element liElement) throws XmpParsingException {
TypeMapping tm = xmp.getTypeMapping();
List<Element> elements = DomHelper.getElementChildren(liElement);
if (elements.size()==0) {
@@ -364,37 +335,26 @@ public class DomXmpParser {
// Instantiate abstract structured type with hint from first element
Element first = elements.get(0);
PropertyType ctype = checkPropertyDefinition(xmp, DomHelper.getQName(first));
- AbstractStructuredType ast = instanciateStructured(tm, ctype.type(), descriptor.getLocalPart(),first.getNamespaceURI());
+ Types tt = ctype.type();
+ AbstractStructuredType ast = instanciateStructured(tm, tt, descriptor.getLocalPart(),first.getNamespaceURI());
+
ast.setNamespace(descriptor.getNamespaceURI());
ast.setPrefix(descriptor.getPrefix());
-// TypeDescription<AbstractStructuredType> td = tm.getStructuredDescription(ctype.type());
-// if (td==null) {
-// td = tm.getDefinedDescriptionByNamespace(first.getNamespaceURI());
-// }
- Types tt = ctype.type();
- PropMapping pm;
+ PropertiesDescription pm;
if (tt.isStructured()) {
pm = tm.getStructuredPropMapping(tt);
} else {
- String dt =tm.getDefinedDescriptionByNamespace(first.getNamespaceURI());
-// pm = tm.getDefinedDescription(dt).getProperties();
- pm = tm.getDefinedPropMapping(dt);
+ pm = tm.getDefinedDescriptionByNamespace(first.getNamespaceURI());
}
for (Element element : elements) {
String prefix = element.getPrefix();
String name = element.getLocalName();
String namespace = element.getNamespaceURI();
PropertyType type = pm.getPropertyType(name);
- if (type.type().isSimple()) {
- AbstractSimpleProperty sp = tm.instanciateSimpleProperty(
- namespace,
- prefix,
- name,
- element.getTextContent(),
- type.type());
- loadAttributes(sp,element);
- ast.getContainer().addProperty(sp);
+ if (type==null) {
+ // not defined
+ throw new XmpParsingException(ErrorType.NoType, "Type '"+name+"' not defined in "+element.getNamespaceURI());
} else if (type.card().isArray()) {
ArrayProperty array = tm.createArrayProperty(namespace, prefix, name, type.card());
ast.getContainer().addProperty(array);
@@ -408,6 +368,15 @@ public class DomXmpParser {
array.addProperty(ast2);
}
}
+ } else if (type.type().isSimple()) {
+ AbstractSimpleProperty sp = tm.instanciateSimpleProperty(
+ namespace,
+ prefix,
+ name,
+ element.getTextContent(),
+ type.type());
+ loadAttributes(sp,element);
+ ast.getContainer().addProperty(sp);
} else if (type.type().isStructured()) {
// create a new structured type
AbstractStructuredType inner = instanciateStructured(tm, type.type(), name,null);
@@ -550,12 +519,17 @@ public class DomXmpParser {
// end of document
}
- private AbstractStructuredType instanciateStructured (TypeMapping tm, Types type, String name, String structuredNamespace) throws BadFieldValueException {
- if (type.isStructured()) {
- return tm.instanciateStructuredType(type,null,name);
- } else {
- String dt = tm.getDefinedDescriptionByNamespace(structuredNamespace);
- return tm.instanciateStructuredType(Types.DefinedType, dt, name);
+ private AbstractStructuredType instanciateStructured (TypeMapping tm, Types type, String name, String structuredNamespace) throws XmpParsingException {
+ try {
+ if (type.isStructured()) {
+ return tm.instanciateStructuredType(type,name);
+ } else if (type.isDefined()) {
+ return tm.instanciateDefinedType(name, structuredNamespace);
+ } else {
+ throw new XmpParsingException(ErrorType.InvalidType, "Type not structured : "+type);
+ }
+ } catch (BadFieldValueException e) {
+ throw new XmpParsingException(ErrorType.InvalidType, "Parsing failed", e);
}
}
@@ -567,15 +541,8 @@ public class DomXmpParser {
}
// test if namespace is defined
String nsuri = prop.getNamespaceURI();
- if (!tm.isDefinedSchema(nsuri)) {
- if (!tm.isStructuredTypeNamespace(nsuri) && !tm.isDefinedTypeNamespace(nsuri)) {
-// // structured exists
-// } else if () {
-// // defined
-// } else {
- // not structured and not defind
- throw new XmpParsingException(ErrorType.NoSchema, "Cannot find a definition for the namespace "+prop.getNamespaceURI());
- }
+ if (!tm.isDefinedNamespace(nsuri)) {
+ throw new XmpParsingException(ErrorType.NoSchema, "Cannot find a definition for the namespace "+prop.getNamespaceURI());
}
try {
return tm.getSpecifiedPropertyType(prop);
@@ -607,17 +574,6 @@ public class DomXmpParser {
return stack.pop();
}
- protected String getNamespaceURI (String prefix) throws XmpParsingException {
- for (int i=stack.size()-1; i>=0; i--) {
- Map<String,String> map = stack.get(i);
- if (map.containsKey(prefix)) {
- // found the namespace
- return map.get(prefix);
- }
- }
- throw new XmpParsingException (ErrorType.NoSchema, "No namespace linked with prefix '"+prefix+"'");
- }
-
protected boolean containsNamespace (String namespace) {
for (int i=stack.size()-1; i>=0; i--) {
Map<String,String> map = stack.get(i);
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/PdfaExtensionHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/PdfaExtensionHelper.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/PdfaExtensionHelper.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/PdfaExtensionHelper.java Sat Oct 27 16:07:18 2012
@@ -16,7 +16,7 @@ import org.apache.padaf.xmpbox.type.PDFA
import org.apache.padaf.xmpbox.type.PDFAPropertyType;
import org.apache.padaf.xmpbox.type.PDFASchemaType;
import org.apache.padaf.xmpbox.type.PDFATypeType;
-import org.apache.padaf.xmpbox.type.PropMapping;
+import org.apache.padaf.xmpbox.type.PropertiesDescription;
import org.apache.padaf.xmpbox.type.PropertyType;
import org.apache.padaf.xmpbox.type.StructuredType;
import org.apache.padaf.xmpbox.type.TypeMapping;
@@ -127,12 +127,10 @@ public final class PdfaExtensionHelper {
}
}
// add the structured type to list
-// TypeDescription<AbstractStructuredType> td = new TypeDescription<AbstractStructuredType>(tm,Types.DefinedType);
- PropMapping pm = new PropMapping(structuredType.getNamespace());
+ PropertiesDescription pm = new PropertiesDescription();
for (Map.Entry<String, PropertyType> entry : structuredType.getDefinedProperties().entrySet()) {
pm.addNewProperty(entry.getKey(), entry.getValue());
}
-// td.setProperties(pm);
tm.addToDefinedStructuredTypes(ttype, tns,pm);
}
}
@@ -184,7 +182,6 @@ public final class PdfaExtensionHelper {
} else if ("alt".equals(scard)) {
card = Cardinality.Alt;
} else {
-// throw new XmpParsingException(ErrorType.NoValueType, "Invalid type definition : "+valueType);
return null;
}
}
@@ -194,7 +191,6 @@ public final class PdfaExtensionHelper {
type = pos<0?Types.valueOf(valueType):Types.valueOf(vt);
} catch (IllegalArgumentException e) {
if (tm.isDefinedType(vt)) {
-// type = tm.getDefinedDescription(vt).getType();
type = Types.DefinedType;
}
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/XmpSerializer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/XmpSerializer.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/XmpSerializer.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/xml/XmpSerializer.java Sat Oct 27 16:07:18 2012
@@ -109,7 +109,7 @@ public class XmpSerializer {
// attributes
fillElementWithAttributes(asimple, array);
// the array definition
- Element econtainer = doc.createElement("rdf"+":"+array.getArrayType());
+ Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX+":"+array.getArrayType());
asimple.appendChild(econtainer);
// for each element of the array
List<AbstractField> innerFields = array.getAllProperties();
@@ -126,7 +126,7 @@ public class XmpSerializer {
}
// element li
- Element estructured = doc.createElement("rdf"+":"+"li");
+ Element estructured = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX+":"+XmpConstants.LIST_NAME);
listParent.appendChild(estructured);
if (parseTypeResourceForLi) {
estructured.setAttribute("rdf:parseType", "Resource");
@@ -134,7 +134,7 @@ public class XmpSerializer {
serializeFields(doc, estructured, innerFields, true);
} else {
// element description
- Element econtainer = doc.createElement("rdf"+":"+"Description");
+ Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX+":"+"Description");
estructured.appendChild(econtainer);
// all properties
serializeFields(doc, econtainer, innerFields, true);
@@ -153,7 +153,7 @@ public class XmpSerializer {
if (target.getNamespaceURI().equals(attribute.getNamespace())) {
target.setAttribute(attribute.getName(), attribute.getValue());
} else if (XmpConstants.RDF_NAMESPACE.equals(attribute.getNamespace())) {
- target.setAttribute("rdf"+":"+attribute.getName(), attribute.getValue());
+ target.setAttribute(XmpConstants.DEFAULT_RDF_PREFIX+":"+attribute.getName(), attribute.getValue());
} else {
target.setAttribute(attribute.getName(), attribute.getValue());
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java Sat Oct 27 16:07:18 2012
@@ -30,6 +30,8 @@ import org.apache.padaf.xmpbox.XMPMetada
import org.apache.padaf.xmpbox.schema.DublinCoreSchema;
import org.apache.padaf.xmpbox.type.ThumbnailType;
import org.apache.padaf.xmpbox.xml.DomXmpParser;
+import org.apache.padaf.xmpbox.xml.XmpParsingException;
+import org.apache.padaf.xmpbox.xml.XmpParsingException.ErrorType;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -44,7 +46,7 @@ public class DeserializationTest {
}
-
+
@Test
public void testStructuredRecursive () throws Exception {
InputStream fis = DomXmpParser.class
@@ -53,7 +55,7 @@ public class DeserializationTest {
DomXmpParser xdb = new DomXmpParser();
xdb.parse(fis);
-
+
}
@Test
@@ -64,7 +66,7 @@ public class DeserializationTest {
DomXmpParser xdb = new DomXmpParser();
xdb.parse(fis);
-
+
}
@Test
@@ -92,7 +94,7 @@ public class DeserializationTest {
Assert.assertEquals("title value", s);
}
-
+
@Test
public void testAltBagSeq() throws Exception {
InputStream fis = DomXmpParser.class
@@ -154,4 +156,131 @@ public class DeserializationTest {
}
+
+ @Test
+ public void testWithNoXPacketStart () throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/noxpacket.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.XpacketBadStart, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testWithNoXPacketEnd () throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/noxpacketend.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.XpacketBadEnd, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testWithNoRDFElement () throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/noroot.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testWithTwoRDFElement () throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/tworoot.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testWithInvalidRDFElementPrefix () throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/invalidroot2.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testWithRDFRootAsText() throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/invalidroot.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testUndefinedSchema() throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/undefinedschema.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.NoSchema, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testUndefinedPropertyWithDefinedSchema() throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/undefinedpropertyindefinedschema.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.NoType, e.getErrorType());
+ }
+ }
+
+ @Test
+ public void testUndefinedStructuredWithDefinedSchema() throws Exception {
+ InputStream fis = DomXmpParser.class
+ .getResourceAsStream("/invalidxmp/undefinedstructuredindefinedschema.xml");
+
+ DomXmpParser xdb = new DomXmpParser();
+ try {
+ xdb.parse(fis);
+ Assert.fail("Should fail during parse");
+ } catch (XmpParsingException e) {
+ Assert.assertEquals(ErrorType.NoValueType, e.getErrorType());
+ }
+ }
+
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/PropMappingTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/PropMappingTest.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/PropMappingTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/PropMappingTest.java Sat Oct 27 16:07:18 2012
@@ -23,23 +23,18 @@ package org.apache.padaf.xmpbox.parser;
import junit.framework.Assert;
-import org.apache.padaf.xmpbox.type.PropMapping;
+import org.apache.padaf.xmpbox.type.PropertiesDescription;
import org.junit.Before;
import org.junit.Test;
public class PropMappingTest {
- protected PropMapping propMap;
+ protected PropertiesDescription propMap;
protected String nsURI = "http://www.test.org/PropMap#";
@Before
public void init() {
- propMap = new PropMapping(nsURI);
- }
-
- @Test
- public void testURI() {
- Assert.assertEquals(nsURI, propMap.getConcernedNamespace());
+ propMap = new PropertiesDescription();
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java?rev=1402816&r1=1402815&r2=1402816&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java Sat Oct 27 16:07:18 2012
@@ -70,7 +70,7 @@ public final class TypeTestingHelper {
} else if (TextType.class.isAssignableFrom(type.getImplementingClass())) {
return String.class;
} else {
- throw new IllegalArgumentException("TODO : type not expected in test : "+type.getImplementingClass());
+ throw new IllegalArgumentException("Type not expected in test : "+type.getImplementingClass());
}
}
@@ -89,7 +89,7 @@ public final class TypeTestingHelper {
// all derived from TextType
return UUID.randomUUID().toString();
} else {
- throw new IllegalArgumentException("TODO : type not expected in test : "+type.getImplementingClass());
+ throw new IllegalArgumentException("Type not expected in test : "+type.getImplementingClass());
}
}
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,17 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 ">
+A text value
+</x:xmpmeta>
+<?xpacket end='r'?>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot2.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot2.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot2.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/invalidroot2.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,17 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 ">
+<rdfa:RDF xmlns:rdfa="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
+</x:xmpmeta>
+<?xpacket end='r'?>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noroot.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noroot.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noroot.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noroot.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,16 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 ">
+</x:xmpmeta>
+<?xpacket end='r'?>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacket.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacket.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacket.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacket.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,30 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 ">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about=""
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:format>application/pdf</dc:format>
+ <dc:title>
+ <rdf:Alt>
+ <rdf:li xml:lang="x-default">title value</rdf:li>
+ </rdf:Alt>
+ </dc:title>
+ <dc:creator>
+ <rdf:Seq>
+ <rdf:li/>
+ </rdf:Seq>
+ </dc:creator>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacketend.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacketend.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacketend.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/noxpacketend.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,31 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 ">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about=""
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:format>application/pdf</dc:format>
+ <dc:title>
+ <rdf:Alt>
+ <rdf:li xml:lang="x-default">title value</rdf:li>
+ </rdf:Alt>
+ </dc:title>
+ <dc:creator>
+ <rdf:Seq>
+ <rdf:li/>
+ </rdf:Seq>
+ </dc:creator>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/tworoot.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/tworoot.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/tworoot.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/tworoot.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,18 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 ">
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
+</x:xmpmeta>
+<?xpacket end='r'?>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedpropertyindefinedschema.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedpropertyindefinedschema.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedpropertyindefinedschema.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedpropertyindefinedschema.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,81 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about=""
+ xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
+ xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"
+ xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#"
+ xmlns:pdfaType="http://www.aiim.org/pdfa/ns/type#" xmlns:pdfaField="http://www.aiim.org/pdfa/ns/field#">
+ <pdfaExtension:schemas>
+ <rdf:Bag>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaSchema:schema>ACME E-Mail Schema</pdfaSchema:schema>
+ <pdfaSchema:namespaceURI>http://www.acme.com/ns/email/1/</pdfaSchema:namespaceURI>
+ <pdfaSchema:prefix>acmeemail</pdfaSchema:prefix>
+ <pdfaSchema:property>
+ <rdf:Seq>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaProperty:name>Delivery-Date</pdfaProperty:name>
+ <pdfaProperty:valueType>Date</pdfaProperty:valueType>
+ <pdfaProperty:category>internal</pdfaProperty:category>
+ <pdfaProperty:description>date of email delivery</pdfaProperty:description>
+ </rdf:li>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaProperty:name>From</pdfaProperty:name>
+ <pdfaProperty:valueType>mailaddress</pdfaProperty:valueType>
+ <pdfaProperty:category>internal</pdfaProperty:category>
+ <pdfaProperty:description>sender email address</pdfaProperty:description>
+ </rdf:li>
+ </rdf:Seq>
+ </pdfaSchema:property>
+ <pdfaSchema:valueType>
+ <rdf:Seq>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaType:type>mailaddress</pdfaType:type>
+ <pdfaType:namespaceURI>http://www.acme.com/ns/email/1/mailaddress/</pdfaType:namespaceURI>
+ <pdfaType:description>mailaddress value</pdfaType:description>
+ <pdfaType:prefix>add</pdfaType:prefix>
+ <pdfaType:field>
+ <rdf:Seq>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaField:name>name</pdfaField:name>
+ <pdfaField:valueType>Text</pdfaField:valueType>
+ <pdfaField:description>plaintext name</pdfaField:description>
+ </rdf:li>
+<!-- <rdf:li rdf:parseType="Resource"> -->
+<!-- <pdfaField:name>mailto</pdfaField:name> -->
+<!-- <pdfaField:valueType>Text</pdfaField:valueType> -->
+<!-- <pdfaField:description>email address</pdfaField:description> -->
+<!-- </rdf:li> -->
+ </rdf:Seq>
+ </pdfaType:field>
+ </rdf:li>
+ </rdf:Seq>
+ </pdfaSchema:valueType>
+ </rdf:li>
+ </rdf:Bag>
+ </pdfaExtension:schemas>
+ </rdf:Description>
+ <rdf:Description rdf:about=""
+ xmlns:acmeemail="http://www.acme.com/ns/email/1/" xmlns:add="http://www.acme.com/ns/email/1/mailaddress/">
+ <acmeemail:Delivery-Date>2007-11-09T09:55:36+01:00</acmeemail:Delivery-Date>
+ <acmeemail:From rdf:parseType="Resource">
+ <add:name>John Doe</add:name>
+ <add:mailto>john@acme.com</add:mailto>
+ </acmeemail:From>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
+<?xpacket end='r'?>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedschema.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedschema.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedschema.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedschema.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,26 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about=""
+ xmlns:acmeemail="http://www.acme.com/ns/email/1/" xmlns:add="http://www.acme.com/ns/email/1/mailaddress/">
+ <acmeemail:Delivery-Date>2007-11-09T09:55:36+01:00</acmeemail:Delivery-Date>
+ <acmeemail:From rdf:parseType="Resource">
+ <add:name>John Doe</add:name>
+ <add:mailto>john@acme.com</add:mailto>
+ </acmeemail:From>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
+<?xpacket end='r'?>
+
Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedstructuredindefinedschema.xml
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedstructuredindefinedschema.xml?rev=1402816&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedstructuredindefinedschema.xml (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/resources/invalidxmp/undefinedstructuredindefinedschema.xml Sat Oct 27 16:07:18 2012
@@ -0,0 +1,57 @@
+<!-- ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements. See the NOTICE file distributed with !
+ this work for additional information regarding copyright ownership. ! The
+ ASF licenses this file to You under the Apache License, Version 2.0 ! (the
+ "License"); you may not use this file except in compliance with ! the License.
+ You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0
+ ! ! Unless required by applicable law or agreed to in writing, software !
+ distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the
+ License for the specific language governing permissions and ! limitations
+ under the License. ! -->
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about=""
+ xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
+ xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#"
+ xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#"
+ xmlns:pdfaType="http://www.aiim.org/pdfa/ns/type#" xmlns:pdfaField="http://www.aiim.org/pdfa/ns/field#">
+ <pdfaExtension:schemas>
+ <rdf:Bag>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaSchema:schema>ACME E-Mail Schema</pdfaSchema:schema>
+ <pdfaSchema:namespaceURI>http://www.acme.com/ns/email/1/</pdfaSchema:namespaceURI>
+ <pdfaSchema:prefix>acmeemail</pdfaSchema:prefix>
+ <pdfaSchema:property>
+ <rdf:Seq>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaProperty:name>Delivery-Date</pdfaProperty:name>
+ <pdfaProperty:valueType>Date</pdfaProperty:valueType>
+ <pdfaProperty:category>internal</pdfaProperty:category>
+ <pdfaProperty:description>date of email delivery</pdfaProperty:description>
+ </rdf:li>
+ <rdf:li rdf:parseType="Resource">
+ <pdfaProperty:name>From</pdfaProperty:name>
+ <pdfaProperty:valueType>mailaddress</pdfaProperty:valueType>
+ <pdfaProperty:category>internal</pdfaProperty:category>
+ <pdfaProperty:description>sender email address</pdfaProperty:description>
+ </rdf:li>
+ </rdf:Seq>
+ </pdfaSchema:property>
+ </rdf:li>
+ </rdf:Bag>
+ </pdfaExtension:schemas>
+ </rdf:Description>
+ <rdf:Description rdf:about=""
+ xmlns:acmeemail="http://www.acme.com/ns/email/1/" xmlns:add="http://www.acme.com/ns/email/1/mailaddress/">
+ <acmeemail:Delivery-Date>2007-11-09T09:55:36+01:00</acmeemail:Delivery-Date>
+ <acmeemail:From rdf:parseType="Resource">
+ <add:name>John Doe</add:name>
+ <add:mailto>john@acme.com</add:mailto>
+ </acmeemail:From>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
+<?xpacket end='r'?>
+