Exemple #1
0
        //        static private HtmlElementProps  s_otherElements = Create(false, false, false, false, false, false, false);

        static public HtmlElementProps GetProps(string name)
        {
            HtmlElementProps result = (HtmlElementProps)s_table[name];

            return(result);
            // We can do this but in case of Xml/Html mixed output this doesn't have big sence.
            //            return result != null ?  result : s_otherElements;
        }
 internal void Initialize(string prefix, string name, string nspace) {
     this.prefix         = prefix;
     this.localName      = name;
     this.namespaceURI   = nspace;
     this.name           = null;
     this.htmlProps      = null;
     this.htmlAttrProps  = null;
     this.TextInfoCount  = 0;
 }
 internal void Initialize(string prefix, string name, string nspace)
 {
     this.prefix        = prefix;
     this.localName     = name;
     this.namespaceURI  = nspace;
     this.name          = null;
     this.htmlProps     = null;
     this.htmlAttrProps = null;
     this.TextInfoCount = 0;
 }
Exemple #4
0
 static public HtmlElementProps Create(bool empty, bool abrParent, bool uriParent, bool noEntities, bool blockWS, bool head, bool nameParent) {
     HtmlElementProps props = new HtmlElementProps();
     props.empty      = empty     ;
     props.abrParent  = abrParent ;
     props.uriParent  = uriParent ;
     props.noEntities = noEntities;
     props.blockWS    = blockWS   ;
     props.head       = head      ;
     props.nameParent = nameParent;
     return props;
 }
 internal void Init(string name, string nspace, string prefix, XmlSpace space, string lang, bool mixed) {
     this.scopes           = null;
     this.name             = name;
     this.nsUri            = nspace;
     this.prefix           = prefix;
     this.space            = space;
     this.lang             = lang;
     this.mixed            = mixed;
     this.toCData          = false;
     this.htmlElementProps = null;
 }
Exemple #6
0
 internal void Init(string name, string nspace, string prefix, XmlSpace space, string lang, bool mixed)
 {
     this.scopes           = null;
     this.name             = name;
     this.nsUri            = nspace;
     this.prefix           = prefix;
     this.space            = space;
     this.lang             = lang;
     this.mixed            = mixed;
     this.toCData          = false;
     this.htmlElementProps = null;
 }
Exemple #7
0
 internal void Init(string name, string nspace, string prefix, XmlSpace space, string lang, bool mixed)
 {
     this.scopes = null;
     _name = name;
     _nsUri = nspace;
     _prefix = prefix;
     _space = space;
     _lang = lang;
     _mixed = mixed;
     _toCData = false;
     _htmlElementProps = null;
 }
Exemple #8
0
 internal void Init(string name, string nspace, string prefix, XmlSpace space, string lang, bool mixed)
 {
     this.scopes       = null;
     _name             = name;
     _nsUri            = nspace;
     _prefix           = prefix;
     _space            = space;
     _lang             = lang;
     _mixed            = mixed;
     _toCData          = false;
     _htmlElementProps = null;
 }
