示例#1
0
        protected override void RenderRaControl(HtmlBuilder builder)
        {
            using (Element el = builder.CreateElement("div"))
            {
                AddAttributes(el);
                CreateToolbar(builder);

                // Creating editor area...
                using (Element txt = builder.CreateElement("div"))
                {
                    txt.AddAttribute("id", ClientID + "_LBL");
                    txt.AddAttribute("class", "editorMain");
                    txt.Write(Text);
                }

                // Creating the invisible TextArea - which holds the data for posting back
                using (Element value = builder.CreateElement("textarea"))
                {
                    value.AddAttribute("id", ClientID + "__VALUE");
                    value.AddAttribute("name", ClientID + "__VALUE");
                    value.AddAttribute("class", "editorMain");
                    value.AddAttribute("style", "display:none;");
                    value.Write(Text);
                }

                using (Element value = builder.CreateElement("input"))
                {
                    value.AddAttribute("id", ClientID + "__SELTEXT");
                    value.AddAttribute("name", ClientID + "__SELTEXT");
                    value.AddAttribute("type", "hidden");
                }
            }
        }
示例#2
0
        private void EndParagraphInInsert()
        {
            Element paragraph = this._currentNode.Peek();
            Element pPr       = paragraph.GetChild("pPr", W_NAMESPACE);

            if (pPr == null)
            {
                pPr = new Element("w", "pPr", W_NAMESPACE);
                paragraph.AddChild(pPr);
            }
            Element rPr = pPr.GetChild("rPr", W_NAMESPACE);

            if (rPr == null)
            {
                rPr = new Element("w", "rPr", W_NAMESPACE);
                pPr.AddChild(rPr);
            }
            Element region = this._currentInsertionRegion.Peek();
            Element ins    = new Element("w", "ins", W_NAMESPACE);

            ins.AddAttribute(new Attribute("w", "id", "" + this._currentId++, W_NAMESPACE));
            ins.AddAttribute(new Attribute("w", "author", region.GetAttributeValue("creator", PCT_NAMESPACE), W_NAMESPACE));
            ins.AddAttribute(new Attribute("w", "date", region.GetAttributeValue("date", PCT_NAMESPACE), W_NAMESPACE));
            rPr.AddFirstChild(ins);
        }
示例#3
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("type", "hidden");
     el.AddAttribute("name", ClientID);
     el.AddAttribute("value", Value);
     base.AddAttributes(el);
 }
示例#4
0
        private void AddFooterToDocument(Element rootElement, Resource resource, long timeTaken)
        {
            Element body = rootElement.GetFirstChildElement("body");

            if (body != null)
            {
                Element footer = new Element("div");
                footer.AddStyleClass("footer");
                footer.AppendText("Results generated by ");

                Element link = new Element("a");
                link.AddAttribute("href", CONCORDION_WEBSITE_URL);
                footer.AppendChild(link);

                Element img = new Element("img");
                img.AddAttribute("src", resource.GetRelativePath(TARGET_LOGO_RESOURCE));
                img.AddAttribute("alt", "Concordion");
                img.AddAttribute("border", "0");
                link.AppendChild(img);

                Element dateDiv = new Element("div");
                dateDiv.AddStyleClass("testTime");
                dateDiv.AppendText("in " + (timeTaken + 1) + " ms ");
                dateDiv.AppendText(DateTime.Now.ToString());
                footer.AppendChild(dateDiv);

                body.AppendChild(footer);
            }
        }
示例#5
0
        protected override void AddAttributes(Element el)
        {
            if (!string.IsNullOrEmpty(Title))
            {
                el.AddAttribute("title", Title);
            }
            if (!string.IsNullOrEmpty(Class))
            {
                el.AddAttribute("class", Class);
            }
            if (!string.IsNullOrEmpty(Dir))
            {
                el.AddAttribute("dir", Dir);
            }
            string style = Style.GetStylesForResponse();

            if (!string.IsNullOrEmpty(style))
            {
                el.AddAttribute("style", style);
            }
            if (!string.IsNullOrEmpty(TabIndex))
            {
                el.AddAttribute("tabindex", TabIndex);
            }
            base.AddAttributes(el);
        }
