You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2009/10/22 17:30:13 UTC

svn commit: r828747 - in /xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop: accessibility/AccessibilityEventProducer.java accessibility/AccessibilityEventProducer.xml area/AreaTreeParser.java render/intermediate/IFParser.java

Author: vhennebert
Date: Thu Oct 22 15:30:13 2009
New Revision: 828747

URL: http://svn.apache.org/viewvc?rev=828747&view=rev
Log:
Issue an error when attempting to render an intermediate XML file in accessibility mode, but that file wasn't generated with accessibility (i.e., does not contain the structure tree)

Added:
    xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java   (with props)
    xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml   (with props)
Modified:
    xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java
    xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java

Added: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java?rev=828747&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java Thu Oct 22 15:30:13 2009
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer for accessibility-related events.
+ */
+public interface AccessibilityEventProducer extends EventProducer {
+
+    /** Provider class for the event producer. */
+    public final class Provider {
+
+        private Provider() { }
+
+        /**
+         * Returns an event producer.
+         *
+         * @param broadcaster the event broadcaster to use
+         * @return the event producer
+         */
+        public static AccessibilityEventProducer get(EventBroadcaster broadcaster) {
+            return (AccessibilityEventProducer) broadcaster.getEventProducerFor(
+                    AccessibilityEventProducer.class);
+        }
+    }
+
+    /**
+     * The structure tree is missing in the XML file.
+     *
+     * @param source the event source
+     * @event.severity FATAL
+     */
+    void noStructureTreeInXML(Object source);
+}

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Added: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml?rev=828747&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml (added)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml Thu Oct 22 15:30:13 2009
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+  <message key="org.apache.fop.accessibility.AccessibilityEventProducer.noStructureTreeInXML">Accessibility is enabled but structure tree is missing in XML file. Please disable accessibility, or re-generate XML file in accessibility mode.</message>
+</catalogue>

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java?rev=828747&r1=828746&r2=828747&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java Thu Oct 22 15:30:13 2009
@@ -57,6 +57,7 @@
 import org.apache.xmlgraphics.image.loader.ImageSessionContext;
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.AccessibilityEventProducer;
 import org.apache.fop.accessibility.StructureTreeBuilder;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Trait.Background;
@@ -164,19 +165,19 @@
 
         private ContentHandler structureTreeBuilderWrapper;
 
-        private final class StructureTreeBuilderWrapper extends DelegatingContentHandler {
+        private Attributes pageSequenceAttributes;
 
-            private Attributes pageSequenceAttributes;
+        private final class StructureTreeBuilderWrapper extends DelegatingContentHandler {
 
-            private StructureTreeBuilderWrapper(Attributes pageSequenceAttributes)
+            private StructureTreeBuilderWrapper()
                     throws SAXException {
                 super(structureTreeBuilder.getHandlerForNextPageSequence());
-                this.pageSequenceAttributes = new AttributesImpl(pageSequenceAttributes);
             }
 
             public void endDocument() throws SAXException {
                 super.endDocument();
                 startAreaTreeElement("pageSequence", pageSequenceAttributes);
+                pageSequenceAttributes = null;
             }
         }
 
@@ -297,7 +298,8 @@
                 boolean handled = true;
                 if ("".equals(uri)) {
                     if (localName.equals("pageSequence") && userAgent.isAccessibilityEnabled()) {
-                        structureTreeBuilderWrapper = new StructureTreeBuilderWrapper(attributes);
+                        structureTreeBuilderWrapper = new StructureTreeBuilderWrapper();
+                        pageSequenceAttributes = new AttributesImpl(attributes);
                     } else if (localName.equals("structureTree")) {
                         if (userAgent.isAccessibilityEnabled()) {
                             delegate = structureTreeBuilderWrapper;
@@ -309,6 +311,18 @@
                         delegate.startDocument();
                         delegate.startElement(uri, localName, qName, attributes);
                     } else {
+                        if (pageSequenceAttributes != null) {
+                            /*
+                             * This means that no structure-element tag was
+                             * found in the XML, otherwise a
+                             * StructureTreeBuilderWrapper object would have
+                             * been created, which would have reset the
+                             * pageSequenceAttributes field.
+                             */
+                            AccessibilityEventProducer.Provider
+                                    .get(userAgent.getEventBroadcaster())
+                                    .noStructureTreeInXML(this);
+                        }
                         handled = startAreaTreeElement(localName, attributes);
                     }
                 } else {

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=828747&r1=828746&r2=828747&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java Thu Oct 22 15:30:13 2009
@@ -46,6 +46,7 @@
 
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.AccessibilityEventProducer;
 import org.apache.fop.accessibility.StructureTreeBuilder;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.ElementMapping;
@@ -155,19 +156,19 @@
 
         private ContentHandler structureTreeBuilderWrapper;
 
-        private final class StructureTreeBuilderWrapper extends DelegatingContentHandler {
+        private Attributes pageSequenceAttributes;
 
-            private Attributes pageSequenceAttributes;
+        private final class StructureTreeBuilderWrapper extends DelegatingContentHandler {
 
-            private StructureTreeBuilderWrapper(Attributes pageSequenceAttributes)
+            private StructureTreeBuilderWrapper()
                     throws SAXException {
                 super(structureTreeBuilder.getHandlerForNextPageSequence());
-                this.pageSequenceAttributes = new AttributesImpl(pageSequenceAttributes);
             }
 
             public void endDocument() throws SAXException {
                 super.endDocument();
                 startIFElement(EL_PAGE_SEQUENCE, pageSequenceAttributes);
+                pageSequenceAttributes = null;
             }
         }
 
@@ -227,7 +228,8 @@
                 boolean handled = true;
                 if (NAMESPACE.equals(uri)) {
                     if (localName.equals(EL_PAGE_SEQUENCE) && userAgent.isAccessibilityEnabled()) {
-                        structureTreeBuilderWrapper = new StructureTreeBuilderWrapper(attributes);
+                        pageSequenceAttributes = new AttributesImpl(attributes);
+                        structureTreeBuilderWrapper = new StructureTreeBuilderWrapper();
                     } else if (localName.equals(EL_STRUCTURE_TREE)) {
                         if (userAgent.isAccessibilityEnabled()) {
                             delegate = structureTreeBuilderWrapper;
@@ -239,6 +241,18 @@
                         delegate.startDocument();
                         delegate.startElement(uri, localName, qName, attributes);
                     } else {
+                        if (pageSequenceAttributes != null) {
+                            /*
+                             * This means that no structure-element tag was
+                             * found in the XML, otherwise a
+                             * StructureTreeBuilderWrapper object would have
+                             * been created, which would have reset the
+                             * pageSequenceAttributes field.
+                             */
+                            AccessibilityEventProducer.Provider
+                                    .get(userAgent.getEventBroadcaster())
+                                    .noStructureTreeInXML(this);
+                        }
                         handled = startIFElement(localName, attributes);
                     }
                 } else if (DocumentNavigationExtensionConstants.NAMESPACE.equals(uri)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Re: Generation of *EventProducer.xml [was: Re: svn commit: r828747...]

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi Vincent,

feel free to improve as you see fit. I have no problem with any of your
suggestions.

On 27.10.2009 11:40:21 Vincent Hennebert wrote:
> Hi,
> 
> Jeremias Maerki wrote:
> > On 22.10.2009 19:36:14 Vincent Hennebert wrote:
> >> Hi,
> >>
> >>> Log:
> >>> Issue an error when attempting to render an intermediate XML file in accessibility mode, but that file wasn't generated with accessibility (i.e., does not contain the structure tree)
> >>>
> >>> Added:
> >>>     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java   (with props)
> >>>     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml   (with props)
> >> After creating the AccessibilityEventProducer.xml file and running ‘ant
> >> resourcegen’ I discovered that an empty message had been added to
> >> src/java/org/apache/fop/events/EventFormatter.xml. Why?
> > 
> > Because the new files wasn't reflected in the build. All events not
> > specifically directed into a special file go into the catch-all file in
> > the events package. I've updated the build accordingly:
> > http://svn.apache.org/viewvc?rev=828805&view=rev
> 
> I have trouble seeing the necessity of adding something to the build
> file I must say. (That build file, BTW, is already 1441 lines long. We
> should think twice before adding anything to it IMO.)
> 
> All eventResourceGenerator tasks are exactly the same. Couldn’t we set
> the convention that the translation file corresponding to a certain
> EventProducer interface must have the same name and be in the same
> directory as the interface itself?
> 
> Example: a PDFEventProducer.java file is found in the
> org/apache/fop/render/pdf directory; a PDFEventProducer.xml file
> containing the translation is expected in that same directory.
> 
> Using a catch-all file kills the modularity of the thing IMO. Also, the
> individual translation files are called *EventProducer.xml but the
> catch-all file is called EventFormatter.xml!?
> 
> 
> >> Also, after re-building FOP I regularly find myself with modified
> >> *EventProducer.xml files, where the sole modification is an
> >> added/removed line break. This is annoying. How can that be avoided?
> > 
> > These are small differences in behaviour of XML serializers. I guess if
> > that is so annoying, we'd have to make sure we always use the same
> > serializer (make & version) somehow. We could also experiment with
> > removing the XML declaration [1] at the beginning of the file. That
> > might get rid of the problem but that's not for sure. I've stumbled over
> > this myself a number of times but found it to be only a minor nuisance
> > which is why I didn't do anything about it.
> > 
> > [1] http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/OutputKeys.html#OMIT_XML_DECLARATION
> 
> I can see the interest of filling the translation file with empty
> messages having correct keys (those are not exactly trivial —although
> necessary, I guess). However, there is IMO a non-negligible danger that
> the user then forgets to fill in those messages appropriately.
> 
> Also, I’m not sure I like having a file that is both manually edited and
> automatically generated. That usually doesn’t go well together, as the
> automatic generation usually messes up any manual formatting. The above
> is an illustration.
> 
> If there were the convention that the translation file must be put in
> the same package as the EventProducer interface, the key wouldn’t need
> to be fully qualified, only the method name would be necessary. Then
> I think it’s reasonable to expect the user to fill in the translation
> file accordingly, and just check at build time that both the interface
> and the translation file are consistent.
> 
> Is there anything wrong with that?
> 
> Vincent




Jeremias Maerki


Re: Generation of *EventProducer.xml [was: Re: svn commit: r828747...]

Posted by Vincent Hennebert <vh...@gmail.com>.
Hi,

Jeremias Maerki wrote:
> On 22.10.2009 19:36:14 Vincent Hennebert wrote:
>> Hi,
>>
>>> Log:
>>> Issue an error when attempting to render an intermediate XML file in accessibility mode, but that file wasn't generated with accessibility (i.e., does not contain the structure tree)
>>>
>>> Added:
>>>     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java   (with props)
>>>     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml   (with props)
>> After creating the AccessibilityEventProducer.xml file and running ‘ant
>> resourcegen’ I discovered that an empty message had been added to
>> src/java/org/apache/fop/events/EventFormatter.xml. Why?
> 
> Because the new files wasn't reflected in the build. All events not
> specifically directed into a special file go into the catch-all file in
> the events package. I've updated the build accordingly:
> http://svn.apache.org/viewvc?rev=828805&view=rev

I have trouble seeing the necessity of adding something to the build
file I must say. (That build file, BTW, is already 1441 lines long. We
should think twice before adding anything to it IMO.)

All eventResourceGenerator tasks are exactly the same. Couldn’t we set
the convention that the translation file corresponding to a certain
EventProducer interface must have the same name and be in the same
directory as the interface itself?

Example: a PDFEventProducer.java file is found in the
org/apache/fop/render/pdf directory; a PDFEventProducer.xml file
containing the translation is expected in that same directory.

Using a catch-all file kills the modularity of the thing IMO. Also, the
individual translation files are called *EventProducer.xml but the
catch-all file is called EventFormatter.xml!?


>> Also, after re-building FOP I regularly find myself with modified
>> *EventProducer.xml files, where the sole modification is an
>> added/removed line break. This is annoying. How can that be avoided?
> 
> These are small differences in behaviour of XML serializers. I guess if
> that is so annoying, we'd have to make sure we always use the same
> serializer (make & version) somehow. We could also experiment with
> removing the XML declaration [1] at the beginning of the file. That
> might get rid of the problem but that's not for sure. I've stumbled over
> this myself a number of times but found it to be only a minor nuisance
> which is why I didn't do anything about it.
> 
> [1] http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/OutputKeys.html#OMIT_XML_DECLARATION

I can see the interest of filling the translation file with empty
messages having correct keys (those are not exactly trivial —although
necessary, I guess). However, there is IMO a non-negligible danger that
the user then forgets to fill in those messages appropriately.

Also, I’m not sure I like having a file that is both manually edited and
automatically generated. That usually doesn’t go well together, as the
automatic generation usually messes up any manual formatting. The above
is an illustration.

If there were the convention that the translation file must be put in
the same package as the EventProducer interface, the key wouldn’t need
to be fully qualified, only the method name would be necessary. Then
I think it’s reasonable to expect the user to fill in the translation
file accordingly, and just check at build time that both the interface
and the translation file are consistent.

Is there anything wrong with that?

Vincent

Re: Generation of *EventProducer.xml [was: Re: svn commit: r828747...]

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 22.10.2009 19:36:14 Vincent Hennebert wrote:
> Hi,
> 
> > Log:
> > Issue an error when attempting to render an intermediate XML file in accessibility mode, but that file wasn't generated with accessibility (i.e., does not contain the structure tree)
> > 
> > Added:
> >     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java   (with props)
> >     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml   (with props)
> 
> After creating the AccessibilityEventProducer.xml file and running ‘ant
> resourcegen’ I discovered that an empty message had been added to
> src/java/org/apache/fop/events/EventFormatter.xml. Why?

Because the new files wasn't reflected in the build. All events not
specifically directed into a special file go into the catch-all file in
the events package. I've updated the build accordingly:
http://svn.apache.org/viewvc?rev=828805&view=rev

> Also, after re-building FOP I regularly find myself with modified
> *EventProducer.xml files, where the sole modification is an
> added/removed line break. This is annoying. How can that be avoided?

These are small differences in behaviour of XML serializers. I guess if
that is so annoying, we'd have to make sure we always use the same
serializer (make & version) somehow. We could also experiment with
removing the XML declaration [1] at the beginning of the file. That
might get rid of the problem but that's not for sure. I've stumbled over
this myself a number of times but found it to be only a minor nuisance
which is why I didn't do anything about it.

[1] http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/OutputKeys.html#OMIT_XML_DECLARATION

Jeremias Maerki


Generation of *EventProducer.xml [was: Re: svn commit: r828747...]

Posted by Vincent Hennebert <vh...@gmail.com>.
Hi,

> Log:
> Issue an error when attempting to render an intermediate XML file in accessibility mode, but that file wasn't generated with accessibility (i.e., does not contain the structure tree)
> 
> Added:
>     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java   (with props)
>     xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml   (with props)

After creating the AccessibilityEventProducer.xml file and running ‘ant
resourcegen’ I discovered that an empty message had been added to
src/java/org/apache/fop/events/EventFormatter.xml. Why?

Also, after re-building FOP I regularly find myself with modified
*EventProducer.xml files, where the sole modification is an
added/removed line break. This is annoying. How can that be avoided?


Thanks,
Vincent