Exemple #9
0
 public static HtmlElementProps Create(bool empty, bool abrParent, bool uriParent, bool noEntities, bool blockWS, bool head, bool nameParent)
 {
     HtmlElementProps props = new HtmlElementProps();
     props._empty = empty;
     props._abrParent = abrParent;
     props._uriParent = uriParent;
     props._noEntities = noEntities;
     props._blockWS = blockWS;
     props._head = head;
     props._nameParent = nameParent;
     return props;
 }
        static public HtmlElementProps Create(bool empty, bool abrParent, bool uriParent, bool noEntities, bool blockWS, bool head, bool nameParent)
        {
            HtmlElementProps props = new HtmlElementProps();

            props.empty      = empty;
            props.abrParent  = abrParent;
            props.uriParent  = uriParent;
            props.noEntities = noEntities;
            props.blockWS    = blockWS;
            props.head       = head;
            props.nameParent = nameParent;
            return(props);
        }
        private void WriteEndElement(RecordBuilder record)
        {
            HtmlElementProps htmlProps = record.Manager.CurrentElementScope.HtmlElementProps;

            if (htmlProps != null && htmlProps.Empty)
            {
                return;
            }

            Indent(record);
            Write(s_LessThanSlash);
            WriteName(record.MainNode.Prefix, record.MainNode.LocalName);
            Write(s_GreaterThan);
        }
 private void WriteAttributes(ArrayList list, int count, HtmlElementProps htmlElementsProps)
 {
     Debug.Assert(count <= list.Count);
     for (int attrib = 0; attrib < count; attrib++)
     {
         Debug.Assert(list[attrib] is BuilderInfo);
         BuilderInfo attribute = (BuilderInfo)list[attrib];
         string      attrValue = attribute.Value;
         bool        abr = false, uri = false;
         {
             if (htmlElementsProps != null && attribute.Prefix.Length == 0)
             {
                 HtmlAttributeProps htmlAttrProps = attribute.htmlAttrProps;
                 if (htmlAttrProps == null && attribute.search)
                 {
                     htmlAttrProps = HtmlAttributeProps.GetProps(attribute.LocalName);
                 }
                 if (htmlAttrProps != null)
                 {
                     abr = htmlElementsProps.AbrParent && htmlAttrProps.Abr;
                     uri = htmlElementsProps.UriParent && (htmlAttrProps.Uri ||
                                                           htmlElementsProps.NameParent && htmlAttrProps.Name
                                                           );
                 }
             }
         }
         Write(s_Space);
         WriteName(attribute.Prefix, attribute.LocalName);
         if (abr && string.Equals(attribute.LocalName, attrValue, StringComparison.OrdinalIgnoreCase))
         {
             // Since the name of the attribute = the value of the attribute,
             // this is a boolean attribute whose value should be suppressed
             continue;
         }
         Write(s_EqualQuote);
         if (uri)
         {
             WriteHtmlUri(attrValue);
         }
         else if (_isHtmlOutput)
         {
             WriteHtmlAttributeValue(attrValue);
         }
         else
         {
             WriteXmlAttributeValue(attrValue);
         }
         Write(s_Quote);
     }
 }
        internal void Initialize(BuilderInfo src) {
            this.prefix        = src.Prefix;
            this.localName     = src.LocalName;
            this.namespaceURI  = src.NamespaceURI;
            this.name          = null;
            this.depth         = src.Depth;
            this.nodeType      = src.NodeType;
            this.htmlProps     = src.htmlProps;
            this.htmlAttrProps = src.htmlAttrProps;

            this.TextInfoCount = 0;
            EnsureTextInfoSize(src.TextInfoCount);
            src.TextInfo.CopyTo(this.TextInfo, 0);
            this.TextInfoCount = src.TextInfoCount;
        }
        internal void Initialize(BuilderInfo src)
        {
            this.prefix        = src.Prefix;
            this.localName     = src.LocalName;
            this.namespaceURI  = src.NamespaceURI;
            this.name          = null;
            this.depth         = src.Depth;
            this.nodeType      = src.NodeType;
            this.htmlProps     = src.htmlProps;
            this.htmlAttrProps = src.htmlAttrProps;

            this.TextInfoCount = 0;
            EnsureTextInfoSize(src.TextInfoCount);
            src.TextInfo.CopyTo(this.TextInfo, 0);
            this.TextInfoCount = src.TextInfoCount;
        }