示例#6
0
 private Element ReplaceElementWithDel(Element element, Element deletion)
 {
     if (W_NAMESPACE.Equals(element.Ns) && Contains(DEL_CHILDREN, element.Name))
     {
         // insert w:del element
         Element del = new Element("w", "del", W_NAMESPACE);
         del.AddAttribute(new Attribute("w", "id", "" + this._currentId++, W_NAMESPACE));
         del.AddAttribute(new Attribute("w", "author", deletion.GetAttributeValue("creator", PCT_NAMESPACE), W_NAMESPACE));
         del.AddAttribute(new Attribute("w", "date", deletion.GetAttributeValue("date", PCT_NAMESPACE), W_NAMESPACE));
         del.AddChild(element);
         return(del);
     }
     else
     {
         // recursive call on all children
         ArrayList newChildren = new ArrayList();
         foreach (object child in element.Children)
         {
             if (child is Element)
             {
                 Element replaced = ReplaceElementWithDel((Element)child, deletion);
                 newChildren.Add(replaced);
             }
             else
             {
                 newChildren.Add(child);
             }
         }
         element.Children = newChildren;
         return(element);
     }
 }
        private static Element ToXML(EntityMention entity, string curNS)
        {
            Element top = new Element("entity", curNS);

            top.AddAttribute(new Attribute("id", entity.GetObjectId()));
            Element type = new Element("type", curNS);

            type.AppendChild(entity.GetType());
            top.AppendChild(entity.GetType());
            if (entity.GetNormalizedName() != null)
            {
                Element nm = new Element("normalized", curNS);
                nm.AppendChild(entity.GetNormalizedName());
                top.AppendChild(nm);
            }
            if (entity.GetSubType() != null)
            {
                Element subtype = new Element("subtype", curNS);
                subtype.AppendChild(entity.GetSubType());
                top.AppendChild(subtype);
            }
            Element span = new Element("span", curNS);

            span.AddAttribute(new Attribute("start", int.ToString(entity.GetHeadTokenStart())));
            span.AddAttribute(new Attribute("end", int.ToString(entity.GetHeadTokenEnd())));
            top.AppendChild(span);
            top.AppendChild(MakeProbabilitiesElement(entity, curNS));
            return(top);
        }
示例#8
0
        private void EndTableRow()
        {
            Element tr = this._currentNode.Peek();

            if (IsTableRowInsert())     // only on insertion
            {
                Element trPr   = tr.GetChild("trPr", W_NAMESPACE);
                Element region = this._currentInsertionRegion.Peek();
                Element ins    = new Element("w", "ins", W_NAMESPACE);
                ins.AddAttribute(new Attribute("w", "id", "" + this._currentId++, W_NAMESPACE));
                ins.AddAttribute(new Attribute("w", "author", region.GetAttributeValue("creator", PCT_NAMESPACE), W_NAMESPACE));
                ins.AddAttribute(new Attribute("w", "date", region.GetAttributeValue("date", PCT_NAMESPACE), W_NAMESPACE));
                if (trPr == null)
                {
                    trPr = new Element("w", "trPr", W_NAMESPACE);
                    tr.AddChild(trPr);
                    tr.Children = GetOrderedChildren(tr, TR_CHILDREN);
                }
                trPr.AddChild(ins);
                trPr.Children = GetOrderedChildren(trPr, TRPR_CHILDREN);
                this._context.Pop();
            }
            this._dontWrites.Pop();
            if (DontWrite())
            {
                AddChildToElement();
            }
            else
            {
                tr.Write(nextWriter);
            }
        }
