Search code examples
xmlspring-mvcnamespacesxstream

Weird Namespace Being Added by XStream in Spring MVC Controller Response


Does anyone know why I am getting a namespace on an XML node for the property "object"?

It should just be <object>JeffF Cross</object>. The property in debug mode looks like fine and doesn't contain any extra data and is a string. This is in Spring MVC using a Xstream as a serializer.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><getMemberActivitiesResponse><validator/><activities><list>

<object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">JeffF Cross</object>

<validator/><actor>MichaelL FlynnN</actor><actorId>1</actorId><context>Cisco Blogs</context><contextId>1</contextId><dateCreated>3/24/2011 12:00 AM</dateCreated><id>1</id><imageId>9401</imageId><imagePath>http://localhost:8080/Web/resources/assets/users/default.jpgk</imagePath><objectId>54</objectId><verb>is following</verb><verbId>1</verbId></list><total>1</total></activities></getMemberActivitiesResponse>

Solution

  • I fixed this by renaming the property "object" to "directobject". Seems "object" is a keyword that XStream can't parse correctly.