-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json to XML MappedXMLStreamReader: Several Namespace Handling Problems #3
Comments
Index: src/main/java/org/codehaus/jettison/Convention.java--- src/main/java/org/codehaus/jettison/Convention.java (revision 159) public interface Convention {
QName createQName(String name, Node node) throws XMLStreamException; Index: src/main/java/org/codehaus/jettison/Node.java--- src/main/java/org/codehaus/jettison/Node.java (revision 159)
@@ -60,10 +60,12 @@
Index: src/main/java/org/codehaus/jettison/mapped/MappedNamespaceConvention.java--- src/main/java/org/codehaus/jettison/mapped/MappedNamespaceConvention.java (revision 159)
Index: src/main/java/org/codehaus/jettison/mapped/MappedXMLStreamReader.java--- src/main/java/org/codehaus/jettison/mapped/MappedXMLStreamReader.java (revision 159)
+} Property changes on: src/test/java/org/codehaus/jettison/mapped/MappedRoundTripTest.java Added: svn:mime-type -0,0 +1+text/plain Index: src/test/java/org/codehaus/jettison/mapped/MappedXMLStreamReaderTest.java--- src/test/java/org/codehaus/jettison/mapped/MappedXMLStreamReaderTest.java (revision 159) +import java.io.ByteArrayInputStream; import javax.xml.namespace.QName; import junit.framework.TestCase; +import org.codehaus.jettison.AbstractXMLInputFactory;
|
In the JSON to XML case, the MappedNamespaceConvention maps the namespace defined in the key of the JSON object to the parent node. This is not correct it must be mapped to the node.
For example, if you have the JSON docment
{"p1.A":{"p2.B":"value"}}
with the xml2JsonNs map:
Map<String, String> xml2JsonNs = new TreeMap<String, String>();
xml2JsonNs.put("http://namespaceOfElementA", "p1");
xml2JsonNs.put("http://namespaceOfElementB", "p2");
then you get currently the result
valueHowever correct would be
valueI attached the patch.
Meanwhile I detected further problems concerning the namespace handling.
if you have the JSON document
{"simple.root":{"WithoutNs":"value"}}
then you currently get as XML
value
But correct is:
value
because the element "WithoutNS" does not have a namespace.
Secondly the attribute NS are not treated correctly:
If you have
{"simple.root":{"WithoutNs":
{"@ns.attrNs":"ans_v","$":"value"}
}}
then you get
value
But correct is :
value
So I updated the patch to correct these errors also.
Meanwhile my impression is that it would be better to use also for the elements prefixes in the XML because you need the prefixes anyway for the attributes with namespaces.
Regards Franz Forsthofer
The text was updated successfully, but these errors were encountered: