示例#1
0
        public override IList <IHtmlValidationError> ValidateElement(ElementNode element)
        {
            var results = new ValidationErrorCollection();

            if (element.IsDocType())
            {
                return(results);
            }

            for (int i = 0; i < element.Attributes.Count; i++)
            {
                AttributeNode attr = element.Attributes[i];

                if (attr.Name == "itemtype" && attr.HasValue() && !attr.Value.Contains("@"))
                {
                    if (!Uri.IsWellFormedUriString(attr.Value, UriKind.Absolute))
                    {
                        results.AddAttributeError(element, string.Format(CultureInfo.CurrentCulture, "The value of {0} must be an absolute URI", attr.Name), HtmlValidationErrorLocation.AttributeValue, i);
                        break;
                    }
                }
            }

            return(results);
        }
示例#2
0
        private void WriteAttribute(AttributeNode at)
        {
            _sb.Append(' ');

            string prefix = _tree.Text.GetText(at.PrefixRange);
            string colon  = (at.NameToken != null && at.NameToken.HasColon) ? _tree.Text.GetText(at.NameToken.ColonRange) : String.Empty;
            string name   = _tree.Text.GetText(at.NameRange);

            _sb.Append(prefix);
            _sb.Append(colon);
            _sb.Append(name);

            if (at.EqualsSignRange.Length > 0)
            {
                _sb.Append('=');
            }

            if (at.HasValue())
            {
                string value = _tree.Text.GetText(at.ValueRange);
                _sb.Append(value);
            }
        }