aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorarved <arved@unknown>2000-07-11 02:28:40 +0000
committerarved <arved@unknown>2000-07-11 02:28:40 +0000
commita1f9e03f6a482849869f2889e04a306111bde821 (patch)
tree2779354fa24e9c89e9328746386e5f9f6e428b0d /src/org
parent4db7ddbd6393af44726e6e2392233e68971915c7 (diff)
downloadxmlgraphics-fop-a1f9e03f6a482849869f2889e04a306111bde821.tar.gz
xmlgraphics-fop-a1f9e03f6a482849869f2889e04a306111bde821.zip
Expresses SAX2 support
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193473 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/apps/CommandLine.java8
-rw-r--r--src/org/apache/fop/apps/Driver.java33
-rw-r--r--src/org/apache/fop/fo/FOTreeBuilder.java26
-rw-r--r--src/org/apache/fop/fo/PropertyListBuilder.java12
-rw-r--r--src/org/apache/fop/fo/StandardElementMapping.java18
5 files changed, 54 insertions, 43 deletions
diff --git a/src/org/apache/fop/apps/CommandLine.java b/src/org/apache/fop/apps/CommandLine.java
index 8fa6dc08f..270b4a5f7 100644
--- a/src/org/apache/fop/apps/CommandLine.java
+++ b/src/org/apache/fop/apps/CommandLine.java
@@ -51,7 +51,7 @@
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;
@@ -84,7 +84,7 @@ public class CommandLine {
*
* @return the created SAX parser
*/
- static Parser createParser() {
+ static XMLReader createParser() {
String parserClassName =
System.getProperty("org.xml.sax.parser");
if (parserClassName == null) {
@@ -93,7 +93,7 @@ public class CommandLine {
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);
@@ -154,7 +154,7 @@ public class CommandLine {
System.exit(1);
}
- Parser parser = createParser();
+ XMLReader parser = createParser();
if (parser == null) {
MessageHandler.errorln("ERROR: Unable to create SAX parser");
diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java
index 27e471c93..32e427386 100644
--- a/src/org/apache/fop/apps/Driver.java
+++ b/src/org/apache/fop/apps/Driver.java
@@ -66,11 +66,11 @@ import org.w3c.dom.NamedNodeMap;
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;
@@ -214,7 +214,7 @@ public class Driver {
* 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;
}
@@ -222,9 +222,10 @@ public class Driver {
* 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) {
@@ -246,12 +247,12 @@ public class Driver {
/* 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;
@@ -283,13 +284,15 @@ public class Driver {
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;
}
@@ -306,7 +309,7 @@ public class Driver {
break;
case Node.ELEMENT_NODE:
this.treeBuilder.endElement(
- currentNode.getNodeName());
+ "", currentNode.getNodeName(), "" );
break;
}
diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java
index d00308588..42a3098a1 100644
--- a/src/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/org/apache/fop/fo/FOTreeBuilder.java
@@ -57,10 +57,10 @@ import org.apache.fop.apps.FOPException;
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;
@@ -70,7 +70,7 @@ import java.io.IOException;
/**
* 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
@@ -168,7 +168,8 @@ public class FOTreeBuilder extends HandlerBase {
}
/** 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--;
@@ -183,7 +184,8 @@ public class FOTreeBuilder extends HandlerBase {
}
/** 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 */
@@ -195,7 +197,7 @@ public class FOTreeBuilder extends HandlerBase {
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),
@@ -206,7 +208,8 @@ public class FOTreeBuilder extends HandlerBase {
level));
}
}
- String fullName = mapName(name);
+
+ String fullName = mapName(rawName);
fobjMaker = (FObj.Maker) fobjTable.get(fullName);
@@ -220,12 +223,11 @@ public class FOTreeBuilder extends HandlerBase {
}
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) {
diff --git a/src/org/apache/fop/fo/PropertyListBuilder.java b/src/org/apache/fop/fo/PropertyListBuilder.java
index 70f9e80ce..f5f457d82 100644
--- a/src/org/apache/fop/fo/PropertyListBuilder.java
+++ b/src/org/apache/fop/fo/PropertyListBuilder.java
@@ -57,7 +57,7 @@ import org.apache.fop.svg.*;
import org.apache.fop.apps.FOPException;
-import org.xml.sax.AttributeList;
+import org.xml.sax.Attributes;
import java.util.Hashtable;
@@ -69,7 +69,7 @@ public class PropertyListBuilder {
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());
@@ -167,6 +167,10 @@ public class PropertyListBuilder {
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());
}
@@ -196,13 +200,13 @@ public class PropertyListBuilder {
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)));
diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java
index aa294ba55..94236ca96 100644
--- a/src/org/apache/fop/fo/StandardElementMapping.java
+++ b/src/org/apache/fop/fo/StandardElementMapping.java
@@ -69,14 +69,16 @@ public class StandardElementMapping implements ElementMapping {
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());