示例#9
0
 protected override void RenderRaControl(HtmlBuilder builder)
 {
     using (Element span = builder.CreateElement("span"))
     {
         AddAttributes(span);
         using (Element el = builder.CreateElement("input"))
         {
             el.AddAttribute("id", ClientID + "_CTRL");
             el.AddAttribute("type", "checkbox");
             el.AddAttribute("name", ClientID);
             if (!string.IsNullOrEmpty(AccessKey))
             {
                 el.AddAttribute("accesskey", AccessKey);
             }
             if (!Enabled)
             {
                 el.AddAttribute("disabled", "disabled");
             }
             if (Checked)
             {
                 el.AddAttribute("checked", "checked");
             }
         }
         using (Element label = builder.CreateElement("label"))
         {
             label.AddAttribute("id", ClientID + "_LBL");
             label.AddAttribute("for", ClientID + "_CTRL");
             label.Write(Text);
         }
     }
 }
        private static void AddDependencyInfo(Element depInfo, string rel, bool isExtra, int source, string sourceWord, int sourceCopy, int target, string targetWord, int targetCopy, string curNS)
        {
            Element depElem = new Element("dep", curNS);

            depElem.AddAttribute(new Attribute("type", rel));
            if (isExtra)
            {
                depElem.AddAttribute(new Attribute("extra", "true"));
            }
            Element govElem = new Element("governor", curNS);

            govElem.AddAttribute(new Attribute("idx", int.ToString(source)));
            govElem.AppendChild(sourceWord);
            if (sourceCopy != null && sourceCopy > 0)
            {
                govElem.AddAttribute(new Attribute("copy", int.ToString(sourceCopy)));
            }
            depElem.AppendChild(govElem);
            Element dependElem = new Element("dependent", curNS);

            dependElem.AddAttribute(new Attribute("idx", int.ToString(target)));
            dependElem.AppendChild(targetWord);
            if (targetCopy != null && targetCopy > 0)
            {
                dependElem.AddAttribute(new Attribute("copy", int.ToString(targetCopy)));
            }
            depElem.AppendChild(dependElem);
            depInfo.AppendChild(depElem);
        }
示例#11
0
 protected override void RenderRaControl(HtmlBuilder builder)
 {
     using (Element el = builder.CreateElement("button"))
     {
         AddAttributes(el);
         using (Element bRight = builder.CreateElement("span"))
         {
             bRight.AddAttribute("class", "ra-button-right");
             using (Element bLeft = builder.CreateElement("span"))
             {
                 bLeft.AddAttribute("class", "ra-button-left");
                 using (Element bCenter = builder.CreateElement("span"))
                 {
                     bCenter.AddAttribute("class", "ra-button-center");
                     using (Element content = builder.CreateElement("span"))
                     {
                         content.AddAttribute("class", "ra-button-content");
                         content.AddAttribute("id", ClientID + "_LBL");
                         content.Write(Text);
                     }
                 }
             }
         }
     }
 }
示例#12
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("onclick", "return false;");
     el.AddAttribute("type", "image");
     el.AddAttribute("src", ImageUrl);
     el.AddAttribute("alt", AlternateText);
     base.AddAttributes(el);
 }
示例#13
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("href", "javascript:Ra.emptyFunction();");
     if (!string.IsNullOrEmpty(AccessKey))
     {
         el.AddAttribute("accesskey", AccessKey);
     }
     base.AddAttributes(el);
 }
示例#14
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("href", Href);
     if (!string.IsNullOrEmpty(Target))
     {
         el.AddAttribute("target", Target);
     }
     base.AddAttributes(el);
 }
示例#15
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("name", ClientID);
     if (Size != -1 && Size != 1)
     {
         el.AddAttribute("size", Size.ToString());
     }
     base.AddAttributes(el);
 }
示例#16
0
 private void CreateButton(HtmlBuilder builder, string className)
 {
     using (Element bold = builder.CreateElement("button"))
     {
         bold.AddAttribute("class", "editorBtn " + className);
         bold.AddAttribute("id", ClientID + className);
         bold.AddAttribute("onclick", "return false;");
     }
 }
