예제 #1
0
        /// <summary>
        /// Get AutoloaderStatus
        /// </summary>
        /// <returns></returns>
        public string GenerateProdRequestAutoloaderStatus()
        {
            StringBuilder sb             = new StringBuilder();
            XmlTextWriter xmlProdRequest = new XmlTextWriter(new StringWriter(sb));

            xmlProdRequest.Formatting  = Formatting.Indented;
            xmlProdRequest.Indentation = 4;

            xmlProdRequest.WriteStartDocument();

            //Write document type
            try
            {
                xmlProdRequest.WriteDocType("ProductionServerRequest", null, strSysFolder + "\\XML\\ProductionServerRequest_1.9.dtd", null);
            }
            catch
            {
                xmlProdRequest.WriteDocType("ProductionServerRequest", null, strSysFolder + "\\XML\\ProductionServerRequest_1.1.dtd", null);
            }

            //Write Production request root element
            xmlProdRequest.WriteStartElement("ProductionServerRequest");

            //Write ServerID Attribute to the ProductionRequest root Element
            xmlProdRequest.WriteAttributeString("ServerId", strServer + "_PS01");

            //Write ClientId Attribute to the ProductionRequest root Element
            xmlProdRequest.WriteAttributeString("ClientId", strClientID);

            //Write getparametersettings Element
            xmlProdRequest.WriteStartElement("GetServerStatus");

            //Write getparametersettings Element
            xmlProdRequest.WriteAttributeString("GetAutoloaderStatus", "true");

            //Write getparametersettings Element
            xmlProdRequest.WriteAttributeString("GetCommandLineSwitches", "true");

            //Write getparametersettings Element
            xmlProdRequest.WriteAttributeString("GetActivationInfo", "true");

            xmlProdRequest.WriteAttributeString("GetAdaptiveTracingInfo", "true");

            //End getparametersettings element
            //xmlProdRequest.WriteEndElement();

            //End getparametersettings element
            xmlProdRequest.WriteEndElement();

            //end ProductionRequest Element
            xmlProdRequest.WriteEndElement();

            //End the document and close the writer
            xmlProdRequest.WriteEndDocument();
            xmlProdRequest.Close();

            return(sb.ToString());
        }
예제 #2
0
        /// <summary>
        /// Reset Bins
        /// </summary>
        public string GenerateProdRequestResetBins(string AutoLoader)
        {
            StringBuilder sbTest         = new StringBuilder();
            XmlTextWriter xmlProdRequest = new XmlTextWriter(new StringWriter(sbTest));

            xmlProdRequest.Formatting  = Formatting.Indented;
            xmlProdRequest.Indentation = 4;

            xmlProdRequest.WriteStartDocument();

            //Write document type
            try
            {
                xmlProdRequest.WriteDocType("ProductionServerRequest", null, strSysFolder + @"\XML\ProductionServerRequest_1.9.dtd", null);
            }
            catch
            {
                xmlProdRequest.WriteDocType("ProductionServerRequest", null, strSysFolder + @"\XML\ProductionServerRequest_1.1.dtd", null);
            }

            //Write Production request root element
            xmlProdRequest.WriteStartElement("ProductionServerRequest");

            //Write ServerID Attribute to the ProductionRequest root Element
            xmlProdRequest.WriteAttributeString("ServerId", strServer + "_PS01");

            //Write ClientId Attribute to the ProductionRequest root Element
            xmlProdRequest.WriteAttributeString("ClientId", strClientID);

            //Write getparametersettings Element
            xmlProdRequest.WriteStartElement("ResetInputBins");

            //Write getparametersettings Element
            xmlProdRequest.WriteAttributeString("LoaderNumber", AutoLoader);

            //End getparametersettings element
            //xmlProdRequest.WriteEndElement()

            //End getparametersettings element
            xmlProdRequest.WriteEndElement();

            //end ProductionRequest Element
            xmlProdRequest.WriteEndElement();

            //End the document and close the writer
            xmlProdRequest.WriteEndDocument();
            xmlProdRequest.Close();

            //Output XML to string
            return(sbTest.ToString());
        }
예제 #3
0
 public void WriteDocumentType(string name, string varArg2, string varArg3 = null, string varArg4 = null)
 {
     if (varArg4 != null)
     {
         _writer.WriteDocType(name, varArg2, varArg3, varArg4);
     }
     else if (varArg3 != null)
     {
         _writer.WriteDocType(name, null, varArg2, varArg3);
     }
     else
     {
         _writer.WriteDocType(name, null, null, varArg2);
     }
 }
