Example #1
0
 public override bool Add(VariableBindings result)
 {
     output.WriteLine("<tr>");
     foreach (Variable var in result.Variables)
     {
         if (var.LocalName == null)
         {
             continue;
         }
         Resource varTarget = result[var];
         string   t         = "";
         if (varTarget != null)
         {
             t = varTarget.ToString();
             if (varTarget is Literal)
             {
                 t = ((Literal)varTarget).Value;
             }
         }
         t = t.Replace("&", "&amp;");
         t = t.Replace("<", "&lt;");
         output.WriteLine("<td>" + t + "</td>");
     }
     output.WriteLine("</tr>");
     return(true);
 }
Example #2
0
        public override bool Add(VariableBindings result)
        {
            bool first = true;

            foreach (Variable var in result.Variables)
            {
                if (var.LocalName == null)
                {
                    continue;
                }
                Resource varTarget = result[var];
                string   t         = "";
                if (varTarget != null)
                {
                    t = varTarget.ToString();
                    if (varTarget is Literal)
                    {
                        t = ((Literal)varTarget).Value;
                    }
                    if (varTarget.Uri != null)
                    {
                        t = varTarget.Uri;
                    }
                }
                if (t.IndexOfAny(reservedChars) >= 0 || t != t.Trim())
                {
                    t = "\"" + t.Replace("\"", "\"\"") + "\"";
                }
                if (!first)
                {
                    output.Write(",");
                }
                first = false;
                output.Write(t);
            }
            output.WriteLine();
            return(true);
        }
Example #3
0
 public abstract bool Add(VariableBindings result);
Example #4
0
        public override bool Add(VariableBindings result)
        {
            output.WriteStartElement("result");
            for (int i = 0; i < result.Count; i++)
            {
                Variable var = result.Variables[i];
                Resource val = result.Values[i];

                if (var.LocalName == null)
                {
                    continue;
                }
                if (val == null)
                {
                    continue;
                }

                output.WriteStartElement("binding");
                output.WriteAttributeString("name", var.LocalName);

                if (val.Uri != null)
                {
                    output.WriteElementString("uri", val.Uri);
                }
                else if (val is Literal)
                {
                    output.WriteStartElement("literal");
                    Literal literal = (Literal)val;
                    if (literal.DataType != null)
                    {
                        output.WriteAttributeString("datatype", literal.DataType);
                    }
                    if (literal.Language != null)
                    {
                        output.WriteAttributeString("xml", "lang", null, literal.Language);
                    }
                    output.WriteString(literal.Value);
                    output.WriteEndElement();
                }
                else
                {
                    string id;
                    if (blankNodes.ContainsKey(val))
                    {
                        id = (string)blankNodes[val];
                    }
                    else
                    {
                        id = "r" + (++blankNodeCounter);
                        blankNodes[val] = id;
                    }
                    output.WriteStartElement("bnode");
                    output.WriteString(id);
                    output.WriteEndElement();
                }

                output.WriteEndElement();
            }
            output.WriteEndElement();

            return(true);
        }