private void OutputTextAndTag(string qName, IAttributes attributes, bool close)
 {
     // If we're not already in an element to be transformed, first
     // echo the previous text...
     outWriter.Print(XMLUtils.EscapeXML(textToBeTransformed.ToString()));
     textToBeTransformed = new StringBuilder();
     // ... then echo the new tag to outStream
     outWriter.Print('<');
     if (close)
     {
         outWriter.Print('/');
     }
     outWriter.Print(qName);
     if (attributes != null)
     {
         for (int i = 0; i < attributes.GetLength(); i++)
         {
             outWriter.Print(' ');
             outWriter.Print(attributes.GetQName(i));
             outWriter.Print("=\"");
             outWriter.Print(XMLUtils.EscapeXML(attributes.GetValue(i)));
             outWriter.Print('"');
         }
     }
     outWriter.Print(">\n");
 }
 // when we're inside a block to be transformed, we ignore
 // elements that don't end the block.
 public virtual void ProcessText(string text)
 {
     if (text.Length > 0)
     {
         text = function.Apply(text).ToString();
         outWriter.Print(XMLUtils.EscapeXML(text));
         outWriter.Print('\n');
     }
 }
 public override void EndDocument()
 {
     // Theoretically, there shouldn't be anything in the buffer after
     // the last closing tag, but if there is, it's probably better to
     // echo it than ignore it
     outWriter.Print(XMLUtils.EscapeXML(textToBeTransformed.ToString()));
     // we need to flush because there are no other ways we
     // explicitely flush
     outWriter.Flush();
 }
        private static void PrintAnswersTokenizedXML <In>(IList <In> doc, PrintWriter @out)
            where In : ICoreMap
        {
            int num = 0;

            foreach (IN wi in doc)
            {
                @out.Print("<wi num=\"");
                // tag.append(wi.get("position"));
                @out.Print(num++);
                @out.Print("\" entity=\"");
                @out.Print(StringUtils.GetNotNullString(wi.Get(typeof(CoreAnnotations.AnswerAnnotation))));
                @out.Print("\">");
                @out.Print(XMLUtils.EscapeXML(StringUtils.GetNotNullString(wi.Get(typeof(CoreAnnotations.TextAnnotation)))));
                @out.Println("</wi>");
            }
        }
        /// <summary>Provide different printing options via a String keyword.</summary>
        /// <remarks>
        /// Provide different printing options via a String keyword.
        /// The recognized options are currently "xml", and "predicate".
        /// Otherwise the default toString() is used.
        /// </remarks>
        public override string ToString(string format)
        {
            switch (format)
            {
            case "xml":
            {
                return("  <dep>\n    <governor>" + XMLUtils.EscapeXML(Governor().Value()) + "</governor>\n    <dependent>" + XMLUtils.EscapeXML(Dependent().Value()) + "</dependent>\n  </dep>");
            }

            case "predicate":
            {
                return("dep(" + Governor() + "," + Dependent() + "," + Name() + ")");
            }

            default:
            {
                return(ToString());
            }
            }
        }
        /// <summary>Provide different printing options via a String keyword.</summary>
        /// <remarks>
        /// Provide different printing options via a String keyword.
        /// The recognized options are currently "xml", and "predicate".
        /// Otherwise the default toString() is used.
        /// </remarks>
        public override string ToString(string format)
        {
            switch (format)
            {
            case "xml":
            {
                string govIdxStr = " idx=\"" + headIndex + "\"";
                string depIdxStr = " idx=\"" + depIndex + "\"";
                return("  <dep>\n    <governor" + govIdxStr + ">" + XMLUtils.EscapeXML(Governor().Value()) + "</governor>\n    <dependent" + depIdxStr + ">" + XMLUtils.EscapeXML(Dependent().Value()) + "</dependent>\n  </dep>");
            }

            case "predicate":
            {
                return("dep(" + Governor() + "," + Dependent() + ")");
            }

            default:
            {
                return(ToString());
            }
            }
        }