I have want to write a list into the userdata of a node. As far as I save this node I got the following exeption:
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR
I put some effort to debug this issue. This issue comes form com.jme3.scene.UserData.
The write methode of this class stores Arrays, Lists and Maps starting with a number:
case TYPE_LIST:
this.writeList(oc, (List<?>) value, "0");
break;
case TYPE_MAP:
Map<?, ?> map = (Map<?, ?>) value;
this.writeList(oc, map.keySet(), "0");
this.writeList(oc, map.values(), "1");
break;
case TYPE_ARRAY:
this.writeList(oc, Arrays.asList((Object[]) value), "0");
break;
It seems XML does not allow field names starting with an number.
Can someone confirm this behavoir?
Exactly, I am using JME’s serialization for XML and I am geting this error.
I am just save my rootnode. Some of the nodes in my scene graph has Lists in theire userdata. So I am not able to save my game as xml.
As a workaround you could use a Savable object instead of your List/Map.
I guess you need an human readable output for some reason, otherwise i’d tell you to use BinaryExporter instead.
I don’t think the fault lies in UserData, because nowhere is it stated that Savable objects have to follow the XML specification. UserData had no idea that it had to do this.
Actually, XMLExporter is responsible for making sure it generates valid XML given any input. In this case, it can detect that the field name is not valid for XML and “massage” it to fit the specification.