From 7fc7949157739dd6b446abdbdd6d9981d2745246 Mon Sep 17 00:00:00 2001 From: scottkurz Date: Wed, 27 Apr 2011 21:10:49 +0000 Subject: Pass through XMLStreamReader rather than returning 'null' on xsi:nil="true" element. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1097243 13f79535-47bb-0310-9956-ffa450edef68 --- .../axiom/OMElement2XMLStreamReader.java | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java b/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java index e0da9ad428..4c7be59466 100644 --- a/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java +++ b/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java @@ -32,20 +32,22 @@ import org.apache.tuscany.sca.databinding.BaseTransformer; */ public class OMElement2XMLStreamReader extends BaseTransformer implements PullTransformer { - // private XmlOptions options; - - public static final QName QNAME_NIL = new QName("http://www.w3.org/2001/XMLSchema-instance", "nil"); + /* + * Reverting the behavior here in 2.x (though not in 1.x) to pass through the + * XMLStreamReader even in the case of an xsi:nil element. This appears to only + * be relied upon in 1.x by the XMLStreamReader2CallableReference transformer, and can + * be changed in 2.x without breaking anything. + * + * I'd preferto move the responsibility for handling xsi:nil to transformers such as + * XMLStreamReader2CallableReference. While for something like JAXB, xsi:nil would + * typically map to 'null', for something XML-centric like DOM I think it's more useful + * to transform to a DOM Element with xsi:nil="true". For now I'll leave this issue + * unaddressed in 2.x, where we'd have to adjust XMLStreamReader2CallableReference in + * order to make a change like this. + */ public XMLStreamReader transform(OMElement source, TransformationContext context) { - if (source == null) { - return null; - } else { - if ("true".equals(source.getAttributeValue(QNAME_NIL))) { - return null; - } else { - return source.getXMLStreamReader(); - } - } + return source != null ? source.getXMLStreamReader() : null; } @Override -- cgit v1.2.3