diff options
author | Glenn Adams <gadams@apache.org> | 2012-05-28 03:30:37 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2012-05-28 03:30:37 +0000 |
commit | d48e0e1f467c58a22c4d1b19591d4fa9d22aa8c6 (patch) | |
tree | 27f9f2afe4b8efcbd53066daa89a61aed6e5fa52 /src | |
parent | 72ba7e572dccdb5ab1930ed9f20c9db7f720ae50 (diff) | |
download | xmlgraphics-fop-d48e0e1f467c58a22c4d1b19591d4fa9d22aa8c6.tar.gz xmlgraphics-fop-d48e0e1f467c58a22c4d1b19591d4fa9d22aa8c6.zip |
Add version attribute to AT and IF intermediate formats. Also eliminate redundant use of reversed attribute in AT format.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1343133 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
3 files changed, 34 insertions, 6 deletions
diff --git a/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd b/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd index bea5275a5..6e17c793b 100644 --- a/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd +++ b/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd @@ -34,6 +34,7 @@ <xs:element ref="mf:page-sequence" minOccurs="1" maxOccurs="unbounded"/> <xs:element ref="mf:trailer"/> </xs:sequence> + <xs:attribute name="version" type="xs:string"/> </xs:complexType> </xs:element> <xs:element name="header"> diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index f8f286cb3..7114f51e3 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -64,6 +64,15 @@ import org.apache.fop.util.XMLUtil; public class IFSerializer extends AbstractXMLWritingIFDocumentHandler implements IFConstants, IFPainter, IFDocumentNavigationHandler { + /** + * Intermediate Format (IF) version, used to express an @version attribute + * in the root element of the IF document, the initial value of which + * is set to '2.0' to signify that something preceded it (but didn't + * happen to be marked as such), and that this version is not necessarily + * backwards compatible with the unmarked (<2.0) version. + */ + public static final String VERSION = "2.0"; + private IFDocumentHandler mimicHandler; private int pageSequenceIndex; // used for accessibility @@ -167,7 +176,9 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler DocumentNavigationExtensionConstants.NAMESPACE); handler.startPrefixMapping(InternalElementMapping.STANDARD_PREFIX, InternalElementMapping.URI); - handler.startElement(EL_DOCUMENT); + AttributesImpl atts = new AttributesImpl(); + addAttribute(atts, "version", VERSION); + handler.startElement(EL_DOCUMENT, atts); } catch (SAXException e) { throw new IFException("SAX error in startDocument()", e); } diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 4ac650269..cf3cbe5a2 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -97,6 +97,15 @@ import org.apache.fop.util.XMLUtil; */ public class XMLRenderer extends AbstractXMLRenderer { + /** + * Area Tree (AT) version, used to express an @version attribute + * in the root element of the AT document, the initial value of which + * is set to '2.0' to signify that something preceded it (but didn't + * happen to be marked as such), and that this version is not necessarily + * backwards compatible with the unmarked (<2.0) version. + */ + public static final String VERSION = "2.0"; + /** XML MIME type */ public static final String XML_MIME_TYPE = MimeConstants.MIME_FOP_AREA_TREE; @@ -365,7 +374,9 @@ public class XMLRenderer extends AbstractXMLRenderer { if (userAgent.getProducer() != null) { comment("Produced by " + userAgent.getProducer()); } - startElement("areaTree"); + atts.clear(); + addAttribute("version", VERSION); + startElement("areaTree", atts); } /** {@inheritDoc} */ @@ -825,11 +836,10 @@ public class XMLRenderer extends AbstractXMLRenderer { } maybeAddLevelAttribute(word); maybeAddPositionAdjustAttribute(word); - if ( word.isReversed() ) { - addAttribute("reversed", "true"); - } + String text = word.getWord(); + maybeAddReversedAttribute(word, text); startElement("word", atts); - characters(word.getWord()); + characters(text); endElement("word"); super.renderWord(word); } @@ -917,5 +927,11 @@ public class XMLRenderer extends AbstractXMLRenderer { } } + private void maybeAddReversedAttribute ( WordArea w, String text ) { + if ( w.isReversed() && ( text.length() > 1 ) ) { + addAttribute("reversed", "true"); + } + } + } |