You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sc...@apache.org on 2007/10/17 19:46:47 UTC

svn commit: r585599 - /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/util/OMSerializerUtil.java

Author: scheu
Date: Wed Oct 17 10:46:46 2007
New Revision: 585599

URL: http://svn.apache.org/viewvc?rev=585599&view=rev
Log:
WSCOMMONS-262
Contributor:Rich Scheuerle
Update "setPrefixBeforeStartElement" toggle to use a property in addition to the current
behavior.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/util/OMSerializerUtil.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/util/OMSerializerUtil.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/util/OMSerializerUtil.java?rev=585599&r1=585598&r2=585599&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/util/OMSerializerUtil.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/util/OMSerializerUtil.java Wed Oct 17 10:46:46 2007
@@ -36,6 +36,12 @@
 public class OMSerializerUtil {
 
     static long nsCounter = 0;
+    
+    // This property should be used by the parser to indicate whether 
+    // setPrefix should be done before or after the Start Element event.
+    // This property is not yet a standard, but at least one parser.
+    private static final String IS_SET_PREFIX_BEFORE_PROPERTY = 
+        "javax.xml.stream.XMLStreamWriter.isSetPrefixBeforeStartElement";
 
     /**
      * Method serializeEndpart.
@@ -156,8 +162,21 @@
      * @return true if setPrefix should be generated before startElement
      */
     public static boolean isSetPrefixBeforeStartElement(XMLStreamWriter writer) {
+        try {
+            Boolean value = (Boolean)writer.getProperty(IS_SET_PREFIX_BEFORE_PROPERTY);
+            // this will always be false if the property is defined
+            if (value != null) {
+                return value.booleanValue();
+            }
+        }
+        catch (IllegalArgumentException e) {
+            // Some parsers throw an exception for unknown properties.
+        }
+        // Fallback: Toggle based on sun or woodstox implementation.
         NamespaceContext nc = writer.getNamespaceContext();
-        return (nc == null || (nc.getClass().getName().indexOf("wstx") == -1 && nc.getClass().getName().indexOf("sun") == -1));
+        return (nc == null || 
+                (nc.getClass().getName().indexOf("wstx") == -1 && 
+                 nc.getClass().getName().indexOf("sun") == -1));
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org