Exemple #15
0
        public BeginEvent(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            Debug.Assert(input != null);
            Debug.Assert(input.NodeType != XPathNodeType.Namespace);
            _nodeType     = input.NodeType;
            _namespaceUri = input.NamespaceURI;
            _name         = input.LocalName;
            _prefix       = input.Prefix;
            _empty        = input.IsEmptyTag;
            if (_nodeType == XPathNodeType.Element)
            {
                _htmlProps = HtmlElementProps.GetProps(_name);
            }
            else if (_nodeType == XPathNodeType.Attribute)
            {
                _htmlProps = HtmlAttributeProps.GetProps(_name);
            }
        }
        private void WriteAttributes(ArrayList list, int count, HtmlElementProps htmlElementsProps) {
            Debug.Assert(count <= list.Count);
            for (int attrib = 0; attrib < count; attrib ++) {
                Debug.Assert(list[attrib] is BuilderInfo);
                BuilderInfo attribute = (BuilderInfo) list[attrib];
                string attrValue = attribute.Value;
                bool abr = false, uri = false; {
                    if(htmlElementsProps != null && attribute.Prefix.Length == 0) {
                        HtmlAttributeProps htmlAttrProps = attribute.htmlAttrProps;
                        if (htmlAttrProps == null && attribute.search) {
                            htmlAttrProps = HtmlAttributeProps.GetProps(attribute.LocalName);
                        }
                        if(htmlAttrProps != null) {
                            abr = htmlElementsProps.AbrParent  && htmlAttrProps.Abr;
                            uri = htmlElementsProps.UriParent  && ( htmlAttrProps.Uri ||
								  htmlElementsProps.NameParent && htmlAttrProps.Name
							);
                        }
                    }
                }
                Write(s_Space);
                WriteName(attribute.Prefix, attribute.LocalName);
                if(abr && 0 == string.Compare(attribute.LocalName, attrValue, StringComparison.OrdinalIgnoreCase) ) {
                    // Since the name of the attribute = the value of the attribute, 
                    // this is a boolean attribute whose value should be suppressed
                    continue; 
                }
                Write(s_EqualQuote);
                if(uri) {
                    WriteHtmlUri(attrValue);
                }
                else if(this.isHtmlOutput) {
                    WriteHtmlAttributeValue(attrValue);
                }
                else {
                    WriteXmlAttributeValue(attrValue);
                }
                Write(s_Quote);
            }
        }
Exemple #17
0
        //
        // Particular outputs
        //
        private void WriteStartElement(RecordBuilder record)
        {
            Debug.Assert(record.MainNode.NodeType == XmlNodeType.Element);
            BuilderInfo      mainNode  = record.MainNode;
            HtmlElementProps?htmlProps = null;

            if (_isHtmlOutput)
            {
                if (mainNode.Prefix.Length == 0)
                {
                    htmlProps = mainNode.htmlProps;
                    if (htmlProps == null && mainNode.search)
                    {
                        htmlProps = HtmlElementProps.GetProps(mainNode.LocalName);
                    }
                    record.Manager.CurrentElementScope.HtmlElementProps = htmlProps;
                    mainNode.IsEmptyTag = false;
                }
            }
            else if (_isXmlOutput)
            {
                if (mainNode.Depth == 0)
                {
                    if (
                        _secondRoot && (
                            _output.DoctypeSystem != null ||
                            _output.Standalone
                            )
                        )
                    {
                        throw XsltException.Create(SR.Xslt_MultipleRoots);
                    }
                    _secondRoot = true;
                }
            }

            if (_outputDoctype)
            {
                WriteDoctype(mainNode);
                _outputDoctype = false;
            }

            if (_cdataElements != null && _cdataElements.Contains(new XmlQualifiedName(mainNode.LocalName, mainNode.NamespaceURI)) && _isXmlOutput)
            {
                record.Manager.CurrentElementScope.ToCData = true;
            }

            Indent(record);
            Write(s_LessThan);
            WriteName(mainNode.Prefix, mainNode.LocalName);

            WriteAttributes(record.AttributeList, record.AttributeCount, htmlProps);


            if (mainNode.IsEmptyTag)
            {
                Debug.Assert(!_isHtmlOutput || mainNode.Prefix != null, "Html can't have abbreviated elements");
                Write(s_SlashGreaterThan);
            }
            else
            {
                Write(s_GreaterThan);
            }

            if (htmlProps != null && htmlProps.Head)
            {
                mainNode.Depth++;
                Indent(record);
                mainNode.Depth--;
                Write("<META http-equiv=\"Content-Type\" content=\"");
                Write(_output.MediaType);
                Write("; charset=");
                Write(this.encoding !.WebName);
                Write("\">");
            }
        }