[jboss-svn-commits] JBL Code SVN: r25140 - in labs/jbossesb/trunk/product/services/soap/src/main: resources/org/jboss/soa/esb/actions/soap and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Feb 6 10:49:48 EST 2009


Author: tfennelly
Date: 2009-02-06 10:49:48 -0500 (Fri, 06 Feb 2009)
New Revision: 25140

Added:
   labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/DenormalizedAttributeValueSerializer.java
Modified:
   labs/jbossesb/trunk/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml
Log:
https://jira.jboss.org/jira/browse/JBESB-2340

Added: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/DenormalizedAttributeValueSerializer.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/DenormalizedAttributeValueSerializer.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/DenormalizedAttributeValueSerializer.java	2009-02-06 15:49:48 UTC (rev 25140)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.milyn.delivery.dom.serialize.DefaultSerializationUnit;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Attr;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class DenormalizedAttributeValueSerializer extends DefaultSerializationUnit {
+
+    private StringBuilder denormalizeBuffer = new StringBuilder();
+
+    /**
+     * Write the element attributes.
+     * @param attributes The element attibutes.
+     * @param writer The writer to be written to.
+     * @throws IOException Exception writing output.
+     */
+    protected void writeAttributes(NamedNodeMap attributes, Writer writer) throws IOException {
+        int attribCount = attributes.getLength();
+
+        for(int i = 0; i < attribCount; i++) {
+            Attr attribute = (Attr)attributes.item(i);
+            String attribValue = attribute.getValue();
+            int enclosingChar = (int)'"';
+
+            writer.write((int)' ');
+            writer.write(attribute.getName());
+            writer.write((int)'=');
+            if(attribValue.indexOf((int)'"') != -1) {
+                enclosingChar = (int)'\'';
+            }
+            writer.write(enclosingChar);
+            writer.write(denormalize(attribValue));
+            writer.write(enclosingChar);
+        }
+    }
+
+    private String denormalize(String attribValue) {
+        denormalizeBuffer.setLength(0);
+
+        //
+        // Reversing the normalization work done on the attribute values by the
+        // parser (http://www.w3.org/TR/2006/REC-xml-20060816/#AVNormalize). Assumption
+        // here is that there's no entity/char values in the attribute!!
+        //
+
+        for(int i = 0; i < attribValue.length(); i++) {
+            char character = attribValue.charAt(i);
+
+            if(character == '<') {
+                denormalizeBuffer.append("&lt;");
+            } else if(character == '>') {
+                denormalizeBuffer.append("&gt;");
+            } else if(character == '&') {
+                denormalizeBuffer.append("&amp;");
+            } else if(character == '\'') {
+                denormalizeBuffer.append("&apos;");
+            } else if(character == '"') {
+                denormalizeBuffer.append("&quot;");
+            } else {
+                denormalizeBuffer.append(character);
+            }
+        }
+
+        return denormalizeBuffer.toString();
+    }
+}


Property changes on: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/DenormalizedAttributeValueSerializer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml	2009-02-06 15:47:58 UTC (rev 25139)
+++ labs/jbossesb/trunk/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml	2009-02-06 15:49:48 UTC (rev 25140)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
 
     <resource-config selector="import">
         <resource>org.jboss.soa.esb.actions.soap.WsdlEndpointTransformer</resource>
@@ -13,11 +13,8 @@
         <resource>org.jboss.soa.esb.actions.soap.WsdlEndpointTransformer</resource>
     </resource-config>
 
-    <!--
-        We explicitly want to close empty elements.  They're left open by default.
-    -->
     <resource-config selector="*">
-        <resource>org.milyn.delivery.dom.serialize.DefaultSerializationUnit</resource>
+        <resource>org.jboss.soa.esb.actions.soap.DenormalizedAttributeValueSerializer</resource>
         <param name="closeEmptyElements">true</param>
     </resource-config>
 




More information about the jboss-svn-commits mailing list