// XML
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
// Avalon
import org.apache.avalon.framework.logger.Logger;
name = str;
}
+ /**
+ * Sets the name of the node.
+ * @param str the name
+ */
+ public void setLocation(Locator locator) {
+ // do nothing by default
+ }
+
/**
* Returns the logger for the node.
* @return the logger
* @param data text
* @param start start position
* @param length length of the text
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
// ignore
}
import org.apache.fop.fo.ElementMapping.Maker;
import org.apache.fop.fo.pagination.Root;
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/** The FOTreeControl object managing the FO Tree that is being built */
public FOTreeControl foTreeControl;
+ /** The SAX locator object maneging the line and column counters */
+ private Locator locator;
+
/**
* Default constructor
*/
}
}
+ /**
+ * SAX Handler for locator
+ * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
+ */
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
/**
* SAX Handler for characters
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
public void characters(char data[], int start, int length) {
if (currentFObj != null) {
- currentFObj.addCharacters(data, start, start + length);
+ currentFObj.addCharacters(data, start, start + length, locator);
}
}
try {
fobj = fobjMaker.make(currentFObj);
fobj.setName(localName);
+ fobj.setLocation(locator);
fobj.handleAttrs(attlist);
} catch (FOPException e) {
throw new SAXException(e);
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.properties.FOPropertyMapping;
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
/**
* Base class for representation of formatting objects and their processing.
name = "fo:" + str;
}
+ public void setLocation(Locator locator) {
+ line = locator.getLineNumber();
+ column = locator.getColumnNumber();
+ systemId = locator.getSystemId();
+ }
+
/**
* Handle the attributes for this element.
* The attributes must be used immediately as the sax attributes
public void acceptVisitor(FOTreeVisitor fotv) {
fotv.serveFObj(this);
}
+
+ /**
+ * Return a string representation of the fo element.
+ */
+ public String toString() {
+ return getName() + " at line " + line + ":" + column;
+ }
+
}
*/
package org.apache.fop.fo;
+import org.xml.sax.Locator;
+
/**
* Base class for representation of mixed content formatting objects
* and their processing
* @param data array of characters containing text to be added
* @param start starting array element to add
* @param length number of characters to add
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
if (textInfo == null) {
// Really only need one of these, but need to get fontInfo
// stored in propMgr for later use.
}
FOText ft = new FOText(data, start, length, textInfo, this);
+ ft.setLocation(locator);
+ ft.setName("text");
/* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */
getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, ft.length);
*/
package org.apache.fop.fo;
+import org.xml.sax.Locator;
+
/**
* Class for handling generic XML from a namespace not recognized by FOP
*/
/**
* @see XMLObj#addCharacters
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
if (doc == null) {
createBasicDocument();
}
- super.addCharacters(data, start, length);
+ super.addCharacters(data, start, length, locator);
}
/**
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import javax.xml.parsers.DocumentBuilderFactory;
// FOP
* @param data array of characters contaning the text to add
* @param start starting array element to add
* @param length number of characters from the array to add
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
String str = new String(data, start, length - start);
org.w3c.dom.Text text = doc.createTextNode(str);
element.appendChild(text);
*/
package org.apache.fop.fo.extensions;
+import org.xml.sax.Locator;
+
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
* @param data the character data
* @param start the start position in the data array
* @param end the end position in the character array
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int end) {
+ protected void addCharacters(char data[], int start, int end,
+ Locator locator) {
label += new String(data, start, end - start);
}