xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r746951 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/xmp/XMPSerializer.java status.xml
Date Mon, 23 Feb 2009 10:40:15 GMT
Author: jeremias
Date: Mon Feb 23 10:40:14 2009
New Revision: 746951

URL: http://svn.apache.org/viewvc?rev=746951&view=rev
Log:
Catching IllegalArgumentException in XMPSerializer when the Transformer implementation in
use doesn't support the INDENT key.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSerializer.java
    xmlgraphics/commons/trunk/status.xml

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSerializer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSerializer.java?rev=746951&r1=746950&r2=746951&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSerializer.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/xmp/XMPSerializer.java Mon Feb
23 10:40:14 2009
@@ -37,38 +37,38 @@
 public class XMPSerializer {
 
     private static final String DEFAULT_ENCODING = "UTF-8";
-    
+
     /**
      * Writes the in-memory representation of the XMP metadata to a JAXP Result.
      * @param meta the metadata
      * @param res the JAXP Result to write to
-     * @throws TransformerConfigurationException if an error occurs setting up the XML 
+     * @throws TransformerConfigurationException if an error occurs setting up the XML
      *              infrastructure.
      * @throws SAXException if a SAX-related problem occurs while writing the XML
      */
-    public static void writeXML(Metadata meta, Result res) 
+    public static void writeXML(Metadata meta, Result res)
             throws TransformerConfigurationException, SAXException {
         writeXML(meta, res, false, false);
     }
-    
+
     /**
      * Writes the in-memory representation of the XMP metadata to an OutputStream as an XMP
packet.
      * @param meta the metadata
      * @param out the stream to write to
      * @param readOnlyXMP true if the generated XMP packet should be read-only
-     * @throws TransformerConfigurationException if an error occurs setting up the XML 
+     * @throws TransformerConfigurationException if an error occurs setting up the XML
      *              infrastructure.
      * @throws SAXException if a SAX-related problem occurs while writing the XML
      */
-    public static void writeXMPPacket(Metadata meta, OutputStream out, boolean readOnlyXMP)

+    public static void writeXMPPacket(Metadata meta, OutputStream out, boolean readOnlyXMP)
             throws TransformerConfigurationException, SAXException {
         StreamResult res = new StreamResult(out);
         writeXML(meta, res, true, readOnlyXMP);
-        
+
     }
-    
-    private static void writeXML(Metadata meta, Result res, 
-                    boolean asXMPPacket, boolean readOnlyXMP) 
+
+    private static void writeXML(Metadata meta, Result res,
+                    boolean asXMPPacket, boolean readOnlyXMP)
                             throws TransformerConfigurationException, SAXException {
         SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
         TransformerHandler handler = tFactory.newTransformerHandler();
@@ -77,11 +77,15 @@
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
         }
         transformer.setOutputProperty(OutputKeys.ENCODING, DEFAULT_ENCODING);
-        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        try {
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        } catch (IllegalArgumentException iae) {
+            //INDENT key is not supported by implementation. That's not tragic, so just ignore.
+        }
         handler.setResult(res);
         handler.startDocument();
         if (asXMPPacket) {
-            handler.processingInstruction("xpacket", 
+            handler.processingInstruction("xpacket",
                     "begin=\"\uFEFF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"");
         }
         meta.toSAX(handler);
@@ -106,5 +110,5 @@
         }
         handler.endDocument();
     }
-    
+
 }

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=746951&r1=746950&r2=746951&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Mon Feb 23 10:40:14 2009
@@ -40,6 +40,10 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="JM" type="fix">
+        Catching IllegalArgumentException in XMPSerializer when the Transformer implementation
+        in use doesn't support the INDENT key.
+      </action>
       <action context="Code" dev="AC" type="fix" fixes-bug="46292" due-to="Jiri Kunhart">
         Added the ability to assign a string value for a key in a postscript dictionary.
       </action>



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


Mime
View raw message