You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/11/15 20:30:58 UTC

svn commit: r1714491 [2/2] - in /webservices/axiom/branches/datatypes: ./ aspects/core-aspects/ aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/fom-aspects/ aspects/fom-aspects/src/main/java/org/apache/axiom/fom/ datatypes/ datatypes/...

Added: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+import org.apache.axiom.datatype.InvariantType;
+
+public interface XSStringType extends InvariantType<String> {
+    XSStringType INSTANCE = new XSStringTypeImpl();
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+import java.text.ParseException;
+
+import org.apache.axiom.datatype.AbstractInvariantType;
+
+final class XSStringTypeImpl extends AbstractInvariantType<String> implements XSStringType {
+    public String parse(String literal) throws ParseException {
+        return literal;
+    }
+
+    public String format(String value) {
+        return value;
+    }
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSStringTypeImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+public interface XSTime extends Temporal {
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTime.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+final class XSTimeImpl extends TemporalImpl implements XSTime {
+    private final int hour;
+    private final int minute;
+    private final int second;
+    private final int nanoSecond;
+    private final String nanoSecondFraction;
+    private final SimpleTimeZone timeZone;
+    
+    XSTimeImpl(int hour, int minute, int second, int nanoSecond, String nanoSecondFraction,
+            SimpleTimeZone timeZone) {
+        this.hour = hour;
+        this.minute = minute;
+        this.second = second;
+        this.nanoSecond = nanoSecond;
+        this.nanoSecondFraction = nanoSecondFraction;
+        this.timeZone = timeZone;
+    }
+
+    @Override
+    boolean hasDatePart() {
+        return false;
+    }
+
+    @Override
+    boolean hasTimePart() {
+        return true;
+    }
+
+    @Override
+    boolean isBC() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    String getAeon() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    int getYear() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    int getMonth() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    int getDay() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    int getHour() {
+        return hour;
+    }
+
+    @Override
+    int getMinute() {
+        return minute;
+    }
+
+    @Override
+    int getSecond() {
+        return second;
+    }
+
+    @Override
+    int getNanoSecond() {
+        return nanoSecond;
+    }
+
+    @Override
+    String getNanoSecondFraction() {
+        return nanoSecondFraction;
+    }
+
+    @Override
+    SimpleTimeZone getTimeZone() {
+        return timeZone;
+    }
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+import org.apache.axiom.datatype.InvariantType;
+
+public interface XSTimeType extends InvariantType<XSTime> {
+
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+final class XSTimeTypeImpl extends TemporalType<XSTime> implements XSTimeType {
+    @Override
+    boolean hasDatePart() {
+        return false;
+    }
+
+    @Override
+    boolean hasTimePart() {
+        return true;
+    }
+
+    @Override
+    XSTime createInstance(boolean bc, String aeon, int year, int month, int day, int hour,
+            int minute, int second, int nanoSecond, String nanoSecondFraction,
+            SimpleTimeZone timeZone) {
+        return new XSTimeImpl(hour, minute, second, nanoSecond, nanoSecondFraction, timeZone);
+    }
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/main/java/org/apache/axiom/datatype/xsd/XSTimeTypeImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/DOMHelperTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/DOMHelperTest.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/DOMHelperTest.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/DOMHelperTest.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.datatype.xsd.XSQNameType;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class DOMHelperTest {
+    @Test
+    public void testGetQNameFromElement() throws Exception {
+        Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+        Element element = document.createElementNS("urn:test", "p:elem");
+        element.setTextContent("p:value");
+        QName qname = DOMHelper.getValue(element, XSQNameType.INSTANCE);
+        assertThat(qname.getNamespaceURI()).isEqualTo("urn:test");
+        assertThat(qname.getLocalPart()).isEqualTo("value");
+        assertThat(qname.getPrefix()).isEqualTo("p");
+    }
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/DOMHelperTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeTest.java?rev=1714491&view=auto
==============================================================================
--- webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeTest.java (added)
+++ webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeTest.java Sun Nov 15 19:30:57 2015
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.datatype.xsd;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.fail;
+
+import java.util.Date;
+
+import org.apache.axiom.datatype.UnexpectedEndOfStringException;
+import org.junit.Test;
+
+public class XSDateTimeTypeTest {
+    @Test
+    public void testParse() throws Exception {
+        XSDateTime dateTime = XSDateTimeType.INSTANCE.parse("2003-12-13T18:30:02Z");
+        assertThat(dateTime.getDate(null)).isEqualTo(new Date(1071340202000L));
+    }
+    
+    @Test
+    public void testParseTruncated() throws Exception {
+        String literal = "2002-10-10T12:00:00-05:00";
+        for (int i=0; i<literal.length()-1; i++) {
+            if (i == 19) {
+                // This would give a valid literal without time zone
+                continue;
+            }
+            String truncatedLiteral = literal.substring(0, i);
+            try {
+                XSDateTimeType.INSTANCE.parse(truncatedLiteral);
+                fail("Expected UnexpectedEndOfStringException for literal \"" + truncatedLiteral + "\"");
+            } catch (UnexpectedEndOfStringException ex) {
+                // Expected
+            }
+        }
+    }
+}

Propchange: webservices/axiom/branches/datatypes/datatypes/src/test/java/org/apache/axiom/datatype/xsd/XSDateTimeTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/datatypes/implementations/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/implementations/pom.xml?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
--- webservices/axiom/branches/datatypes/implementations/pom.xml (original)
+++ webservices/axiom/branches/datatypes/implementations/pom.xml Sun Nov 15 19:30:57 2015
@@ -88,6 +88,7 @@
                     <artifactSet>
                         <includes>
                             <include>${project.groupId}:*-aspects</include>
+                            <include>${project.groupId}:datatypes</include>
                             <include>org.aspectj:aspectjrt</include>
                         </includes>
                     </artifactSet>

Modified: webservices/axiom/branches/datatypes/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/pom.xml?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
--- webservices/axiom/branches/datatypes/pom.xml (original)
+++ webservices/axiom/branches/datatypes/pom.xml Sun Nov 15 19:30:57 2015
@@ -223,6 +223,7 @@
         <module>testing</module>
         <module>aspects</module>
         <module>implementations</module>
+        <module>datatypes</module>
     </modules>
 
     <scm>

Modified: webservices/axiom/branches/datatypes/testing/soap-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/testing/soap-testsuite/pom.xml?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
--- webservices/axiom/branches/datatypes/testing/soap-testsuite/pom.xml (original)
+++ webservices/axiom/branches/datatypes/testing/soap-testsuite/pom.xml Sun Nov 15 19:30:57 2015
@@ -45,6 +45,11 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>datatypes</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>

Modified: webservices/axiom/branches/datatypes/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/datatypes/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java?rev=1714491&r1=1714490&r2=1714491&view=diff
==============================================================================
--- webservices/axiom/branches/datatypes/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java (original)
+++ webservices/axiom/branches/datatypes/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java Sun Nov 15 19:30:57 2015
@@ -20,6 +20,7 @@ package org.apache.axiom.ts.soap;
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.text.ParseException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -30,6 +31,8 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.axiom.datatype.DOMHelper;
+import org.apache.axiom.datatype.xsd.XSQNameType;
 import org.apache.axiom.testing.multiton.Multiton;
 import org.apache.axiom.ts.xml.ComputedMessageContent;
 import org.w3c.dom.Attr;
@@ -40,15 +43,15 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 final class ConvertedSOAPSampleContent extends ComputedMessageContent {
-    private static Map<String,String> faultCodeMap = new HashMap<String,String>();
+    private static Map<QName,QName> faultCodeMap = new HashMap<>();
     
     static {
         faultCodeMap.put(
-                SOAPSpec.SOAP12.getSenderFaultCode().getLocalPart(),
-                SOAPSpec.SOAP11.getSenderFaultCode().getLocalPart());
+                SOAPSpec.SOAP12.getSenderFaultCode(),
+                SOAPSpec.SOAP11.getSenderFaultCode());
         faultCodeMap.put(
-                SOAPSpec.SOAP12.getReceiverFaultCode().getLocalPart(),
-                SOAPSpec.SOAP11.getReceiverFaultCode().getLocalPart());
+                SOAPSpec.SOAP12.getReceiverFaultCode(),
+                SOAPSpec.SOAP11.getReceiverFaultCode());
     }
     
     private final SOAPSample soap12Message;
@@ -112,25 +115,17 @@ final class ConvertedSOAPSampleContent e
                 child = nextChild;
             }
         } else if (type == SOAPFaultChild.CODE) {
-            final Element value = getChild(element, SOAPFaultChild.VALUE);
-            element.setTextContent(transform(value.getTextContent(), new TextTransformer() {
-                @Override
-                public String transform(String in) {
-                    int idx = in.indexOf(':');
-                    if (idx == -1) {
-                        return in;
-                    }
-                    String prefix = in.substring(0, idx);
-                    if (!SOAPSpec.SOAP12.getEnvelopeNamespaceURI().equals(value.lookupNamespaceURI(prefix))) {
-                        return in;
-                    }
-                    String newCode = faultCodeMap.get(in.substring(idx+1));
-                    if (newCode == null) {
-                        return in;
-                    }
-                    return prefix + ":" + newCode;
-                }
-            }));
+            Element value = getChild(element, SOAPFaultChild.VALUE);
+            String[] whitespace = getSurroundingWhitespace(value.getTextContent());
+            QName qname;
+            try {
+                qname = DOMHelper.getValue(value, XSQNameType.INSTANCE);
+            } catch (ParseException ex) {
+                throw new Error(ex);
+            }
+            QName newQName = faultCodeMap.get(qname);
+            DOMHelper.setValue(element, XSQNameType.INSTANCE, newQName == null ? qname : newQName);
+            element.setTextContent(reapplyWhitespace(element.getTextContent(), whitespace));
         } else if (type == SOAPFaultChild.REASON) {
             Element text = getChild(element, SOAPFaultChild.TEXT);
             element.setTextContent(text.getTextContent());
@@ -210,19 +205,19 @@ final class ConvertedSOAPSampleContent e
         return " \r\n\t".indexOf(c) != -1;
     }
     
-    private static String transform(String text, TextTransformer transformer) {
+    private static String[] getSurroundingWhitespace(String text) {
         int start = 0;
         while (isWhitespace(text.charAt(start))) {
-            if (++start == text.length()) {
-                return text;
-            }
+            start++;
         }
         int end = text.length();
         while (isWhitespace(text.charAt(end-1))) {
             end--;
         }
-        return text.substring(0, start)
-                + transformer.transform(text.substring(start, end))
-                + text.substring(end);
+        return new String[] { text.substring(0, start), text.substring(end) };
+    }
+    
+    private static String reapplyWhitespace(String text, String[] surroundingWhitespace) {
+        return surroundingWhitespace[0] + text + surroundingWhitespace[1];
     }
 }