示例#17
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("type", "checkbox");
     el.AddAttribute("name", ClientID);
     if (Checked)
     {
         el.AddAttribute("checked", "checked");
     }
     base.AddAttributes(el);
 }
示例#18
0
 protected override void AddAttributes(Element el)
 {
     if (string.IsNullOrEmpty(ImageUrl) || string.IsNullOrEmpty(AlternateText))
     {
         throw new ApplicationException("Cannot have empty ImageUrl or AlternateText of Image");
     }
     el.AddAttribute("src", ImageUrl);
     el.AddAttribute("alt", AlternateText);
     base.AddAttributes(el);
 }
示例#19
0
 public void ElementWithMultipleAttributes()
 {
     using (HtmlBuilder builder = new HtmlBuilder())
     {
         using (Element el = builder.CreateElement("div"))
         {
             el.AddAttribute("attribute", "value");
             el.AddAttribute("howdy", "yahoo");
         }
         Assert.AreEqual("<div attribute=\"value\" howdy=\"yahoo\"></div>", builder.ToString());
     }
 }
 protected override void AddAttributes(Element el)
 {
     if (!string.IsNullOrEmpty(AccessKey))
     {
         el.AddAttribute("accesskey", AccessKey);
     }
     if (Disabled)
     {
         el.AddAttribute("disabled", "disabled");
     }
     base.AddAttributes(el);
 }
示例#21
0
 protected override void AddAttributes(Element el)
 {
     if (ShouldAddValue)
     {
         el.AddAttribute("value", Value);
     }
     if (!string.IsNullOrEmpty(PlaceHolder))
     {
         el.AddAttribute("placeholder", PlaceHolder);
     }
     el.AddAttribute("name", ClientID);
     base.AddAttributes(el);
 }
示例#22
0
        //Split the paragraph in two paragraphs (triggered by an element in the PCUT_NAMESPACE)
        private void CutParagraph(Element element, bool bCutOneTime)
        {
            Element textParagraphElement = element.GetChild("paragraph", element.Ns);
            Element nextElement          = new Element(element.Prefix, element.Name, element.Ns);

            ArrayList childrenFirstPart  = new ArrayList();
            ArrayList childrenSecondPart = new ArrayList();

            ArrayList children = childrenFirstPart;

            foreach (Object child in element.Children)
            {
                Element childElement = child as Element;
                if (childElement != null && childElement.Ns == PCUT_NAMESPACE)
                {
                    children = childrenSecondPart;
                }
                else
                {
                    children.Add(child);
                }
            }
            element.Children     = childrenFirstPart;
            nextElement.Children = childrenSecondPart;

            foreach (Attribute attribute in element.Attributes)
            {
                if (attribute.Ns == TEXT_NAMESPACE && attribute.Name == "style-name")
                {
                    Attribute newAttribute = new Attribute(attribute.Prefix, attribute.Name, attribute.Ns);
                    if (!bCutOneTime)
                    {
                        newAttribute.Value = attribute.Value + EXTENSION_STYLE;
                    }
                    else
                    {
                        newAttribute.Value = attribute.Value;
                    }
                    nextElement.AddAttribute(newAttribute);
                }
                else
                {
                    nextElement.AddAttribute(attribute);
                }
            }
            element.RemoveChild(textParagraphElement);
            RemoveAllTextParagraphChildren(element);
            element.Write(this.nextWriter);
            nextElement.AddChild(textParagraphElement);
            WriteParagraph(nextElement, true);
        }
示例#23
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("type", "button");
     el.AddAttribute("value", Text);
     if (!string.IsNullOrEmpty(AccessKey))
     {
         el.AddAttribute("accesskey", AccessKey);
     }
     if (!Enabled)
     {
         el.AddAttribute("disabled", "disabled");
     }
     base.AddAttributes(el);
 }
