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/Framework/Serialization | |
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 '')
3 files changed, 31 insertions, 31 deletions
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index db46ea8..6debf65 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Framework.Serialization.External | |||
51 | /// <param name="xtr"></param> | 51 | /// <param name="xtr"></param> |
52 | /// <returns>true on successful, false if there were any processing failures</returns> | 52 | /// <returns>true on successful, false if there were any processing failures</returns> |
53 | public static bool ExecuteReadProcessors<NodeType>( | 53 | public static bool ExecuteReadProcessors<NodeType>( |
54 | NodeType nodeToFill, Dictionary<string, Action<NodeType, XmlTextReader>> processors, XmlTextReader xtr) | 54 | NodeType nodeToFill, Dictionary<string, Action<NodeType, XmlReader>> processors, XmlReader xtr) |
55 | { | 55 | { |
56 | return ExecuteReadProcessors( | 56 | return ExecuteReadProcessors( |
57 | nodeToFill, | 57 | nodeToFill, |
@@ -75,8 +75,8 @@ namespace OpenSim.Framework.Serialization.External | |||
75 | /// <returns>true on successful, false if there were any processing failures</returns> | 75 | /// <returns>true on successful, false if there were any processing failures</returns> |
76 | public static bool ExecuteReadProcessors<NodeType>( | 76 | public static bool ExecuteReadProcessors<NodeType>( |
77 | NodeType nodeToFill, | 77 | NodeType nodeToFill, |
78 | Dictionary<string, Action<NodeType, XmlTextReader>> processors, | 78 | Dictionary<string, Action<NodeType, XmlReader>> processors, |
79 | XmlTextReader xtr, | 79 | XmlReader xtr, |
80 | Action<NodeType, string, Exception> parseExceptionAction) | 80 | Action<NodeType, string, Exception> parseExceptionAction) |
81 | { | 81 | { |
82 | bool errors = false; | 82 | bool errors = false; |
@@ -88,7 +88,7 @@ namespace OpenSim.Framework.Serialization.External | |||
88 | 88 | ||
89 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); | 89 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); |
90 | 90 | ||
91 | Action<NodeType, XmlTextReader> p = null; | 91 | Action<NodeType, XmlReader> p = null; |
92 | if (processors.TryGetValue(xtr.Name, out p)) | 92 | if (processors.TryGetValue(xtr.Name, out p)) |
93 | { | 93 | { |
94 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); | 94 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); |
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index 4b5326a..e42d56f 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |||
@@ -44,11 +44,11 @@ namespace OpenSim.Framework.Serialization.External | |||
44 | { | 44 | { |
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors | 47 | private static Dictionary<string, Action<LandData, XmlReader>> m_ldProcessors |
48 | = new Dictionary<string, Action<LandData, XmlTextReader>>(); | 48 | = new Dictionary<string, Action<LandData, XmlReader>>(); |
49 | 49 | ||
50 | private static Dictionary<string, Action<LandAccessEntry, XmlTextReader>> m_laeProcessors | 50 | private static Dictionary<string, Action<LandAccessEntry, XmlReader>> m_laeProcessors |
51 | = new Dictionary<string, Action<LandAccessEntry, XmlTextReader>>(); | 51 | = new Dictionary<string, Action<LandAccessEntry, XmlReader>>(); |
52 | 52 | ||
53 | static LandDataSerializer() | 53 | static LandDataSerializer() |
54 | { | 54 | { |
@@ -134,7 +134,7 @@ namespace OpenSim.Framework.Serialization.External | |||
134 | "AccessList", (lae, xtr) => lae.Flags = (AccessList)Convert.ToUInt32(xtr.ReadElementString("AccessList"))); | 134 | "AccessList", (lae, xtr) => lae.Flags = (AccessList)Convert.ToUInt32(xtr.ReadElementString("AccessList"))); |
135 | } | 135 | } |
136 | 136 | ||
137 | public static void ProcessParcelAccessList(LandData ld, XmlTextReader xtr) | 137 | public static void ProcessParcelAccessList(LandData ld, XmlReader xtr) |
138 | { | 138 | { |
139 | if (!xtr.IsEmptyElement) | 139 | if (!xtr.IsEmptyElement) |
140 | { | 140 | { |
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index 135cefb..994cede 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |||
@@ -46,8 +46,8 @@ namespace OpenSim.Framework.Serialization.External | |||
46 | { | 46 | { |
47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors | 49 | private static Dictionary<string, Action<InventoryItemBase, XmlReader>> m_InventoryItemXmlProcessors |
50 | = new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>(); | 50 | = new Dictionary<string, Action<InventoryItemBase, XmlReader>>(); |
51 | 51 | ||
52 | #region InventoryItemBase Processor initialization | 52 | #region InventoryItemBase Processor initialization |
53 | static UserInventoryItemSerializer() | 53 | static UserInventoryItemSerializer() |
@@ -76,103 +76,103 @@ namespace OpenSim.Framework.Serialization.External | |||
76 | #endregion | 76 | #endregion |
77 | 77 | ||
78 | #region InventoryItemBase Processors | 78 | #region InventoryItemBase Processors |
79 | private static void ProcessName(InventoryItemBase item, XmlTextReader reader) | 79 | private static void ProcessName(InventoryItemBase item, XmlReader reader) |
80 | { | 80 | { |
81 | item.Name = reader.ReadElementContentAsString("Name", String.Empty); | 81 | item.Name = reader.ReadElementContentAsString("Name", String.Empty); |
82 | } | 82 | } |
83 | 83 | ||
84 | private static void ProcessID(InventoryItemBase item, XmlTextReader reader) | 84 | private static void ProcessID(InventoryItemBase item, XmlReader reader) |
85 | { | 85 | { |
86 | item.ID = Util.ReadUUID(reader, "ID"); | 86 | item.ID = Util.ReadUUID(reader, "ID"); |
87 | } | 87 | } |
88 | 88 | ||
89 | private static void ProcessInvType(InventoryItemBase item, XmlTextReader reader) | 89 | private static void ProcessInvType(InventoryItemBase item, XmlReader reader) |
90 | { | 90 | { |
91 | item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); | 91 | item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); |
92 | } | 92 | } |
93 | 93 | ||
94 | private static void ProcessCreatorUUID(InventoryItemBase item, XmlTextReader reader) | 94 | private static void ProcessCreatorUUID(InventoryItemBase item, XmlReader reader) |
95 | { | 95 | { |
96 | item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty); | 96 | item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty); |
97 | } | 97 | } |
98 | 98 | ||
99 | private static void ProcessCreatorID(InventoryItemBase item, XmlTextReader reader) | 99 | private static void ProcessCreatorID(InventoryItemBase item, XmlReader reader) |
100 | { | 100 | { |
101 | // when it exists, this overrides the previous | 101 | // when it exists, this overrides the previous |
102 | item.CreatorId = reader.ReadElementContentAsString("CreatorID", String.Empty); | 102 | item.CreatorId = reader.ReadElementContentAsString("CreatorID", String.Empty); |
103 | } | 103 | } |
104 | 104 | ||
105 | private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader) | 105 | private static void ProcessCreationDate(InventoryItemBase item, XmlReader reader) |
106 | { | 106 | { |
107 | item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); | 107 | item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); |
108 | } | 108 | } |
109 | 109 | ||
110 | private static void ProcessOwner(InventoryItemBase item, XmlTextReader reader) | 110 | private static void ProcessOwner(InventoryItemBase item, XmlReader reader) |
111 | { | 111 | { |
112 | item.Owner = Util.ReadUUID(reader, "Owner"); | 112 | item.Owner = Util.ReadUUID(reader, "Owner"); |
113 | } | 113 | } |
114 | 114 | ||
115 | private static void ProcessDescription(InventoryItemBase item, XmlTextReader reader) | 115 | private static void ProcessDescription(InventoryItemBase item, XmlReader reader) |
116 | { | 116 | { |
117 | item.Description = reader.ReadElementContentAsString("Description", String.Empty); | 117 | item.Description = reader.ReadElementContentAsString("Description", String.Empty); |
118 | } | 118 | } |
119 | 119 | ||
120 | private static void ProcessAssetType(InventoryItemBase item, XmlTextReader reader) | 120 | private static void ProcessAssetType(InventoryItemBase item, XmlReader reader) |
121 | { | 121 | { |
122 | item.AssetType = reader.ReadElementContentAsInt("AssetType", String.Empty); | 122 | item.AssetType = reader.ReadElementContentAsInt("AssetType", String.Empty); |
123 | } | 123 | } |
124 | 124 | ||
125 | private static void ProcessAssetID(InventoryItemBase item, XmlTextReader reader) | 125 | private static void ProcessAssetID(InventoryItemBase item, XmlReader reader) |
126 | { | 126 | { |
127 | item.AssetID = Util.ReadUUID(reader, "AssetID"); | 127 | item.AssetID = Util.ReadUUID(reader, "AssetID"); |
128 | } | 128 | } |
129 | 129 | ||
130 | private static void ProcessSaleType(InventoryItemBase item, XmlTextReader reader) | 130 | private static void ProcessSaleType(InventoryItemBase item, XmlReader reader) |
131 | { | 131 | { |
132 | item.SaleType = (byte)reader.ReadElementContentAsInt("SaleType", String.Empty); | 132 | item.SaleType = (byte)reader.ReadElementContentAsInt("SaleType", String.Empty); |
133 | } | 133 | } |
134 | 134 | ||
135 | private static void ProcessSalePrice(InventoryItemBase item, XmlTextReader reader) | 135 | private static void ProcessSalePrice(InventoryItemBase item, XmlReader reader) |
136 | { | 136 | { |
137 | item.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); | 137 | item.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); |
138 | } | 138 | } |
139 | 139 | ||
140 | private static void ProcessBasePermissions(InventoryItemBase item, XmlTextReader reader) | 140 | private static void ProcessBasePermissions(InventoryItemBase item, XmlReader reader) |
141 | { | 141 | { |
142 | item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); | 142 | item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); |
143 | } | 143 | } |
144 | 144 | ||
145 | private static void ProcessCurrentPermissions(InventoryItemBase item, XmlTextReader reader) | 145 | private static void ProcessCurrentPermissions(InventoryItemBase item, XmlReader reader) |
146 | { | 146 | { |
147 | item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); | 147 | item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); |
148 | } | 148 | } |
149 | 149 | ||
150 | private static void ProcessEveryOnePermissions(InventoryItemBase item, XmlTextReader reader) | 150 | private static void ProcessEveryOnePermissions(InventoryItemBase item, XmlReader reader) |
151 | { | 151 | { |
152 | item.EveryOnePermissions = (uint)reader.ReadElementContentAsInt("EveryOnePermissions", String.Empty); | 152 | item.EveryOnePermissions = (uint)reader.ReadElementContentAsInt("EveryOnePermissions", String.Empty); |
153 | } | 153 | } |
154 | 154 | ||
155 | private static void ProcessNextPermissions(InventoryItemBase item, XmlTextReader reader) | 155 | private static void ProcessNextPermissions(InventoryItemBase item, XmlReader reader) |
156 | { | 156 | { |
157 | item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); | 157 | item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); |
158 | } | 158 | } |
159 | 159 | ||
160 | private static void ProcessFlags(InventoryItemBase item, XmlTextReader reader) | 160 | private static void ProcessFlags(InventoryItemBase item, XmlReader reader) |
161 | { | 161 | { |
162 | item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); | 162 | item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); |
163 | } | 163 | } |
164 | 164 | ||
165 | private static void ProcessGroupID(InventoryItemBase item, XmlTextReader reader) | 165 | private static void ProcessGroupID(InventoryItemBase item, XmlReader reader) |
166 | { | 166 | { |
167 | item.GroupID = Util.ReadUUID(reader, "GroupID"); | 167 | item.GroupID = Util.ReadUUID(reader, "GroupID"); |
168 | } | 168 | } |
169 | 169 | ||
170 | private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader) | 170 | private static void ProcessGroupOwned(InventoryItemBase item, XmlReader reader) |
171 | { | 171 | { |
172 | item.GroupOwned = Util.ReadBoolean(reader); | 172 | item.GroupOwned = Util.ReadBoolean(reader); |
173 | } | 173 | } |
174 | 174 | ||
175 | private static void ProcessCreatorData(InventoryItemBase item, XmlTextReader reader) | 175 | private static void ProcessCreatorData(InventoryItemBase item, XmlReader reader) |
176 | { | 176 | { |
177 | item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty); | 177 | item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty); |
178 | } | 178 | } |