示例#1
0
        /*
         * using (var writer = XmlWriter.Create("file.xml"))
         * {
         * const string Ns = "http://bladibla";
         * const string Prefix = "abx";
         *
         * writer.WriteStartDocument();
         *
         * writer.WriteStartElement("root");
         *
         * // set root namespace
         * writer.WriteAttributeString("xmlns", Prefix, null, Ns);
         *
         * writer.WriteStartElement(Prefix, "child", Ns);
         * writer.WriteAttributeString("id", "A");
         *
         * writer.WriteStartElement("grandchild");
         * writer.WriteAttributeString("id", "B");
         *
         * writer.WriteElementString(Prefix, "grandgrandchild", Ns, null);
         *
         * // grandchild
         * writer.WriteEndElement();
         * // child
         * writer.WriteEndElement();
         * // root
         * writer.WriteEndElement();
         *
         * writer.WriteEndDocument();
         * }
         * <?xml version="1.0" encoding="utf-8"?>
         * <root xmlns:abx="http://bladibla">
         * <abx:child id="A">
         * <grandchild id="B">
         * <abx:grandgrandchild />
         * </grandchild>
         * </abx:child>
         * </root>
         *
         */

        internal void WriteStartRootElement(XmlWriter writer, int?updateSequence)
        {
            writer.WriteAttributeString("version", VersionString);
            if (updateSequence.HasValue)
            {
                writer.WriteAttributeString("updateSequence", updateSequence.Value.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (Version >= WmsVersionEnum.Version_1_3_0)
            {
                writer.WriteAttributeString("xmlns", "xlink", null, WmsNamespaces.Xlink);
                writer.WriteAttributeString("xmlns", "xsi", null, WmsNamespaces.Xsi);
                writer.WriteAttributeString("xsi", "schemaLocation", null, $"{WmsNamespaces.Wms}");
                writer.WriteStartElement("WMS_Capabilities", WmsNamespaces.Wms, WmsNamespaces.WmsSchemaUrl(Version, "capabilities"));
            }
            else
            {
                writer.WriteStartElement("WMT_MS_Capabilities");
            }
        }
示例#2
0
        /*
         * using (var writer = XmlWriter.Create("file.xml"))
         * {
         * const string Ns = "http://bladibla";
         * const string Prefix = "abx";
         *
         * writer.WriteStartDocument();
         *
         * writer.WriteStartElement("root");
         *
         * // set root namespace
         * writer.WriteAttributeString("xmlns", Prefix, null, Ns);
         *
         * writer.WriteStartElement(Prefix, "child", Ns);
         * writer.WriteAttributeString("id", "A");
         *
         * writer.WriteStartElement("grandchild");
         * writer.WriteAttributeString("id", "B");
         *
         * writer.WriteElementString(Prefix, "grandgrandchild", Ns, null);
         *
         * // grandchild
         * writer.WriteEndElement();
         * // child
         * writer.WriteEndElement();
         * // root
         * writer.WriteEndElement();
         *
         * writer.WriteEndDocument();
         * }
         * <?xml version="1.0" encoding="utf-8"?>
         * <root xmlns:abx="http://bladibla">
         * <abx:child id="A">
         * <grandchild id="B">
         * <abx:grandgrandchild />
         * </grandchild>
         * </abx:child>
         * </root>
         *
         */

        internal void WriteStartRootElement(XmlWriter writer, string updateSequence)
        {
            writer.WriteAttributeString("version", VersionString);
            if (updateSequence != null)
            {
                writer.WriteAttributeString("updateSequence", updateSequence);
            }

            if (Version >= WmsVersionEnum.Version_1_3_0)
            {
                writer.WriteAttributeString("xmlns", "xlink", string.Empty, WmsNamespaces.Xlink);
                writer.WriteAttributeString("xmlns", "xsi", string.Empty, WmsNamespaces.Xsi);
                writer.WriteAttributeString("xsi", "schemaLocation", string.Empty, $"{WmsNamespaces.Wms}");
                writer.WriteStartElement("WMS_Capabilities", WmsNamespaces.Wms, WmsNamespaces.WmsSchemaUrl(Version, "capabilities"));
            }
            else
            {
                writer.WriteStartElement("WMT_MS_Capabilities");
            }
        }