Пример #1
0
        public override void VisitAttributeSelector(CssAttributeSelector selector)
        {
            switch (selector.NamespacePrefix)
            {
            case CssSelector.AnyNamespacePrefix:
                _matcher = new AttributeLocalNameMatcher(selector.LocalName, selector.CreatePredicate());
                break;

            case "":
                _matcher = new AttributeNameMatcher(XNamespace.None + selector.LocalName, selector.CreatePredicate());
                break;

            case null:
                var defaultNamespaceName = _namespaceResolver.LookupNamespace("");
                _matcher = string.IsNullOrEmpty(defaultNamespaceName)
                                                ? (ICssElementMatcher) new AttributeLocalNameMatcher(selector.LocalName, selector.CreatePredicate())
                                                : new AttributeNameMatcher(XNamespace.None + selector.LocalName, selector.CreatePredicate());
                break;

            default:
                var namespaceName = _namespaceResolver.LookupNamespace(selector.NamespacePrefix);
                _matcher = string.IsNullOrEmpty(namespaceName)
                                                ? Never
                                                : new AttributeNameMatcher(XName.Get(selector.LocalName, namespaceName), selector.CreatePredicate());
                break;
            }
        }
Пример #2
0
        public override void VisitAttributeSelector(CssAttributeSelector selector)
        {
            _sb.Append('[');

            if (selector.NamespacePrefix != null)
            {
                // We must write a namespace prefix for any explicit namespace. The default namespace
                // does not apply to attributes.
                _sb.Append(selector.NamespacePrefix).Append('|');
            }
            _sb.Append(selector.LocalName);

            if (selector.MatchOperator != CssAttributeMatchOperator.Any)
            {
                if (selector.MatchOperator != CssAttributeMatchOperator.Exact)
                {
                    _sb.Append((char)selector.MatchOperator);
                }
                _sb.Append('=');
                selector.MatchOperandToken.ToString(_sb);
            }

            _sb.Append(']');
        }
Пример #3
0
 public virtual void VisitAttributeSelector(CssAttributeSelector selector)
 {
 }