#region Disclaimer / License
// Copyright (C) 2006, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
using System.Xml;
namespace OSGeo.MapGuide.MaestroAPI
{
///
/// Class that represents a the layout of a datasource
///
public class FeatureSourceDescription
{
private FeatureSourceSchema[] m_schemas;
public FeatureSourceDescription(System.IO.Stream stream)
{
XmlDocument doc = new XmlDocument();
doc.Load(stream);
if (doc.FirstChild.Name != "xml")
throw new Exception("Bad document");
if (doc.ChildNodes.Count != 2 || doc.ChildNodes[1].Name != "xs:schema")
throw new Exception("Bad document");
XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
mgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
mgr.AddNamespace("gml", "http://www.opengis.net/gml");
mgr.AddNamespace("fdo", "http://fdo.osgeo.org/schemas");
XmlNodeList lst = doc.SelectNodes("xs:schema/xs:complexType[@abstract='false']", mgr);
m_schemas = new FeatureSourceSchema[lst.Count];
for(int i = 0;i 0)
m_schema = m_schema.Substring(m_schema.LastIndexOf("/") + 1);
m_name = node.Attributes["name"].Value;
if (m_name.EndsWith("Type"))
m_name = m_name.Substring(0, m_name.Length - "Type".Length);
XmlNodeList lst;
if (node.ChildNodes.Count == 0)
{
m_columns = new FeatureSetColumn[0];
return;
}
else if (node.FirstChild.Name == "xs:sequence")
lst = node.SelectNodes("xs:sequence/xs:element", mgr);
else
lst = node.SelectNodes("xs:complexContent/xs:extension/xs:sequence/xs:element", mgr);
m_columns = new FeatureSetColumn[lst.Count];
for(int i = 0;i