]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Expresses SAX2 support
authorarved <arved@unknown>
Tue, 11 Jul 2000 02:28:40 +0000 (02:28 +0000)
committerarved <arved@unknown>
Tue, 11 Jul 2000 02:28:40 +0000 (02:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193473 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/apps/CommandLine.java
src/org/apache/fop/apps/Driver.java
src/org/apache/fop/fo/FOTreeBuilder.java
src/org/apache/fop/fo/PropertyListBuilder.java
src/org/apache/fop/fo/StandardElementMapping.java

index 8fa6dc08ff9794817ac5eff0ab530effac03a287..270b4a5f7124abcc0677bddf8181466cef47daac 100644 (file)
@@ -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");
index 27e471c939a862e14169012f1bfce116f0b0f407..32e4273868c6b443108ea9a8500cf204172d1dc7 100644 (file)
@@ -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;
                    }
                    
index d00308588873938e435f7367ac093c66c877a4c1..42a3098a15df6734c7a3d60a3f6f2befdce9cd7d 100644 (file)
@@ -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) {
index 70f9e80cefcb17a4d8a29f887b712601916841ed..f5f457d82606d86ce831e4699e2a16f792e0392d 100644 (file)
@@ -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)));
index aa294ba556313a2c783426432b0313d29c14caba..94236ca96c0ea422542b4b5da48eac62f6880879 100644 (file)
@@ -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());