diff options
author | Justin Clark-Casey (justincc) | 2014-08-29 19:08:23 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-08-29 19:08:23 +0100 |
commit | 1b75ec5647afeb9fbdad78f70c0c90a829bba076 (patch) | |
tree | 500744dddfc3f4238391d9e04ca431669f742ce5 /OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |
parent | Fix recent regression test TestDeserializeXmlObjectWithOtherParts() which was... (diff) | |
download | opensim-SC_OLD-1b75ec5647afeb9fbdad78f70c0c90a829bba076.zip opensim-SC_OLD-1b75ec5647afeb9fbdad78f70c0c90a829bba076.tar.gz opensim-SC_OLD-1b75ec5647afeb9fbdad78f70c0c90a829bba076.tar.bz2 opensim-SC_OLD-1b75ec5647afeb9fbdad78f70c0c90a829bba076.tar.xz |
Ignore whitespace when reading serialized XML objects.
This was previously effectively being done by XmlDocument in the multiple passes through the XML.
This change tells XmlReader to ignore whitespace. This also means changing arguments to use XmlReader instead of XmlTextReader (a descendent of XmlReader) directly.
XmlReader.Create() has been the recommend way to create XML readers since .NET 2.0 as per MS SDK and is the only way to specific ignore whitespace settings.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cbb4fe7..3489873 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -2214,49 +2214,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
2214 | 2214 | ||
2215 | try | 2215 | try |
2216 | { | 2216 | { |
2217 | using (XmlTextReader reader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) | 2217 | using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) |
2218 | { | 2218 | { |
2219 | reader.Read(); | 2219 | using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) |
2220 | bool isSingleObject = reader.Name != "CoalescedObject"; | ||
2221 | |||
2222 | if (isSingleObject || isAttachment) | ||
2223 | { | 2220 | { |
2224 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(reader); | 2221 | reader.Read(); |
2225 | objlist.Add(g); | 2222 | bool isSingleObject = reader.Name != "CoalescedObject"; |
2226 | veclist.Add(Vector3.Zero); | 2223 | |
2227 | bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); | 2224 | if (isSingleObject || isAttachment) |
2228 | return true; | ||
2229 | } | ||
2230 | else | ||
2231 | { | ||
2232 | XmlDocument doc = new XmlDocument(); | ||
2233 | doc.LoadXml(xmlData); | ||
2234 | XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); | ||
2235 | XmlElement coll = (XmlElement)e; | ||
2236 | float bx = Convert.ToSingle(coll.GetAttribute("x")); | ||
2237 | float by = Convert.ToSingle(coll.GetAttribute("y")); | ||
2238 | float bz = Convert.ToSingle(coll.GetAttribute("z")); | ||
2239 | bbox = new Vector3(bx, by, bz); | ||
2240 | offsetHeight = 0; | ||
2241 | |||
2242 | XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); | ||
2243 | foreach (XmlNode n in groups) | ||
2244 | { | 2225 | { |
2245 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | 2226 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(reader); |
2246 | objlist.Add(g); | 2227 | objlist.Add(g); |
2247 | 2228 | veclist.Add(Vector3.Zero); | |
2248 | XmlElement el = (XmlElement)n; | 2229 | bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); |
2249 | string rawX = el.GetAttribute("offsetx"); | 2230 | return true; |
2250 | string rawY = el.GetAttribute("offsety"); | ||
2251 | string rawZ = el.GetAttribute("offsetz"); | ||
2252 | |||
2253 | float x = Convert.ToSingle(rawX); | ||
2254 | float y = Convert.ToSingle(rawY); | ||
2255 | float z = Convert.ToSingle(rawZ); | ||
2256 | veclist.Add(new Vector3(x, y, z)); | ||
2257 | } | 2231 | } |
2232 | else | ||
2233 | { | ||
2234 | XmlDocument doc = new XmlDocument(); | ||
2235 | doc.LoadXml(xmlData); | ||
2236 | XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); | ||
2237 | XmlElement coll = (XmlElement)e; | ||
2238 | float bx = Convert.ToSingle(coll.GetAttribute("x")); | ||
2239 | float by = Convert.ToSingle(coll.GetAttribute("y")); | ||
2240 | float bz = Convert.ToSingle(coll.GetAttribute("z")); | ||
2241 | bbox = new Vector3(bx, by, bz); | ||
2242 | offsetHeight = 0; | ||
2243 | |||
2244 | XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); | ||
2245 | foreach (XmlNode n in groups) | ||
2246 | { | ||
2247 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | ||
2248 | objlist.Add(g); | ||
2249 | |||
2250 | XmlElement el = (XmlElement)n; | ||
2251 | string rawX = el.GetAttribute("offsetx"); | ||
2252 | string rawY = el.GetAttribute("offsety"); | ||
2253 | string rawZ = el.GetAttribute("offsetz"); | ||
2254 | |||
2255 | float x = Convert.ToSingle(rawX); | ||
2256 | float y = Convert.ToSingle(rawY); | ||
2257 | float z = Convert.ToSingle(rawZ); | ||
2258 | veclist.Add(new Vector3(x, y, z)); | ||
2259 | } | ||
2258 | 2260 | ||
2259 | return false; | 2261 | return false; |
2262 | } | ||
2260 | } | 2263 | } |
2261 | } | 2264 | } |
2262 | } | 2265 | } |