Ejemplo n.º 1
0
        /// <summary>
        /// Writes the answer collection as a HotDocs XML answer file to the TextWriter.
        /// </summary>
        /// <param name="output">The TextWriter to which to write the XML answer file.</param>
        /// <param name="writeDontSave">Indicates whether or not answers that are marked as "do not save" should be written to the answer file.</param>
        public void WriteXml(System.IO.TextWriter output, bool writeDontSave)
        {
            output.Write("<?xml version=\"1.0\" encoding=\"");
            output.Write(output.Encoding.WebName);            //Write out the IANA-registered name of the encoding.
            output.WriteLine("\" standalone=\"yes\"?>");
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent             = true;
            settings.IndentChars        = "\t";
            settings.OmitXmlDeclaration = true;   // because we emitted it manually above
            bool forInterview = true;             // ensures the userModifiable and userExtendible attributes are output

            using (XmlWriter writer = new AnswerXmlWriter(output, settings, forInterview))
            {
                writer.WriteStartDocument(true);
                if (!String.IsNullOrEmpty(_dtd))
                {
                    writer.WriteRaw(_dtd);
                }
                writer.WriteStartElement("AnswerSet");
                writer.WriteAttributeString("title", _title);
                writer.WriteAttributeString("version", XmlConvert.ToString(_version));
                //writer.WriteAttributeString("useMangledNames", XmlConvert.ToString(false));
                IEnumerator <Answer> answerEnumerator = GetEnumerator();
                while (answerEnumerator.MoveNext())
                {
                    answerEnumerator.Current.WriteXml(writer, writeDontSave);
                }
                writer.WriteEndElement();
            }
        }
        /// <summary>
        /// Writes the answer collection as a HotDocs XML answer file to the TextWriter.
        /// </summary>
        /// <param name="output">The TextWriter to which to write the XML answer file.</param>
        /// <param name="writeDontSave">Indicates whether or not answers that are marked as "do not save" should be written to the answer file.</param>
        public void WriteXml(System.IO.TextWriter output, bool writeDontSave)
        {
            output.Write("<?xml version=\"1.0\" encoding=\"");
            output.Write(output.Encoding.WebName);            //Write out the IANA-registered name of the encoding.
            output.WriteLine("\" standalone=\"yes\"?>");
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent             = true;
            settings.IndentChars        = "\t";
            settings.OmitXmlDeclaration = true;             // because we emitted it manually above
            bool forInterview = true;

            using (XmlWriter writer = new AnswerXmlWriter(output, settings, forInterview))
            {
                writer.WriteStartDocument(true);
                writer.WriteStartElement("AnswerSet");
                writer.WriteAttributeString("title", _title);
                writer.WriteAttributeString("version", XmlConvert.ToString(_version));
                //writer.WriteAttributeString("useMangledNames", XmlConvert.ToString(false));
                foreach (Answer ans in _answers.Values)
                {
                    ans.WriteXml(writer, writeDontSave);
                }
                writer.WriteEndElement();
            }
        }