示例#24
0
 protected override void AddAttributes(Element el)
 {
     el.AddAttribute("name", ClientID);
     el.AddAttribute("rows", Rows.ToString());
     el.AddAttribute("cols", Columns.ToString());
     if (!string.IsNullOrEmpty(AccessKey))
     {
         el.AddAttribute("accesskey", AccessKey);
     }
     if (!Enabled)
     {
         el.AddAttribute("disabled", "disabled");
     }
     base.AddAttributes(el);
 }
示例#25
0
        private void ProcessAttributes(Element element)
        {
            var browser = TypeBrowser.Create(element.GetType());

            while (this.reader.MoveToNextAttribute())
            {
                // Check for namespaces first
                if (string.Equals("xmlns", this.reader.Name, StringComparison.Ordinal))
                {
                    // Set default namespace only on unknown elements
                    if (element is UnknownElement)
                    {
                        element.AddNamespace(string.Empty, this.reader.Value);
                    }
                }
                else if (string.Equals("xmlns", this.reader.Prefix, StringComparison.Ordinal))
                {
                    element.AddNamespace(this.reader.LocalName, this.reader.Value);
                }
                else
                {
                    // just a normal attribute
                    PropertyInfo property = browser.FindAttribute(new XmlComponent(null, this.reader.LocalName, null)); // Attributes never have namespace info.
                    if (property != null)
                    {
                        AssignValue(element, property, this.reader.Value);
                    }
                    else
                    {
                        // Unknown, save for later serialization
                        element.AddAttribute(new XmlComponent(this.reader));
                    }
                }
            }
        }
        private static Element ToXML(RelationMention relation, string curNS)
        {
            Element top = new Element("relation", curNS);

            top.AddAttribute(new Attribute("id", relation.GetObjectId()));
            Element type = new Element("type", curNS);

            type.AppendChild(relation.GetType());
            top.AppendChild(relation.GetType());
            if (relation.GetSubType() != null)
            {
                Element subtype = new Element("subtype", curNS);
                subtype.AppendChild(relation.GetSubType());
                top.AppendChild(relation.GetSubType());
            }
            IList <EntityMention> mentions = relation.GetEntityMentionArgs();
            Element args = new Element("arguments", curNS);

            foreach (EntityMention e in mentions)
            {
                args.AppendChild(ToXML(e, curNS));
            }
            top.AppendChild(args);
            top.AppendChild(MakeProbabilitiesElement(relation, curNS));
            return(top);
        }
示例#27
0
            public Element Clone()
            {
                Element result = new Element(this);

                // copy attributes
                foreach (Attribute attr in this.attributes)
                {
                    Attribute attr2 = new Attribute(attr);
                    attr2.Value = attr.Value;
                    result.AddAttribute(attr2);
                }
                // copy children
                foreach (Object obj in this.children)
                {
                    if (obj is Element)
                    {
                        Element child = (Element)obj;
                        result.AddChild(child.Clone());
                    }
                    else if (obj is string)
                    {
                        string child = (string)obj;
                        result.AddChild(child.Clone());
                    }
                }
                return(result);
            }
        private static void AddCorefMention(AnnotationOutputter.Options options, Element chainElem, string curNS, IList <ICoreMap> sentences, CorefChain.CorefMention mention, bool representative)
        {
            Element mentionElem = new Element("mention", curNS);

            if (representative)
            {
                mentionElem.AddAttribute(new Attribute("representative", "true"));
            }
            SetSingleElement(mentionElem, "sentence", curNS, int.ToString(mention.sentNum));
            SetSingleElement(mentionElem, "start", curNS, int.ToString(mention.startIndex));
            SetSingleElement(mentionElem, "end", curNS, int.ToString(mention.endIndex));
            SetSingleElement(mentionElem, "head", curNS, int.ToString(mention.headIndex));
            string text = mention.mentionSpan;

            SetSingleElement(mentionElem, "text", curNS, text);
            // Do you want context with your coreference?
            if (sentences != null && options.coreferenceContextSize > 0)
            {
                // If so use sentences to get so context from sentences
                IList <CoreLabel> tokens = sentences[mention.sentNum - 1].Get(typeof(CoreAnnotations.TokensAnnotation));
                int    contextStart      = Math.Max(mention.startIndex - 1 - 5, 0);
                int    contextEnd        = Math.Min(mention.endIndex - 1 + 5, tokens.Count);
                string leftContext       = StringUtils.JoinWords(tokens, " ", contextStart, mention.startIndex - 1);
                string rightContext      = StringUtils.JoinWords(tokens, " ", mention.endIndex - 1, contextEnd);
                SetSingleElement(mentionElem, "leftContext", curNS, leftContext);
                SetSingleElement(mentionElem, "rightContext", curNS, rightContext);
            }
            chainElem.AppendChild(mentionElem);
        }