예제 #4
0
        /// <summary>
        /// Write out the header to the stream, if any exists
        /// </summary>
        /// <param name="xtw">XmlTextWriter to write to</param>
        /// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
        /// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
        private void WriteHeader(XmlTextWriter xtw, bool baddumpCol, bool nodumpCol)
        {
            xtw.WriteDocType("html", null, null, null);
            xtw.WriteStartElement("html");

            xtw.WriteStartElement("header");
            xtw.WriteElementString("title", "DAT Statistics Report");
            xtw.WriteElementString("style", @"
body {
    background-color: lightgray;
}
.dir {
    color: #0088FF;
}");
            xtw.WriteEndElement(); // header

            xtw.WriteStartElement("body");

            xtw.WriteElementString("h2", $"DAT Statistics Report ({DateTime.Now.ToShortDateString()})");

            xtw.WriteStartElement("table");
            xtw.WriteAttributeString("border", "1");
            xtw.WriteAttributeString("cellpadding", "5");
            xtw.WriteAttributeString("cellspacing", "0");
            xtw.Flush();

            // Now write the mid header for those who need it
            WriteMidHeader(xtw, baddumpCol, nodumpCol);
        }
예제 #5
0
        /// <summary>
        /// Get a string that contains a complete SVG document.  XML version, DOCTYPE etc are included.
        /// </summary>
        /// <returns></returns>
        /// <param name="compressAttributes">Should usually be set true.  Causes the XML output to be optimized so that
        /// long attributes like styles and transformations are represented with entities.</param>
        public string WriteSVGString(bool compressAttributes)
        {
            string s;
            string ents = "";

            XmlDocument doc = new XmlDocument();

            //write out our SVG tree to the new XmlDocument
            WriteXmlElements(doc, null);

            if (compressAttributes)
            {
                ents = SvgFactory.CompressXML(doc, doc.DocumentElement);
            }

            //This complicated business of writing to a memory stream and then reading back out to a string
            //is necessary in order to specify UTF8 -- for some reason the default is UTF16 (which makes most renderers
            //give up)

            MemoryStream  ms = new MemoryStream();
            XmlTextWriter wr = new XmlTextWriter(ms, new UTF8Encoding());

            wr.Formatting = Formatting.Indented;
            wr.WriteStartDocument(true);
            wr.WriteDocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", ents);
            doc.Save(wr);

            byte[] buf = ms.ToArray();
            s = Encoding.UTF8.GetString(buf, 0, buf.Length);

            wr.Close();

            return(s);
        }
예제 #6
0
        public void SaveXml(string filename)
        {
            const string lng = "eng";
            var          i   = 0;

            var writer = new XmlTextWriter(filename, Encoding.GetEncoding("ISO-8859-1"));

            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteDocType("Chapters", null, "matroskachapters.dtd", null);
            writer.WriteStartElement("Chapters");
            writer.WriteStartElement("EditionEntry");
            foreach (var c in _chapters)
            {
                i++;
                var istr = i.ToString("00");
                writer.WriteStartElement("ChapterAtom");
                writer.WriteStartElement("ChapterTimeStart");
                writer.WriteString(c.ToString());
                writer.WriteEndElement();
                writer.WriteStartElement("ChapterDisplay");
                writer.WriteStartElement("ChapterString");
                writer.WriteString("Chapter " + istr);
                writer.WriteEndElement();
                writer.WriteStartElement("ChapterLanguage");
                writer.WriteString(lng);
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }
예제 #7
0
    private void method_11()
    {
        int           num    = 15;
        MemoryStream  w      = new MemoryStream();
        XmlTextWriter writer = new XmlTextWriter(w, Encoding.UTF8);

        writer.WriteStartDocument();
        writer.WriteDocType(BookmarkStart.b("崴䌶吸场", 15), BookmarkStart.b("ᠴᠶᘸ氺฼簾湀求ńፆൈ歊ᕌݎՐṒᥔ睖桘畚汜灞习♢⭤", 15), BookmarkStart.b("崴䌶䴸䬺ܼှ湀㑂㉄う杈㱊繌慎㹐⅒㉔硖൘ग़牜❞ॠᝢࡤ୦塨婪䉬⭮╰㝲婴ྲྀᅸེၼ፾낀늂ꮄﶈ", 15), null);
        writer.WriteStartElement(BookmarkStart.b("崴䌶吸场", 15), BookmarkStart.b("崴䌶䴸䬺ܼှ湀㑂㉄う杈㱊繌慎㹐⅒㉔硖桘扚摜晞习᭢൤፦Ѩݪ", 15));
        writer.WriteStartElement(BookmarkStart.b("崴制堸强", 15));
        writer.WriteRaw(BookmarkStart.b("ऴ娶尸伺尼Ἶ⥀㝂ㅄ㝆摈⹊㱌㩎㡐╒桔畖ᩘ㑚㍜⭞Ѡൢᅤ䩦㵨ቪᵬ੮印卲ᙴᡶ᝸ེ᡼ᅾ뺂Ꞅ麗ﮊﺖ늜즠힢좤쮦芨펪사쎮誰鎲횴\udfb6\ud8b8즺캼\udabe\ub5c0ﻂ냄돆꿈ﳒ", 15));
        writer.WriteRaw(string.Format(BookmarkStart.b("ऴ䌶倸伺儼娾罀㡂畄㩆畈摊㥌♎═㽒ご楖", 15), BookmarkStart.b("愴砶稸", 15)));
        writer.WriteRaw(BookmarkStart.b("ऴ䐶䴸䈺儼娾慀㝂㱄㝆ⱈ癊潌㭎㑐⭒⅔硖㩘⡚⹜絞彠形䩤ᑦᵨቪŬ੮佰", 15));
        writer.WriteEndElement();
        writer.WriteStartElement(BookmarkStart.b("圴堶崸䈺", 15));
        writer.WriteRaw(BookmarkStart.b("ऴ䜶ᤸ堺儼帾㉀あ硄敆㵈≊㥌⍎㑐煒歔͖㡘㥚ㅜ㩞䅠ౢͤ䝦੨Ѫͬ᭮ᑰᵲŴѶ䕸呺ർ䅾", 15));
        if ((this.dictionary_1 != null) && (this.dictionary_1.Count > 0))
        {
            foreach (string str in this.dictionary_1.Keys)
            {
                string[] strArray = str.Split(new char[] { ';' });
                int.Parse(strArray[0]);
                writer.WriteStartElement(BookmarkStart.b("䔴", num));
                writer.WriteStartElement(BookmarkStart.b("吴", num));
                writer.WriteAttributeString(BookmarkStart.b("崴䔶尸崺", num), this.string_0 + BookmarkStart.b("ᘴ", num) + strArray[1]);
                writer.WriteValue(this.dictionary_1[str]);
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }
        writer.WriteEndElement();
        writer.WriteEndElement();
        writer.Flush();
        this.class771_0.method_14(BookmarkStart.b("䄴堶娸ᔺ唼䬾ⱀ⽂", num), w, true, FileAttributes.Archive);
    }
예제 #8
0
    private string InitialiseDoc(string filePath)
    {
        string files = filePath.Substring(0, filePath.LastIndexOf('/'));

        if (!Directory.Exists(files))
        {
            Directory.CreateDirectory(files);
        }

        doc = new XmlDocument();

        if (!File.Exists(filePath))
        {
            doc.Save(filePath);
            XmlTextWriter writer = new XmlTextWriter(filePath, null);
            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteDocType("Entries", null, null, DataStrings.doctype);
            writer.WriteStartElement("Entries");
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();
        }
        return(filePath);
    }
예제 #9
0
        private static void SaveAsXml(IEnumerable <Chapter> chapters, string path)
        {
            var writer = new XmlTextWriter(path, Encoding);

            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteDocType("Chapters", null, "matroskachapters.dtd", null);
            writer.WriteStartElement("Chapters");
            writer.WriteStartElement("EditionEntry");
            foreach (var chapter in chapters.Where(chapter => chapter.Keep))
            {
                writer.WriteStartElement("ChapterAtom");
                writer.WriteStartElement("ChapterTimeStart");
                writer.WriteString(chapter.StartTimeXmlFormat);                 // 00:00:00.000
                writer.WriteEndElement();
                writer.WriteStartElement("ChapterDisplay");
                writer.WriteStartElement("ChapterString");
                writer.WriteString(chapter.Title);                     // Chapter 1
                writer.WriteEndElement();
                if (HasLanguage(chapter))
                {
                    writer.WriteStartElement("ChapterLanguage");
                    writer.WriteString(chapter.Language.ISO_639_2);                     // eng
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }
예제 #10
0
    private void method_16()
    {
        int num = 3;

        if (this.method_0() != null)
        {
            MemoryStream  w      = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(w, Encoding.UTF8);
            writer.WriteStartDocument();
            writer.WriteDocType(BookmarkStart.b("䄨弪䀬䌮", num), BookmarkStart.b("ШЪȬ砮Ȱ瀲ᨴᠶ紸漺礼Ἶ᥀ୂᅄ੆Ո歊籌慎恐籒穔ቖ᝘", num), BookmarkStart.b("䄨弪夬弮ରᰲᨴ䀶丸䰺ጼ䠾牀浂⩄㕆⹈摊᥌ᵎ繐⭒㵔⍖㑘㝚汜湞习❢ㅤ⍦䙨፪լ᭮ᱰὲ䑴䙶坸ὺॼ᭾", num), null);
            writer.WriteStartElement(BookmarkStart.b("䄨弪䀬䌮", num), BookmarkStart.b("䄨弪夬弮ରᰲᨴ䀶丸䰺ጼ䠾牀浂⩄㕆⹈摊籌癎桐橒穔⽖ㅘ⽚ぜ㍞", num));
            writer.WriteStartElement(BookmarkStart.b("䄨个䰬䬮", num));
            writer.WriteRaw(BookmarkStart.b("ᔨ䘪䠬嬮倰ጲ崴䌶䴸䬺ြ娾぀㙂ⱄㅆ瑈楊์⁎㽐❒ご㥖ⵘ癚ड़♞ᅠ٢䝤䝦੨Ѫͬ᭮ᑰᵲŴ䩶學᩺ർཾﶈ뺐ﶔ뚜철쾢麤螦쪨쎪첬\uddae\uc2b0횲솴誶첸쾺\udbbc\u92be燎", num));
            writer.WriteRaw(string.Format(BookmarkStart.b("ᔨ弪䐬嬮崰嘲଴䰶स䘺ļှ㕀⩂ㅄ⭆ⱈ畊", num), BookmarkStart.b("樨䐪嬬䨮䌰", num)));
            writer.WriteRaw(BookmarkStart.b("ᔨ堪夬嘮崰嘲ᔴ䌶䀸䬺堼Ⱦ捀㝂⁄㽆㵈摊⹌㱎≐煒歔歖癘⡚⥜♞ൠ٢孤", num));
            writer.WriteEndElement();
            writer.WriteStartElement(BookmarkStart.b("䬨䐪䤬嘮", num));
            writer.WriteStartElement(BookmarkStart.b("夨", num));
            writer.WriteRaw(string.Concat(new object[] { BookmarkStart.b("ᔨ䈪䀬䠮ᄰ嬲倴帶常区䤼Ⱦ捀", num), this.method_0().Height * 1.33, BookmarkStart.b("ନପ娬䘮唰䜲崴ਸ਼ᬸ", num), this.method_0().Width * 1.33, BookmarkStart.b("ନପ帬崮到า᜴ᤶ᜸ᐺ琼刾⁀⑂⁄㑆晈⡊≌㥎㑐⅒答❖㝘㱚罜罞习嵢", num) }));
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Flush();
            this.class771_0.method_14(BookmarkStart.b("䨨䐪嬬䨮䌰ᴲ崴䌶吸场", num), w, true, FileAttributes.Archive);
        }
    }
예제 #11
0
        /// <summary>
        /// Export a MacGui style plist preset.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        public static void Export(string path, Preset preset)
        {
            EncodeTask    parsed    = QueryParserUtility.Parse(preset.Query);
            XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8)
            {
                Formatting = Formatting.Indented
            };

            // Header
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN",
                                   @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

            xmlWriter.WriteStartElement("plist");
            xmlWriter.WriteStartElement("array");

            // Add New Preset Here. Can write multiple presets here if required in future.
            WritePreset(xmlWriter, parsed, preset);

            // Footer
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndDocument();

            // Closeout
            xmlWriter.Close();
        }
예제 #12
0
        /// <summary>
        /// Save the current map to an XML-File
        /// </summary>
        /// <param name="fileName">The filename to be used (XML-extension automatically appended)</param>
        public void Save(string fileName)
        {
            fileName = fileName.ToLower().Trim();
            if (!fileName.EndsWith(".xml"))
            {
                fileName += ".xml";
            }
            XmlTextWriter writer = new XmlTextWriter(fileName, null);

            System.Diagnostics.Debug.WriteLine("Save to " + fileName);
            writer.WriteStartDocument();
            writer.WriteDocType("crawlMap", null, null, null);
            writer.WriteComment("Verbose Map file for Crawler Prototype");
            writer.WriteStartElement("map");
            writer.WriteAttributeString("width", _width.ToString());
            writer.WriteAttributeString("height", _height.ToString());
            if (_rows != null)
            {
                foreach (Row row in _rows)
                {
                    row.Save(writer);
                }
                ;
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }
예제 #13
0
        public void Serialize(NlmArticleModel model, Stream output)
        {
            var xmlSerializer = new XmlSerializer(typeof(NlmArticleModel));

            var headerStream = new MemoryStream();

            using (var writer = new XmlTextWriter(headerStream, Encoding.UTF8))
            {
                writer.WriteStartDocument(false);
                writer.WriteDocType("article", null, "journalpub-cals3.dtd", null);
                writer.Flush();

                headerStream.Seek(0, SeekOrigin.Begin);
                headerStream.CopyTo(output);
            }

            var settings = new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            };

            using (var writer = XmlWriter.Create(output, settings))
            {
                var namespaces = new XmlSerializerNamespaces();
                namespaces.Add("mml", "http://www.w3.org/1998/Math/MathML");
                namespaces.Add("xlink", "http://www.w3.org/1999/xlink");

                xmlSerializer.Serialize(writer, model, namespaces);
                writer.Flush();
            }
        }
예제 #14
0
        /// <summary>
        /// Export a MacGui style plist preset.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="build">
        /// The build.PictureModulusPictureModulus
        /// </param>
        public static void Export(string path, Preset preset, string build)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            EncodeTask parsed = new EncodeTask(preset.Task);

            using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8)
            {
                Formatting = Formatting.Indented
            })
            {
                // Header
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteDocType(
                    "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);

                xmlWriter.WriteStartElement("plist");
                xmlWriter.WriteStartElement("array");

                // Add New Preset Here. Can write multiple presets here if required in future.
                WritePreset(xmlWriter, parsed, preset, build);

                // Footer
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndDocument();

                // Closeout
                xmlWriter.Close();
            }
        }
예제 #15
0
        static void Main(string[] args)
        {
            string        document        = "newbooks.xml";
            XmlTextWriter myXmlTextWriter = null;
            XmlTextReader myXmlTextReader = null;

            myXmlTextWriter            = new XmlTextWriter(args[1], null);
            myXmlTextWriter.Formatting = Formatting.Indented;
            myXmlTextWriter.WriteStartDocument(false);
            myXmlTextWriter.WriteDocType("bookstore", null, "books.dtd", null);
            myXmlTextWriter.WriteComment("This file represents another fragment of a book store inventory database");
            myXmlTextWriter.WriteStartElement("bookstore");
            myXmlTextWriter.WriteStartElement("book", null);
            myXmlTextWriter.WriteAttributeString("genre", "autobiography");
            myXmlTextWriter.WriteAttributeString("publicationdate", "1979");
            myXmlTextWriter.WriteAttributeString("ISBN", "0-7356-0562-9");
            myXmlTextWriter.WriteElementString("title", null, "The Autobiography of Mark Twain");
            myXmlTextWriter.WriteStartElement("Author", null);
            myXmlTextWriter.WriteElementString("first-name", "Mark");
            myXmlTextWriter.WriteElementString("last-name", "Twain");
            myXmlTextWriter.WriteEndElement();
            myXmlTextWriter.WriteElementString("price", "7.99");
            myXmlTextWriter.WriteEndElement();
            myXmlTextWriter.WriteEndElement();

            //Write the XML to file and close the writer
            myXmlTextWriter.Flush();
            myXmlTextWriter.Close();
            if (myXmlTextWriter != null)
            {
                myXmlTextWriter.Close();
            }
        }
예제 #16
0
        /// <summary>Writes the begining data to the RSS file</summary>
        /// <remarks>This routine is called from the WriteChannel and WriteItem subs</remarks>
        /// <exception cref="NotSupportedException">RDF Site Summary (RSS) 1.0 is not currently supported.</exception>
        private void BeginDocument()
        {
            if (!wroteStartDocument)
            {
                if (rssVersion == RssVersion.Empty)
                {
                    rssVersion = RssVersion.RSS20;
                }
                writer.Formatting  = xmlFormat;
                writer.Indentation = xmlIndentation;
                writer.WriteStartDocument();

                //TODO: GJ: customise the style
                //writer.WriteProcessingInstruction("xml-stylesheet", @"type=""text/xml"" href=""/static/rss/rss.xsl""");
                //writer.WriteProcessingInstruction("xml-stylesheet", @"type=""text/css"" href=""/static/rss/rss.css""");


                if (rssVersion != RssVersion.RSS20)
                {
                    writer.WriteComment("Generated by RSS.NET: http://rss-net.sf.net");
                }

                //exc: The xml:space or xml:lang attribute value is invalid.
                switch (rssVersion)
                {
                case RssVersion.RSS090:
                    //<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/">
                    writer.WriteStartElement("RDF", "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                    break;

                case RssVersion.RSS091:
                    writer.WriteStartElement("rss");
                    writer.WriteDocType("rss", "-//Netscape Communications//DTD RSS 0.91//EN", "http://my.netscape.com/publish/formats/rss-0.91.dtd", null);
                    writer.WriteAttributeString("version", "0.91");
                    break;

                case RssVersion.RSS092:
                    writer.WriteStartElement("rss");
                    writer.WriteAttributeString("version", "0.92");
                    break;

                case RssVersion.RSS10:
                    throw new NotSupportedException("RDF Site Summary (RSS) 1.0 is not currently supported.");

                case RssVersion.RSS20:
                    writer.WriteStartElement("rss");
                    writer.WriteAttributeString("version", "2.0");
                    // RSS Modules
                    foreach (RssModule rssModule in this._rssModules)
                    {
                        WriteAttribute("xmlns:" + rssModule.NamespacePrefix, rssModule.NamespaceURL.ToString(), true);
                    }
                    break;
                }


                wroteStartDocument = true;
            }
        }
예제 #17
0
 protected GXLExport(XmlTextWriter writer)
 {
     xmlwriter             = writer;
     xmlwriter.Formatting  = Formatting.Indented;
     xmlwriter.Indentation = 1;
     xmlwriter.WriteStartDocument();
     xmlwriter.WriteDocType("gxl", null, "http://www.gupro.de/GXL/gxl-1.0.dtd", null);
 }
예제 #18
0
        public void WriteToXmlDoc()
        {
            XmlTextWriter textWriter = new XmlTextWriter("writeXml.xml", null);
            String        PI         = "type='text/xsl' href='book.xsl'";

            textWriter.WriteProcessingInstruction("xml-stylesheet", PI);
            textWriter.WriteDocType("book", Nothing, Nothing, "<!ENTITY h 'softcover'>");
        }
예제 #19
0
        private void btnValidate_Click(object sender, EventArgs e)
        {
            validationError = false;
            string xmlFilename = txbXmlFile.Text;

            if (xmlFilename.Length == 0 || !File.Exists(xmlFilename))
            {
                txbResults.AppendText("Invalid filename/path" + seperator);
                return;
            }

            // Check if it has DOCTYPE
            string data = File.ReadAllText(xmlFilename);

            if (data.IndexOf("<!DOCTYPE") != -1)
            {
                ValidateXmlFile(xmlFilename);
            }
            else if (txbExternalDtdFile.Text.Length > 0 &&
                     File.Exists(txbExternalDtdFile.Text))
            {
                // Can't do this directly unless i change the original xml file in some way
                // to include the DOCTYPE in it.
                // https://bytes.com/topic/net/answers/177215-xmlvalidatingreader-dtd-validation

                #region Code to create replica of xml file with DOCTYPE in it.
                XmlReader r = new XmlTextReader(xmlFilename);

                string newXmlFilename = xmlFilename.Substring(0, xmlFilename.Length - 4) + "2.xml";
                Debug.WriteLine(newXmlFilename);
                XmlWriter w = new XmlTextWriter(newXmlFilename, Encoding.UTF8);
                bool      hasDoctype = false, inProlog = true;
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.DocumentType)
                    {
                        hasDoctype = true;
                    }
                    else if (inProlog && !hasDoctype && r.NodeType ==
                             XmlNodeType.Element)
                    {
                        //First element is about to be written - insert Doctype here
                        w.WriteDocType(r.Name, null, txbExternalDtdFile.Text, null);
                        inProlog = false;
                    }
                    w.WriteNode(r, false);
                }
                r.Close();
                w.Close();
                #endregion

                ValidateXmlFile(newXmlFilename);
            }
            else
            {
                ShowResults("No DOCTYPE present in xml, choose an External dtd or include DOCTYPE in the xml");
            }
        }
예제 #20
0
        private void WriteNode(XmlTextWriter xtw, bool defattr)
        {
            int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;

            while (this.Read() && (d < this.Depth))
            {
                switch (this.NodeType)
                {
                case XmlNodeType.Element:
                    xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
                    xtw.QuoteChar = this.QuoteChar;
                    xtw.WriteAttributes(this, defattr);
                    if (this.IsEmptyElement)
                    {
                        xtw.WriteEndElement();
                    }
                    break;

                case XmlNodeType.Text:
                    xtw.WriteString(this.Value);
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    xtw.WriteWhitespace(this.Value);
                    break;

                case XmlNodeType.CDATA:
                    xtw.WriteCData(this.Value);
                    break;

                case XmlNodeType.EntityReference:
                    xtw.WriteEntityRef(this.Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    xtw.WriteProcessingInstruction(this.Name, this.Value);
                    break;

                case XmlNodeType.DocumentType:
                    xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                    break;

                case XmlNodeType.Comment:
                    xtw.WriteComment(this.Value);
                    break;

                case XmlNodeType.EndElement:
                    xtw.WriteFullEndElement();
                    break;
                }
            }
            if (d == this.Depth && this.NodeType == XmlNodeType.EndElement)
            {
                Read();
            }
        }
예제 #21
0
        // Writes the content (inner XML) of the current node into the provided XmlTextWriter.
        private async Task WriteNodeAsync(XmlTextWriter xtw, bool defattr)
        {
            int d = NodeType == XmlNodeType.None ? -1 : Depth;

            while (await ReadAsync().ConfigureAwait(false) && d < Depth)
            {
                switch (NodeType)
                {
                case XmlNodeType.Element:
                    xtw.WriteStartElement(Prefix, LocalName, NamespaceURI);
                    xtw.QuoteChar = QuoteChar;
                    xtw.WriteAttributes(this, defattr);
                    if (IsEmptyElement)
                    {
                        xtw.WriteEndElement();
                    }
                    break;

                case XmlNodeType.Text:
                    xtw.WriteString(await GetValueAsync().ConfigureAwait(false));
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    xtw.WriteWhitespace(await GetValueAsync().ConfigureAwait(false));
                    break;

                case XmlNodeType.CDATA:
                    xtw.WriteCData(Value);
                    break;

                case XmlNodeType.EntityReference:
                    xtw.WriteEntityRef(Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    xtw.WriteProcessingInstruction(Name, Value);
                    break;

                case XmlNodeType.DocumentType:
                    xtw.WriteDocType(Name, GetAttribute("PUBLIC"), GetAttribute("SYSTEM"), Value);
                    break;

                case XmlNodeType.Comment:
                    xtw.WriteComment(Value);
                    break;

                case XmlNodeType.EndElement:
                    xtw.WriteFullEndElement();
                    break;
                }
            }
            if (d == Depth && NodeType == XmlNodeType.EndElement)
            {
                await ReadAsync().ConfigureAwait(false);
            }
        }
예제 #22
0
파일: ReportToXml.cs 프로젝트: JabX/kinetix
        /// <summary>
        /// Ecrit la doctype dans le document généré.
        /// </summary>
        private void WriteDoctype()
        {
            if (string.IsNullOrEmpty(this._docType))
            {
                return;
            }

            _writer.WriteDocType(_rootElement, null, null, this._docType);
        }
예제 #23
0
        /// <summary>
        /// Writes the object referenced by CaptionsList to an XML file at the path given by Captionspath
        /// </summary>
        /// <param name="captionList">The List of Caption objects to write to a file.</param>
        /// <param name="captionsPath">The full path (file name and extension included) to write
        /// the CaptionList to.</param>
        public static void WriteCaptions(List <Caption> captionList, string captionsPath)
        {
            //NOTE: XmlTextWriter does not require curly braces between writeStartElement and
            //writeCloseElement. It is put there to easily see what belongs to what node.

            //Return if nothing to write
            if (captionList.Count == 0)
            {
                //TODO throw error?
                Console.WriteLine("Error: CaptionList is empty");
                return;
            }

            //dialogues.xml
            using (XmlTextWriter w = new XmlTextWriter(captionsPath, Encoding.UTF8))
            {
                //Set formatting so that the file will use newlines and 4-spaced indents
                w.Formatting  = Formatting.Indented;
                w.IndentChar  = '\t';
                w.Indentation = 1;

                w.WriteStartDocument();
                //XML header file
                w.WriteDocType("captions", null, "../captions.dtd", null);
                w.WriteStartElement("captions");
                {
                    foreach (Caption c in captionList)
                    {
                        w.WriteStartElement("caption");
                        {
                            w.WriteAttributeString("begin", c.Begin.AsString);
                            w.WriteAttributeString("end", c.End.AsString);
                            w.WriteAttributeString("speaker", c.Speaker.Name);
                            //Both location and alignment refer to hashcode
                            w.WriteAttributeString("location", Convert.ToString(c.Location.GetHashCode()));
                            w.WriteAttributeString("align", Convert.ToString(c.Alignment.GetHashCode()));

                            foreach (CaptionWord cw in c.Words)
                            {
                                w.WriteStartElement("emotion");
                                {
                                    w.WriteAttributeString("type", Convert.ToString(cw.Emotion.GetHashCode()));
                                    w.WriteAttributeString("intensity", Convert.ToString(cw.Intensity.GetHashCode()));
                                    w.WriteString(cw.Text);
                                }
                                w.WriteEndElement();
                            }
                        }
                        w.WriteEndElement();
                    }
                }
                w.WriteEndElement();

                w.WriteEndDocument();
            }
        }
예제 #24
0
 /// <summary>
 /// Serializes an object to a file.
 /// </summary>
 /// <param name="xmlFilePath">The file where the serialized object should go to.</param>
 /// <param name="entity">The object to be serialized.</param>
 /// <param name="docTypeName"></param>
 /// <param name="docTypePubId"></param>
 /// <param name="docTypeSysId"></param>
 /// <param name="docTypeSubSet"></param>
 ///<typeparam name="T">The object type to be serialized/deserialized.</typeparam>
 public static void ToXmlFile <T>(string xmlFilePath, T entity, Dictionary <string, string> namespaces, string docTypeName, string docTypePubId, string docTypeSysId, string docTypeSubSet)
 {
     using (var writer = new XmlTextWriter(xmlFilePath, Encoding.UTF8))
     {
         writer.WriteStartDocument();
         writer.WriteDocType(docTypeName, docTypePubId, docTypeSysId, docTypeSubSet);
         var serializer = new XmlSerializer(typeof(T));
         serializer.Serialize(writer, entity, namespaces != null ? GetNamespace(namespaces) : GetEmptyNamespace());
     }
 }
예제 #25
0
        /// <summary>
        /// Write out DAT header using the supplied StreamWriter
        /// </summary>
        /// <param name="xtw">XmlTextWriter to output to</param>
        private void WriteHeader(XmlTextWriter xtw)
        {
            xtw.WriteStartDocument();
            xtw.WriteDocType("softwarelist", null, "softwarelist.dtd", null);

            xtw.WriteStartElement("softwarelist");
            xtw.WriteRequiredAttributeString("name", Header.Name);
            xtw.WriteRequiredAttributeString("description", Header.Description);

            xtw.Flush();
        }
예제 #26
0
 void IEpgDataSink.Open()
 {
     _writer            = new XmlTextWriter(_xmltvTempFile, Encoding.UTF8);
     _writer.Formatting = Formatting.Indented;
     //Write the <xml version="1.0"> element
     _writer.WriteStartDocument();
     _writer.WriteDocType("tv", null, "xmltv.dtd", null);
     _writer.WriteStartElement("tv");
     _writer.WriteAttributeString("generator-info-name", "WebEPG");
     _currentChannelName = string.Empty;
 }
예제 #27
0
 private void WriteDocTypeOut(XmlTextReader inFile, XmlTextWriter xmlOutput)
 {
     if (currentRT.ClassName == "")              //There is no cuurrently instantiazed class
     {
         xmlOutput.WriteDocType(inFile.Name, null, null, null);
     }
     else
     {
         throw new Exception("DocType input isn't until after the root element");
     }
 }
예제 #28
0
        public void Write(Stream stream)
        {
            var xmlWriter = new XmlTextWriter(stream, Encoding.UTF8);

            xmlWriter.Formatting = Formatting.Indented;

            xmlWriter.WriteDocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null);

            this.WriteElement(xmlWriter);

            xmlWriter.Flush();
        }
예제 #29
0
        /// <summary>
        /// 保存NCX文件。
        /// </summary>
        private void SaveNCX()
        {
            //生成toc.ncx文件
            var ma = Manifest.FirstOrDefault(x => x.Href == "toc.ncx");

            if (ma == null)
            {
                Manifest.Add(new Manifest {
                    Href = "toc.ncx", Id = "ncx"
                });
            }
            var filePath = Path.Combine(_directoryName, "toc.ncx").DeleteFile();

            using (var writer = new XmlTextWriter(filePath, Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteDocType("ncx", "-//NISO//DTD ncx 2005-1//EN", "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd", null);
                writer.WriteStartElement("ncx", "http://www.daisy.org/z3986/2005/ncx/");
                writer.WriteAttributeString("version", "2005-1");
                //head
                //uid: 数字图书的惟一 ID。该元素应该和 OPF 文件中的 dc:identifier 对应。
                //depth:反映目录表中层次的深度。该例只有一层,因此是 1。
                //totalPageCount 和 maxPageNumber:仅用于纸质图书,保留 0 即可。
                writer.WriteStartElement("head");
                writer.WriteMetaElement("dtb:uid", BookId);
                writer.WriteMetaElement("dtb:depth", "2");
                writer.WriteMetaElement("dtb:totalPageCount", "0");
                writer.WriteMetaElement("dtb:maxPageNumber", "0");
                writer.WriteEndElement();
                //doc
                writer.WriteSubTextElement("docTitle", DC.Title);
                writer.WriteSubTextElement("docAuthor", DC.Creator);
                //navMap
                writer.WriteStartElement("navMap");
                var i         = 1;
                var manifests = Manifest.Where(x => x.IsSpine && !x.IsCover && !x.IsToc).OrderBy(x => x.Id).ToList();
                foreach (var manifest in manifests)
                {
                    writer.WriteStartElement("navPoint");
                    writer.WriteAttributeString("id", $"nav-{i}");
                    writer.WriteAttributeString("playOrder", i.ToString());
                    writer.WriteSubTextElement("navLabel", manifest.Title);
                    writer.WriteStartElement("content");
                    writer.WriteAttributeString("src", manifest.Href);
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    i++;
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
예제 #30
0
        // Constructor
        public Hxt(string filePath, Encoding encoding)
        {
            Disposed = false;
            writer   = new XmlTextWriter(filePath, encoding);

            // Write header
            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteDocType("HelpTOC", null, "MS-Help://Hx/Resources/HelpTOC.DTD", null);
            writer.WriteStartElement("HelpTOC");
            writer.WriteAttributeString("DTDVersion", "1.0");
            writer.Flush();
        }