Author: jeremias
Date: Thu Feb 7 02:59:19 2008
New Revision: 619359
URL: http://svn.apache.org/viewvc?rev=619359&view=rev
Log:
Fop's QName now extends XGCommons' QName to initiate a transition.
Hooked PropertyList into the event mechanism.
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/ElementMapping.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOElementMapping.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/PropertyList.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/QName.java
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
Thu Feb 7 02:59:19 2008
@@ -27,4 +27,7 @@
Any reference to it will be considered a reference to the first occurrence in
the document.[ See position {loc}.]</message>
<message
key="org.apache.fop.fo.FOValidationEventProducer.markerNotInitialChild">fo:marker
must be an initial child: {mcname}[ (See position {loc}.)]</message>
<message
key="org.apache.fop.fo.FOValidationEventProducer.markerNotUniqueForSameParent">fo:marker
"marker-class-name" must be unique for same parent: {mcname}[ (See position
{loc}.)]</message>
+ <message
key="org.apache.fop.fo.FOValidationEventProducer.invalidProperty">Invalid
property encountered on "{elementName}": {attr}[ (See position
{loc}.)]</message>
+ <message
key="org.apache.fop.fo.FOValidationEventProducer.invalidPropertyWarning">Invalid
property ignored on "{elementName}": {attr}[ (See position {loc}.)]</message>
+ <message
key="org.apache.fop.fo.FOValidationEventProducer.invalidPropertyValue">Invalid
property value encountered in {propName}="{propValue}": {e}[ (See position
{loc}.)]</message>
</catalogue>
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/ElementMapping.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/ElementMapping.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/ElementMapping.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/ElementMapping.java
Thu Feb 7 02:59:19 2008
@@ -24,8 +24,9 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.fop.util.QName;
import org.w3c.dom.DOMImplementation;
+
+import org.apache.xmlgraphics.util.QName;
/**
* Abstract base class for Element Mappings (including FO Element Mappings)
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOElementMapping.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOElementMapping.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOElementMapping.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOElementMapping.java
Thu Feb 7 02:59:19 2008
@@ -22,7 +22,7 @@
// Java
import java.util.HashMap;
-import org.apache.fop.util.QName;
+import org.apache.xmlgraphics.util.QName;
/**
* Element mapping class for all XSL-FO elements.
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java
Thu Feb 7 02:59:19 2008
@@ -25,6 +25,7 @@
import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.events.EventProducer;
+import org.apache.fop.fo.expr.PropertyException;
/**
* Event producer interface for XSL-FO validation messages.
@@ -148,5 +149,42 @@
*/
void markerNotUniqueForSameParent(Object source, String elementName,
String mcname, Locator loc);
+
+ /**
+ * An invalid property was found.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param attr the invalid attribute
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method
call
+ * @event.severity FATAL
+ */
+ void invalidProperty(Object source, String elementName, QName attr,
+ Locator loc) throws ValidationException;
+
+ /**
+ * An invalid property was encountered.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param attr the invalid attribute
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void invalidPropertyWarning(Object source, String elementName, QName attr,
+ Locator loc);
+
+ /**
+ * An invalid property value was encountered.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param propName the property name
+ * @param propValue the property value
+ * @param e the property exception caused by the invalid value
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void invalidPropertyValue(Object source, String elementName,
+ String propName, String propValue, PropertyException e,
+ Locator loc);
}
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java
Thu Feb 7 02:59:19 2008
@@ -30,11 +30,12 @@
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.properties.PropertyMaker;
-import org.apache.fop.util.QName;
/**
* Base class for representation of formatting objects and their processing.
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/PropertyList.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/PropertyList.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/PropertyList.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/PropertyList.java
Thu Feb 7 02:59:19 2008
@@ -20,13 +20,13 @@
package org.apache.fop.fo;
// Java
-import java.text.MessageFormat;
-
import org.xml.sax.Attributes;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.apps.FopFactory;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.properties.CommonAbsolutePosition;
@@ -41,7 +41,6 @@
import org.apache.fop.fo.properties.CommonTextDecoration;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.PropertyMaker;
-import org.apache.fop.util.QName;
/**
* Class containing the collection of properties for a given FObj.
@@ -319,20 +318,18 @@
} else if (!factory.isNamespaceIgnored(attributeNS)) {
ElementMapping mapping =
factory.getElementMappingRegistry().getElementMapping(
attributeNS);
+ QName attr = new QName(attributeNS, attributeName);
if (mapping != null) {
- QName attName = new QName(attributeNS, attributeName);
- if (mapping.isAttributeProperty(attName)
+ if (mapping.isAttributeProperty(attr)
&& mapping.getStandardPrefix() != null) {
convertAttributeToProperty(attributes,
- mapping.getStandardPrefix() + ":" +
attName.getLocalName(),
+ mapping.getStandardPrefix() + ":" +
attr.getLocalName(),
attributeValue);
} else {
- getFObj().addForeignAttribute(attName, attributeValue);
+ getFObj().addForeignAttribute(attr, attributeValue);
}
} else {
- handleInvalidProperty(
- "Error processing foreign attribute: "
- + attributeNS + "/@" + attributeName,
attributeName);
+ handleInvalidProperty(attr);
}
}
}
@@ -343,11 +340,8 @@
* @param propertyName the property name to check
* @return true if the base property name and the subproperty name (if any)
* can be correctly mapped to an id
- * @throws ValidationException in case the property name
- * is invalid for the FO namespace
*/
- protected boolean isValidPropertyName(String propertyName)
- throws ValidationException {
+ protected boolean isValidPropertyName(String propertyName) {
int propId = FOPropertyMapping.getPropertyId(
findBasePropertyName(propertyName));
@@ -357,9 +351,6 @@
if (propId == -1
|| (subpropId == -1
&& findSubPropertyName(propertyName) != null)) {
- String errorMessage = MessageFormat.format(
- "Invalid property name ''{0}''.", new Object[]
{propertyName});
- handleInvalidProperty(errorMessage, propertyName);
return false;
}
return true;
@@ -380,19 +371,18 @@
if (attributeValue != null) {
- if (!isValidPropertyName(attributeName)) {
- //will log an error or throw an exception
- return;
- }
- FObj parentFO = fobj.findNearestAncestorFObj();
-
-
/* Handle "compound" properties, ex. space-before.minimum */
String basePropertyName = findBasePropertyName(attributeName);
String subPropertyName = findSubPropertyName(attributeName);
int propId = FOPropertyMapping.getPropertyId(basePropertyName);
int subpropId =
FOPropertyMapping.getSubPropertyId(subPropertyName);
+
+ if (propId == -1
+ || (subpropId == -1 && subPropertyName != null)) {
+ handleInvalidProperty(new QName(null, attributeName));
+ }
+ FObj parentFO = fobj.findNearestAncestorFObj();
PropertyMaker propertyMaker = findMaker(propId);
if (propertyMaker == null) {
@@ -415,8 +405,8 @@
}
prop = propertyMaker.make(this, attributeValue, parentFO);
} else { // e.g. "leader-length.maximum"
- Property baseProperty =
- findBaseProperty(attributes, parentFO, propId,
+ Property baseProperty
+ = findBaseProperty(attributes, parentFO, propId,
basePropertyName, propertyMaker);
prop = propertyMaker.make(baseProperty, subpropId,
this, attributeValue, parentFO);
@@ -425,8 +415,8 @@
putExplicit(propId, prop);
}
} catch (PropertyException e) {
- log.error("Ignoring property: "
- + attributeName + "=\"" + attributeValue + "\" (" +
e.getMessage() + ")");
+ fobj.getFOValidationEventProducer().invalidPropertyValue(this,
fobj.getName(),
+ attributeName, attributeValue, e, fobj.locator);
}
}
}
@@ -463,17 +453,20 @@
}
/**
- * @param message ...
- * @param propName ...
- * @throws ValidationException ...
+ * Handles an invalid property.
+ * @param attr the invalid attribute
+ * @throws ValidationException if an exception needs to be thrown
depending on the
+ * validation settings
*/
- protected void handleInvalidProperty(String message, String propName)
+ protected void handleInvalidProperty(QName attr)
throws ValidationException {
- if (!propName.startsWith("xmlns")) {
+ if (!attr.getQName().startsWith("xmlns")) {
if (fobj.getUserAgent().validateStrictly()) {
- fobj.attributeError(message);
+ fobj.getFOValidationEventProducer().invalidProperty(this,
fobj.getName(),
+ attr, fobj.locator);
} else {
- log.error(message + " Property ignored.");
+
fobj.getFOValidationEventProducer().invalidPropertyWarning(this, fobj.getName(),
+ attr, fobj.locator);
}
}
}
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
Thu Feb 7 02:59:19 2008
@@ -19,14 +19,15 @@
package org.apache.fop.fo.extensions;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.apache.xmlgraphics.util.QName;
+
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.UnknownXMLObj;
import org.apache.fop.fo.extensions.destination.Destination;
-import org.apache.fop.util.QName;
-
-import java.util.HashMap;
-import java.util.Set;
/**
* Element mapping for FOP's proprietary extension to XSL-FO.
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/QName.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/QName.java?rev=619359&r1=619358&r2=619359&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/QName.java
(original)
+++
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/QName.java
Thu Feb 7 02:59:19 2008
@@ -19,23 +19,16 @@
package org.apache.fop.util;
-import java.io.Serializable;
-
/**
* Represents a qualified name of an XML element or an XML attribute.
* <p>
* Note: This class allows to carry a namespace prefix but it is not used in
the equals() and
* hashCode() methods.
*/
-public class QName implements Serializable {
+public class QName extends org.apache.xmlgraphics.util.QName {
private static final long serialVersionUID = -5225376740044770690L;
- private String namespaceURI;
- private String localName;
- private String prefix;
- private int hashCode;
-
/**
* Main constructor.
* @param namespaceURI the namespace URI
@@ -43,16 +36,7 @@
* @param localName the local name
*/
public QName(String namespaceURI, String prefix, String localName) {
- if (localName == null) {
- throw new NullPointerException("Parameter localName must not be
null");
- }
- if (localName.length() == 0) {
- throw new IllegalArgumentException("Parameter localName must not
be empty");
- }
- this.namespaceURI = namespaceURI;
- this.prefix = prefix;
- this.localName = localName;
- this.hashCode = toHashString().hashCode();
+ super(namespaceURI, prefix, localName);
}
/**
@@ -61,78 +45,7 @@
* @param qName the qualified name
*/
public QName(String namespaceURI, String qName) {
- if (qName == null) {
- throw new NullPointerException("Parameter localName must not be
null");
- }
- if (qName.length() == 0) {
- throw new IllegalArgumentException("Parameter localName must not
be empty");
- }
- this.namespaceURI = namespaceURI;
- int p = qName.indexOf(':');
- if (p > 0) {
- this.prefix = qName.substring(0, p);
- this.localName = qName.substring(p + 1);
- } else {
- this.prefix = null;
- this.localName = qName;
- }
- this.hashCode = toHashString().hashCode();
+ super(namespaceURI, qName);
}
- /** @return the namespace URI */
- public String getNamespaceURI() {
- return this.namespaceURI;
- }
-
- /** @return the namespace prefix */
- public String getPrefix() {
- return this.prefix;
- }
-
- /** @return the local name */
- public String getLocalName() {
- return this.localName;
- }
-
- /** @return the fully qualified name */
- public String getQName() {
- return getPrefix() != null ? getPrefix() + ':' + getLocalName() :
getLocalName();
- }
-
- /** [EMAIL PROTECTED] */
- public int hashCode() {
- return this.hashCode;
- }
-
- /** [EMAIL PROTECTED] */
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- } else if (obj == this) {
- return true;
- } else {
- if (obj instanceof QName) {
- QName other = (QName)obj;
- if ((getNamespaceURI() == null && other.getNamespaceURI() ==
null)
- || getNamespaceURI().equals(other.getNamespaceURI())) {
- return getLocalName().equals(other.getLocalName());
- }
- }
- }
- return false;
- }
-
- /** [EMAIL PROTECTED] */
- public String toString() {
- return prefix != null
- ? (prefix + ":" + localName)
- : toHashString();
- }
-
- private String toHashString() {
- return (namespaceURI != null
- ? ("{" + namespaceURI + "}" + localName)
- : localName);
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]