cleaning up returned XML REST doclet (no more xsi, xsd)
parent
91b75eda85
commit
c2925dcd40
|
@ -129,7 +129,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
|||
{
|
||||
// complete region details requested
|
||||
XmlSerializer xs = new XmlSerializer(typeof(RegionDetails));
|
||||
xs.Serialize(XmlWriter, details);
|
||||
xs.Serialize(XmlWriter, details, _xmlNs);
|
||||
return XmlWriterResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ using OpenSim.Region.Environment.Scenes;
|
|||
|
||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||
{
|
||||
[XmlRoot(ElementName="region")]
|
||||
[XmlRoot(ElementName="region", IsNullable = false)]
|
||||
public class RegionDetails
|
||||
{
|
||||
public string region_name;
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
|||
[Extension("/OpenSim/Startup")]
|
||||
public partial class RestRegionPlugin : RestPlugin
|
||||
{
|
||||
private static XmlSerializerNamespaces _xmlNs;
|
||||
|
||||
#region overriding properties
|
||||
public override string Name
|
||||
{
|
||||
|
@ -89,6 +91,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
|||
}
|
||||
m_log.InfoFormat("{0} REST region plugin enabled", MsgID);
|
||||
|
||||
_xmlNs = new XmlSerializerNamespaces();
|
||||
_xmlNs.Add(String.Empty, String.Empty);
|
||||
|
||||
// add REST method handlers
|
||||
AddRestStreamHandler("GET", "/regions/", GetHandler);
|
||||
AddRestStreamHandler("POST", "/regions/", PostHandler);
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
|||
// which all REST URLs
|
||||
// are living
|
||||
private StringWriter _sw = null;
|
||||
private XmlTextWriter _xw = null;
|
||||
private RestXmlWriter _xw = null;
|
||||
|
||||
private string _godkey;
|
||||
private int _reqk;
|
||||
|
@ -159,7 +159,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
|||
if (null == _xw)
|
||||
{
|
||||
_sw = new StringWriter();
|
||||
_xw = new XmlTextWriter(_sw);
|
||||
_xw = new RestXmlWriter(_sw);
|
||||
_xw.Formatting = Formatting.Indented;
|
||||
}
|
||||
return _xw; }
|
||||
|
@ -170,6 +170,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
|||
get
|
||||
{
|
||||
_xw.Flush();
|
||||
_xw.Close();
|
||||
_xw = null;
|
||||
|
||||
return _sw.ToString();
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.Rest
|
||||
{
|
||||
public class RestXmlWriter: XmlTextWriter
|
||||
{
|
||||
public RestXmlWriter(TextWriter textWriter) : base(textWriter)
|
||||
{
|
||||
}
|
||||
|
||||
public RestXmlWriter(Stream stream) : this(stream, Encoding.UTF8)
|
||||
{
|
||||
}
|
||||
|
||||
public RestXmlWriter(Stream stream, Encoding enc) : base(stream, enc)
|
||||
{
|
||||
}
|
||||
|
||||
public override void WriteStartDocument()
|
||||
{
|
||||
}
|
||||
|
||||
public override void WriteStartDocument(bool standalone)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue