package org.apache.fop.apps;
// SAX
-import org.xml.sax.Parser;
+import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
*
* @return the created SAX parser
*/
- static Parser createParser() {
+ static XMLReader createParser() {
String parserClassName =
System.getProperty("org.xml.sax.parser");
if (parserClassName == null) {
org.apache.fop.messaging.MessageHandler.logln("using SAX parser " + parserClassName);
try {
- return (Parser)
+ return (XMLReader)
Class.forName(parserClassName).newInstance();
} catch (ClassNotFoundException e) {
org.apache.fop.messaging.MessageHandler.errorln("Could not find " + parserClassName);
System.exit(1);
}
- Parser parser = createParser();
+ XMLReader parser = createParser();
if (parser == null) {
MessageHandler.errorln("ERROR: Unable to create SAX parser");
import org.w3c.dom.Attr;
// SAX
-import org.xml.sax.DocumentHandler;
+import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
-import org.xml.sax.Parser;
+import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributeListImpl;
+import org.xml.sax.helpers.AttributesImpl;
// Java
import java.io.PrintWriter;
* SAX parser. A good example is an XSLT engine that fires SAX
* events but isn't a SAX Parser itself.
*/
- public DocumentHandler getDocumentHandler() {
+ public ContentHandler getContentHandler() {
return this.treeBuilder;
}
* build the formatting object tree using the given SAX Parser and
* SAX InputSource
*/
- public void buildFOTree(Parser parser, InputSource source)
- throws FOPException {
- parser.setDocumentHandler(this.treeBuilder);
+ public void buildFOTree(XMLReader parser, InputSource source)
+ throws FOPException {
+
+ parser.setContentHandler(this.treeBuilder);
try {
parser.parse(source);
} catch (SAXException e) {
/* most of this code is modified from John Cowan's */
Node currentNode;
- AttributeListImpl currentAtts;
+ AttributesImpl currentAtts;
/* temporary array for making Strings into character arrays */
char[] array = null;
- currentAtts = new AttributeListImpl();
+ currentAtts = new AttributesImpl();
/* start at the document element */
currentNode = document;
NamedNodeMap map = currentNode.getAttributes();
currentAtts.clear();
for (int i = map.getLength() - 1; i >= 0; i--) {
- Attr att = (Attr)(map.item(i));
- currentAtts.addAttribute(att.getName(),
- "CDATA",
- att.getValue());
+ Attr att = (Attr)map.item(i);
+ currentAtts.addAttribute("",
+ att.getName(),
+ "",
+ "CDATA",
+ att.getValue());
}
this.treeBuilder.startElement(
- currentNode.getNodeName(), currentAtts);
+ "", currentNode.getNodeName(), "", currentAtts);
break;
}
break;
case Node.ELEMENT_NODE:
this.treeBuilder.endElement(
- currentNode.getNodeName());
+ "", currentNode.getNodeName(), "" );
break;
}
import org.apache.fop.fo.pagination.Root;
// SAX
-import org.xml.sax.HandlerBase;
+import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
-import org.xml.sax.AttributeList;
+import org.xml.sax.Attributes;
// Java
import java.util.Hashtable;
/**
* SAX Handler that builds the formatting object tree.
*/
-public class FOTreeBuilder extends HandlerBase {
+public class FOTreeBuilder extends DefaultHandler {
/**
* table mapping element names to the makers of objects
}
/** SAX Handler for the end of an element */
- public void endElement(String name) {
+ public void endElement(
+ String uri, String localName, String rawName) {
currentFObj.end();
currentFObj = (FObj) currentFObj.getParent();
level--;
}
/** SAX Handler for the start of an element */
- public void startElement(String name, AttributeList attlist)
+ public void startElement(String uri,
+ String localName, String rawName, Attributes attlist)
throws SAXException {
/* the formatting object started */
level++;
int length = attlist.getLength();
for (int i = 0; i < length; i++) {
- String att = attlist.getName(i);
+ String att = attlist.getRawName(i);
if (att.equals("xmlns")) {
namespaceStack.push( new NSMap("",
attlist.getValue(i),
level));
}
}
- String fullName = mapName(name);
+
+ String fullName = mapName(rawName);
fobjMaker = (FObj.Maker) fobjTable.get(fullName);
}
try {
- fobj =
- fobjMaker.make(currentFObj,
- this.propertyListBuilder.makeList(attlist,
- (currentFObj == null) ? null : currentFObj.properties));
+ PropertyList list = this.propertyListBuilder.makeList(attlist,
+ (currentFObj == null) ? null : currentFObj.properties);
+ fobj = fobjMaker.make(currentFObj, list);
} catch (FOPException e) {
- throw new SAXException(e);
+ throw new SAXException(e);
}
if (rootFObj == null) {
import org.apache.fop.apps.FOPException;
-import org.xml.sax.AttributeList;
+import org.xml.sax.Attributes;
import java.util.Hashtable;
this.propertyTable = new Hashtable();
propertyTable.put("end-indent",EndIndent.maker());
- propertyTable.put("page-master-name",PageMasterName.maker());
+ propertyTable.put("master-name",MasterName.maker());
propertyTable.put("page-master-first",PageMasterFirst.maker());
propertyTable.put("page-master-repeating",PageMasterRepeating.maker());
propertyTable.put("page-master-odd",PageMasterOdd.maker());
propertyTable.put("initial-page-number",InitialPageNumber.maker());
propertyTable.put("ref-id",RefId.maker()); // used by page-number-citation
propertyTable.put("id",Id.maker()); // attribute for objects, used by page-number-citation
+ propertyTable.put("maximum-repeats",MaximumRepeats.maker());
+ propertyTable.put("page-position",PagePosition.maker());
+ propertyTable.put("odd-or-even",OddOrEven.maker());
+ propertyTable.put("blank-or-not-blank",BlankOrNotBlank.maker());
}
return b;
}
- public PropertyList makeList(AttributeList attributes, PropertyList parentPropertyList) throws FOPException {
+ public PropertyList makeList(Attributes attributes, PropertyList parentPropertyList) throws FOPException {
PropertyList p = new PropertyList(parentPropertyList);
p.setBuilder(this);
for (int i = 0; i < attributes.getLength(); i++) {
- String attributeName = attributes.getName(i);
+ String attributeName = attributes.getRawName(i);
Property.Maker propertyMaker = (Property.Maker)propertyTable.get(attributeName);
if (propertyMaker != null) {
p.put(attributeName,propertyMaker.make(p,attributes.getValue(i)));
builder.addMapping(uri, "region-before", RegionBefore.maker());
builder.addMapping(uri, "region-after", RegionAfter.maker());
builder.addMapping(uri, "page-sequence", PageSequence.maker());
- builder.addMapping(uri, "sequence-specification",
- SequenceSpecification.maker());
- builder.addMapping(uri, "sequence-specifier-single",
- SequenceSpecifierSingle.maker());
- builder.addMapping(uri, "sequence-specifier-repeating",
- SequenceSpecifierRepeating.maker());
- builder.addMapping(uri, "sequence-specifier-alternating",
- SequenceSpecifierAlternating.maker());
+ builder.addMapping(uri, "page-sequence-master",
+ PageSequenceMaster.maker());
+ builder.addMapping(uri, "single-page-master-reference",
+ SinglePageMasterReference.maker());
+ builder.addMapping(uri, "repeatable-page-master-reference",
+ RepeatablePageMasterReference.maker());
+ builder.addMapping(uri, "conditional-page-master-reference",
+ ConditionalPageMasterReference.maker());
+ builder.addMapping(uri, "repeatable-page-master-alternatives",
+ RepeatablePageMasterAlternatives.maker());
builder.addMapping(uri, "flow", Flow.maker());
builder.addMapping(uri, "static-content",
StaticContent.maker());