]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Merged SimpleStructureTree and ParsedStructureTree classes into a single one, used...
authorVincent Hennebert <vhennebert@apache.org>
Thu, 15 Oct 2009 14:25:28 +0000 (14:25 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Thu, 15 Oct 2009 14:25:28 +0000 (14:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@825504 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/accessibility/ParsedStructureTree.java [deleted file]
src/java/org/apache/fop/accessibility/SimpleStructureTree.java [deleted file]
src/java/org/apache/fop/accessibility/StructureTree.java
src/java/org/apache/fop/accessibility/StructureTreeBuilder.java [new file with mode: 0644]
src/java/org/apache/fop/accessibility/TransformerNodeEndProcessing.java
src/java/org/apache/fop/area/AreaTreeParser.java
src/java/org/apache/fop/render/intermediate/IFParser.java
src/java/org/apache/fop/render/intermediate/IFSerializer.java
src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
src/java/org/apache/fop/render/pdf/PDFRenderer.java
src/java/org/apache/fop/render/xml/XMLRenderer.java

diff --git a/src/java/org/apache/fop/accessibility/ParsedStructureTree.java b/src/java/org/apache/fop/accessibility/ParsedStructureTree.java
deleted file mode 100644 (file)
index 6464962..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.accessibility;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.NodeList;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-import org.apache.fop.util.DelegatingContentHandler;
-
-/**
- * A StructureTree implementation re-created from the structure stored in an IF
- * XML document.
- */
-public class ParsedStructureTree implements StructureTree {
-
-    private SAXTransformerFactory factory;
-
-    private List pageSequenceStructures = new ArrayList();
-
-    /**
-     * Creates a new instance.
-     *
-     * @param factory a factory internally used to build the structures of page
-     * sequences
-     */
-    public ParsedStructureTree(SAXTransformerFactory factory) {
-        this.factory = factory;
-    }
-
-    /**
-     * Returns a ContenHandler for parsing the structure of a new page sequence.
-     * It is assumed that page sequences are being parsed in the document order.
-     * This class will automatically number the structure trees.
-     *
-     * @return a handler for parsing the &lt;structure-tree&gt; element and its
-     * descendants
-     * @throws SAXException if there is an error when creating the handler
-     */
-    public ContentHandler getHandlerForNextPageSequence() throws SAXException {
-        TransformerHandler structureTreeBuilder;
-        try {
-            structureTreeBuilder = factory.newTransformerHandler();
-        } catch (TransformerConfigurationException e) {
-            throw new SAXException(e);
-        }
-        final DOMResult domResult = new DOMResult();
-        structureTreeBuilder.setResult(domResult);
-        return new DelegatingContentHandler(structureTreeBuilder) {
-
-            public void characters(char[] ch, int start, int length) throws SAXException {
-                /*
-                 * There's no text node in the structure tree. This is just
-                 * whitespace => ignore
-                 */
-            }
-
-            public void endDocument() throws SAXException {
-                super.endDocument();
-                pageSequenceStructures.add(domResult.getNode().getFirstChild().getChildNodes());
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    public NodeList getPageSequence(int number) {
-        return (NodeList) pageSequenceStructures.get(number - 1);
-    }
-
-    /**
-     * Returns an XML-like representation of the structure trees.
-     * <p>
-     * <strong>Note:</strong> use only for debugging purpose, as this method
-     * performs non-trivial operations.
-     * </p>
-     * @return a string representation of this object
-     */
-    public String toString() {
-        try {
-            Transformer t = TransformerFactory.newInstance().newTransformer();
-            Writer str = new StringWriter();
-            for (Iterator iter = pageSequenceStructures.iterator(); iter.hasNext();) {
-                NodeList nodes = (NodeList) iter.next();
-                for (int i = 0, c = nodes.getLength(); i < c; i++) {
-                    t.transform(new DOMSource(nodes.item(i)), new StreamResult(str));
-                }
-            }
-            return str.toString();
-        } catch (Exception e) {
-            return e.toString();
-        }
-    }
-
-}
diff --git a/src/java/org/apache/fop/accessibility/SimpleStructureTree.java b/src/java/org/apache/fop/accessibility/SimpleStructureTree.java
deleted file mode 100644 (file)
index c009b7b..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.accessibility;
-
-import java.io.StringWriter;
-import java.io.Writer;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A StructureTree implementation created from the reduced FO tree, in the form
- * of a single DOM document obtained by XSL Transformation of the original FO
- * tree.
- */
-final class SimpleStructureTree implements StructureTree {
-
-    private final Node reducedFOTree;
-
-    SimpleStructureTree(Node reducedFOTree) {
-        this.reducedFOTree = reducedFOTree;
-    }
-
-    /** {@inheritDoc} */
-    public NodeList getPageSequence(int number) {
-        Node pageSequence = reducedFOTree.getFirstChild().getChildNodes().item(number - 1);
-        assert pageSequence.getNodeType() == Node.ELEMENT_NODE
-                && pageSequence.getLocalName().equals("page-sequence");
-        return pageSequence.getChildNodes();
-    }
-
-    /** {@inheritDoc} */
-    public String toString() {
-        try {
-            Transformer t = TransformerFactory.newInstance().newTransformer();
-            Writer str = new StringWriter();
-            t.transform(new DOMSource(reducedFOTree), new StreamResult(str));
-            return str.toString();
-        } catch (Exception e) {
-            return e.toString();
-        }
-    }
-
-}
index 09a33f151133e62d44016719ec039b28f913cbd5..a0fdaac21760cc0fc3500fc8cc65c799433d5f3f 100644 (file)
 
 package org.apache.fop.accessibility;
 
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
  * A reduced version of the document's FO tree, containing only its logical
  * structure. Used by accessible output formats.
  */
-public interface StructureTree {
+public final class StructureTree {
+
+    private final List pageSequenceStructures = new ArrayList();
+
+    /**
+     * Package-private default constructor.
+     */
+    StructureTree() { }
+
+    private static boolean flowOrStaticContentNodes(NodeList nodes) {
+        for (int i = 0; i < nodes.getLength(); i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeType() != Node.ELEMENT_NODE) {
+                return false;
+            }
+            String name = node.getLocalName();
+            if (!(name.equals("flow") || name.equals("static-content"))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    void addPageSequenceStructure(NodeList structureTree) {
+        assert flowOrStaticContentNodes(structureTree);
+        pageSequenceStructures.add(structureTree);
+    }
 
     /**
      * Returns the list of nodes that are the children of the given page sequence.
      *
-     * @param number number of the page sequence, 1-based
+     * @param index index of the page sequence, 0-based
      * @return its children nodes
      */
-    NodeList getPageSequence(int number);
+    public NodeList getPageSequence(int index) {
+        return (NodeList) pageSequenceStructures.get(index);
+    }
+
+    /**
+     * Returns an XML-like representation of the structure trees.
+     * <p>
+     * <strong>Note:</strong> use only for debugging purpose, as this method
+     * performs non-trivial operations.
+     * </p>
+     * @return a string representation of this object
+     */
+    public String toString() {
+        try {
+            Transformer t = TransformerFactory.newInstance().newTransformer();
+            Writer str = new StringWriter();
+            for (Iterator iter = pageSequenceStructures.iterator(); iter.hasNext();) {
+                NodeList nodes = (NodeList) iter.next();
+                for (int i = 0, c = nodes.getLength(); i < c; i++) {
+                    t.transform(new DOMSource(nodes.item(i)), new StreamResult(str));
+                }
+            }
+            return str.toString();
+        } catch (Exception e) {
+            return e.toString();
+        }
+    }
 
 }
diff --git a/src/java/org/apache/fop/accessibility/StructureTreeBuilder.java b/src/java/org/apache/fop/accessibility/StructureTreeBuilder.java
new file mode 100644 (file)
index 0000000..cd9aa01
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.accessibility;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import org.apache.fop.util.DelegatingContentHandler;
+
+/**
+ * Helper class that re-builds a structure tree from what is stored in an
+ * intermediate XML file (IF XML or Area Tree XML).
+ */
+public final class StructureTreeBuilder {
+
+    private final SAXTransformerFactory factory;
+
+    private final StructureTree structureTree = new StructureTree();
+
+    /**
+     * Creates a new instance.
+     *
+     * @param factory a factory internally used to build the structures of page
+     * sequences
+     */
+    public StructureTreeBuilder(SAXTransformerFactory factory) {
+        this.factory = factory;
+    }
+
+    /**
+     * Returns the structure tree that will result from the parsing.
+     *
+     * @return the structure tree built by this object
+     */
+    public StructureTree getStructureTree() {
+        return structureTree;
+    }
+
+    /**
+     * Returns a ContenHandler for parsing the structure of a new page sequence.
+     * It is assumed that page sequences are being parsed in the document order.
+     *
+     * @return a handler for parsing the &lt;structure-tree&gt; or
+     * &lt;structureTree&gt; element and its descendants
+     * @throws SAXException if there is an error when creating the handler
+     */
+    public ContentHandler getHandlerForNextPageSequence() throws SAXException {
+        TransformerHandler structureTreeBuilder;
+        try {
+            structureTreeBuilder = factory.newTransformerHandler();
+        } catch (TransformerConfigurationException e) {
+            throw new SAXException(e);
+        }
+        final DOMResult domResult = new DOMResult();
+        structureTreeBuilder.setResult(domResult);
+        return new DelegatingContentHandler(structureTreeBuilder) {
+
+            public void characters(char[] ch, int start, int length) throws SAXException {
+                /*
+                 * There's no text node in the structure tree. This is just
+                 * whitespace => ignore
+                 */
+            }
+
+            public void endDocument() throws SAXException {
+                super.endDocument();
+                structureTree.addPageSequenceStructure(domResult.getNode().getFirstChild()
+                        .getChildNodes());
+            }
+        };
+    }
+
+}
index 00d4a5b56cd6a60f44b234ab8b55a8d806c579cd..36f36fdef0b91e695cbb6512b63293c6b7300f30 100644 (file)
@@ -32,10 +32,12 @@ import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
+import org.apache.commons.io.output.ByteArrayOutputStream;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 
@@ -78,7 +80,12 @@ class TransformerNodeEndProcessing extends TransformerNode {
             Source src = new StreamSource(new ByteArrayInputStream(enrichedFO));
             DOMResult res = new DOMResult();
             transformer.transform(src, res);
-            userAgent.setStructureTree(new SimpleStructureTree(res.getNode()));
+            StructureTree structureTree = new StructureTree();
+            NodeList pageSequences = res.getNode().getFirstChild().getChildNodes();
+            for (int i = 0; i < pageSequences.getLength(); i++) {
+                structureTree.addPageSequenceStructure(pageSequences.item(i).getChildNodes());
+            }
+            userAgent.setStructureTree(structureTree);
 
             SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
             saxParserFactory.setNamespaceAware(true);
index 12e31530d4ce52727a015ae7b5057008122b262a..784ca068410be4529b9edcfd6718a3987208be11 100644 (file)
@@ -57,7 +57,7 @@ import org.apache.xmlgraphics.image.loader.ImageManager;
 import org.apache.xmlgraphics.image.loader.ImageSessionContext;
 import org.apache.xmlgraphics.util.QName;
 
-import org.apache.fop.accessibility.ParsedStructureTree;
+import org.apache.fop.accessibility.StructureTreeBuilder;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Trait.Background;
 import org.apache.fop.area.Trait.InternalLink;
@@ -160,17 +160,17 @@ public class AreaTreeParser {
         private Locator locator;
 
 
-        private ParsedStructureTree structureTree;
+        private StructureTreeBuilder structureTreeBuilder;
 
-        private ContentHandler structureTreeBuilder;
+        private ContentHandler structureTreeBuilderWrapper;
 
-        private final class StructureTreeBuilder extends DelegatingContentHandler {
+        private final class StructureTreeBuilderWrapper extends DelegatingContentHandler {
 
             private Attributes pageSequenceAttributes;
 
-            private StructureTreeBuilder(Attributes pageSequenceAttributes,
-                    ParsedStructureTree structureTree) throws SAXException {
-                super(structureTree.getHandlerForNextPageSequence());
+            private StructureTreeBuilderWrapper(Attributes pageSequenceAttributes)
+                    throws SAXException {
+                super(structureTreeBuilder.getHandlerForNextPageSequence());
                 this.pageSequenceAttributes = new AttributesImpl(pageSequenceAttributes);
             }
 
@@ -216,9 +216,10 @@ public class AreaTreeParser {
             makers.put("bookmarkTree", new BookmarkTreeMaker());
             makers.put("bookmark", new BookmarkMaker());
             makers.put("destination", new DestinationMaker());
+
             if (userAgent.isAccessibilityEnabled()) {
-                structureTree = new ParsedStructureTree(tFactory);
-                userAgent.setStructureTree(structureTree);
+                structureTreeBuilder = new StructureTreeBuilder(tFactory);
+                userAgent.setStructureTree(structureTreeBuilder.getStructureTree());
             }
         }
 
@@ -296,10 +297,10 @@ public class AreaTreeParser {
                 boolean handled = true;
                 if ("".equals(uri)) {
                     if (localName.equals("pageSequence") && userAgent.isAccessibilityEnabled()) {
-                        structureTreeBuilder = new StructureTreeBuilder(attributes, structureTree);
+                        structureTreeBuilderWrapper = new StructureTreeBuilderWrapper(attributes);
                     } else if (localName.equals("structureTree")) {
                         if (userAgent.isAccessibilityEnabled()) {
-                            delegate = structureTreeBuilder;
+                            delegate = structureTreeBuilderWrapper;
                         } else {
                             /* Delegate to a handler that does nothing */
                             delegate = new DefaultHandler();
index 9ef65ce6f721ef99d85537a48fbda7561ea1264f..e7bdd1b23f553a937eea94f3fd0c3cc81f8db12f 100644 (file)
@@ -46,7 +46,7 @@ import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.util.QName;
 
-import org.apache.fop.accessibility.ParsedStructureTree;
+import org.apache.fop.accessibility.StructureTreeBuilder;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.ElementMappingRegistry;
@@ -151,17 +151,17 @@ public class IFParser implements IFConstants {
 
         private ContentHandler navParser;
 
-        private ParsedStructureTree structureTree;
+        private StructureTreeBuilder structureTreeBuilder;
 
-        private ContentHandler structureTreeBuilder;
+        private ContentHandler structureTreeBuilderWrapper;
 
-        private final class StructureTreeBuilder extends DelegatingContentHandler {
+        private final class StructureTreeBuilderWrapper extends DelegatingContentHandler {
 
             private Attributes pageSequenceAttributes;
 
-            private StructureTreeBuilder(Attributes pageSequenceAttributes,
-                    ParsedStructureTree structureTree) throws SAXException {
-                super(structureTree.getHandlerForNextPageSequence());
+            private StructureTreeBuilderWrapper(Attributes pageSequenceAttributes)
+                    throws SAXException {
+                super(structureTreeBuilder.getHandlerForNextPageSequence());
                 this.pageSequenceAttributes = new AttributesImpl(pageSequenceAttributes);
             }
 
@@ -196,8 +196,8 @@ public class IFParser implements IFConstants {
             elementHandlers.put(EL_IMAGE, new ImageHandler());
 
             if (userAgent.isAccessibilityEnabled()) {
-                structureTree = new ParsedStructureTree(tFactory);
-                userAgent.setStructureTree(structureTree);
+                structureTreeBuilder = new StructureTreeBuilder(tFactory);
+                userAgent.setStructureTree(structureTreeBuilder.getStructureTree());
             }
         }
 
@@ -227,10 +227,10 @@ public class IFParser implements IFConstants {
                 boolean handled = true;
                 if (NAMESPACE.equals(uri)) {
                     if (localName.equals(EL_PAGE_SEQUENCE) && userAgent.isAccessibilityEnabled()) {
-                        structureTreeBuilder = new StructureTreeBuilder(attributes, structureTree);
+                        structureTreeBuilderWrapper = new StructureTreeBuilderWrapper(attributes);
                     } else if (localName.equals(EL_STRUCTURE_TREE)) {
                         if (userAgent.isAccessibilityEnabled()) {
-                            delegate = structureTreeBuilder;
+                            delegate = structureTreeBuilderWrapper;
                         } else {
                             /* Delegate to a handler that does nothing */
                             delegate = new DefaultHandler();
index 9d7c15a61150b43702ee7604c455b877aa66f7fa..b6136f03688e1d5a35d93f4c0c9519660103724b 100644 (file)
@@ -63,7 +63,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
         implements IFConstants, IFPainter, IFDocumentNavigationHandler {
 
     private IFDocumentHandler mimicHandler;
-    private int pageSequenceCounter; // used for accessibility
+    private int pageSequenceIndex; // used for accessibility
 
     /** Holds the intermediate format state */
     private IFState state;
@@ -224,7 +224,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
             if (this.getUserAgent().isAccessibilityEnabled()) {
                 StructureTree structureTree = getUserAgent().getStructureTree();
                 handler.startElement(EL_STRUCTURE_TREE); // add structure tree
-                NodeList nodes = structureTree.getPageSequence(++pageSequenceCounter);
+                NodeList nodes = structureTree.getPageSequence(pageSequenceIndex++);
                 for (int i = 0, n = nodes.getLength(); i < n; i++) {
                     Node node = nodes.item(i);
                     new DOM2SAX(handler).writeFragment(node);
index b9d726bf292891094adbc366ba0e218682dddfd4..3cd601bfa19851528f7ff0a4c65dcb10cc94f62a 100644 (file)
@@ -62,7 +62,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
     /** logging instance */
     private static Log log = LogFactory.getLog(PDFDocumentHandler.class);
 
-    private int pageSequenceNumber;
+    private int pageSequenceIndex;
 
     private boolean accessEnabled;
 
@@ -186,8 +186,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
         }
 
         if (accessEnabled) {
-            NodeList nodes = getUserAgent().getStructureTree().getPageSequence(
-                    ++pageSequenceNumber);
+            NodeList nodes = getUserAgent().getStructureTree().getPageSequence(pageSequenceIndex++);
             logicalStructureHandler.processStructureTree(nodes, getContext().getLanguage());
         }
     }
index 17ab1755c64c08f6c7ecc2160ab2901d87655c89..380241ba083da61b5ac4ee79a4400cd958297acd 100644 (file)
@@ -204,7 +204,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer implements PDFConf
 
     private PDFLogicalStructureHandler logicalStructureHandler;
 
-    private int pageSequenceNumber;
+    private int pageSequenceIndex;
 
     /** Reference in the structure tree to the image being rendered. */
     private String imageReference;
@@ -428,8 +428,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer implements PDFConf
         }
         pdfUtil.generateDefaultXMPMetadata();
         if (accessEnabled) {
-            NodeList nodes = getUserAgent().getStructureTree().getPageSequence(
-                    ++pageSequenceNumber);
+            NodeList nodes = getUserAgent().getStructureTree().getPageSequence(pageSequenceIndex++);
             logicalStructureHandler.processStructureTree(nodes, language);
         }
     }
index d86814d25421a0eebd81ccace7710d295288ebda..a8a1a1911e6a70b71e3b641c9f5b2eae8e952765 100644 (file)
@@ -41,7 +41,6 @@ import org.xml.sax.SAXException;
 import org.apache.xmlgraphics.util.QName;
 import org.apache.xmlgraphics.util.XMLizable;
 
-import org.apache.fop.accessibility.StructureTree;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
@@ -108,7 +107,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
     /** If not null, the XMLRenderer will mimic another renderer by using its font setup. */
     protected Renderer mimic;
 
-    private int pageSequenceNumber;
+    private int pageSequenceIndex;
 
     /**
      * Creates a new XML renderer.
@@ -446,10 +445,9 @@ public class XMLRenderer extends AbstractXMLRenderer {
         transferForeignObjects(pageSequence);
         startElement("pageSequence", atts);
         if (this.getUserAgent().isAccessibilityEnabled()) {
-            StructureTree structureTree = getUserAgent().getStructureTree();
             String structureTreeElement = "structureTree";
             startElement(structureTreeElement);
-            NodeList nodes = structureTree.getPageSequence(++pageSequenceNumber);
+            NodeList nodes = getUserAgent().getStructureTree().getPageSequence(pageSequenceIndex++);
             for (int i = 0, n = nodes.getLength(); i < n; i++) {
                 Node node = nodes.item(i);
                 try {