示例#29
0
文件: Label.cs 项目: stjordanis/magix
 protected override void AddAttributes(Element el)
 {
     if (!string.IsNullOrEmpty(For))
     {
         el.AddAttribute("for", For);
     }
     base.AddAttributes(el);
 }
示例#30
0
 /// <summary>
 /// Checks for each attribute on the token if the attribute is already present on the node.
 /// If it is not, the attribute and its corresponding value is added to the node.
 /// </summary>
 /// <param name="element">The node with the target attributes.</param>
 /// <param name="attributes">The attributes to set.</param>
 public static void SetAttributes(this Element element, List <KeyValuePair <String, String> > attributes)
 {
     for (var i = 0; i < attributes.Count; i++)
     {
         var attribute = attributes[i];
         element.AddAttribute(attribute.Key, attribute.Value);
     }
 }
示例#31
0
 protected void AddAttributes(Element el)
 {
     el.AddAttribute("type", "submit");
     if (!string.IsNullOrEmpty(AccessKey))
         el.AddAttribute("accesskey", AccessKey);
     if (!Enabled)
         el.AddAttribute("disabled", "disabled");
     if (!string.IsNullOrEmpty(ToolTip))
         el.AddAttribute("title", ToolTip);
     if (!string.IsNullOrEmpty(CssClass))
         el.AddAttribute("class", CssClass);
     string style = Style.Value;
     if (!string.IsNullOrEmpty(style))
         el.AddAttribute("style", style);
 }
示例#32
0
 private void ProcessAttributes(Element element)
 {
     TypeBrowser browser = TypeBrowser.Create(element.GetType());
     while (_reader.MoveToNextAttribute())
     {
         // Check for namespaces first
         if (string.Equals("xmlns", _reader.Name, StringComparison.Ordinal))
         {
             // Set default namespace only on unknown elements
             if (element is UnknownElement)
             {
                 element.Namespaces.AddNamespace(string.Empty, _reader.Value);
             }
         }
         else if (string.Equals("xmlns", _reader.Prefix, StringComparison.Ordinal))
         {
             element.Namespaces.AddNamespace(_reader.LocalName, _reader.Value);
         }
         else // just a normal attribute
         {
             PropertyInfo property = browser.FindAttribute(new XmlComponent(null, _reader.LocalName, null)); // Attributes never have namespace info.
             if (property != null)
             {
                 AssignValue(element, property, _reader.Value);
             }
             else
             {
                 // Unknown, save for later serialization
                 element.AddAttribute(new XmlComponent(_reader));
             }
         }
     }
 }
        public static IElement ToElement(this HtmlNode self, INode parent)
        {
            if (self == null)
                throw new ArgumentNullException("self");
            if (parent == null)
                throw new ArgumentNullException("parent");

            var name = self.ToQualifiedName();
            var element = new Element(parent, name);

            foreach (var attribute in self.ToAttributes(element))
                element.AddAttribute(attribute);

            foreach (var child in self.ToChildren(element))
                element.AddChild(child);

            var customElement = GetCustomElement(element, parent, name);
            if (customElement != null)
            {
                foreach (var attribute in self.ToAttributes(customElement))
                    customElement.AddAttribute(attribute);

                foreach (var child in self.ToChildren(customElement))
                    customElement.AddChild(child);

                return customElement;
            }

            return element;
        }