Exemplo n.º 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;
        }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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.lastTextInfo  = this;
     // TextInfo:
     this.disableEscaping = false;
     this.valueBuilder    = new StringBuilder();
     this.nextTextInfo    = null;
 }
Exemplo n.º 7
0
 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, /*ignoreCase:*/ true, CultureInfo.InvariantCulture))
         {
             // 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);
     }
 }
Exemplo n.º 8
0
        void WriteEndElement(RecordBuilder record)
        {
            BuilderInfo      node      = record.MainNode;
            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);
        }
Exemplo n.º 9
0
 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.lastTextInfo  = src.lastTextInfo;
     // TextInfo:
     this.disableEscaping = src.disableEscaping;
     this.valueBuilder    = src.valueBuilder;
     this.nextTextInfo    = src.nextTextInfo;
     // This not really correct to copy valueBuilder, but on next usage it will be reinitialized. The same for clone.
 }
Exemplo n.º 10
0
        public BeginEvent(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            Debug.Assert(input != null);
            Debug.Assert(input.NodeType != XPathNodeType.Namespace);
            this.nodeType     = input.NodeType;
            this.namespaceUri = input.NamespaceURI;
            this.name         = input.LocalName;
            this.prefix       = input.Prefix;
            this.empty        = input.IsEmptyTag;
            if (nodeType == XPathNodeType.Element)
            {
                this.htmlProps = HtmlElementProps.GetProps(this.name);
            }
            else if (nodeType == XPathNodeType.Attribute)
            {
                this.htmlProps = HtmlAttributeProps.GetProps(this.name);
            }
        }
Exemplo n.º 11
0
 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.lastTextInfo  = src.lastTextInfo;
     // TextInfo:
     this.disableEscaping = src.disableEscaping;
     this.valueBuilder    = src.valueBuilder;
     this.nextTextInfo    = src.nextTextInfo;
     // This not really correct to copy valueBuilder, but on next usage it will be reinitialized. The same for clone.
 }
Exemplo n.º 12
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.lastTextInfo  = this;
     // TextInfo:
     this.disableEscaping = false;
     this.valueBuilder    = new StringBuilder();
     this.nextTextInfo    = null;
 }
Exemplo n.º 13
0
        //
        // Particular outputs
        //
        void WriteStartElement(RecordBuilder record)
        {
            Debug.Assert(record.MainNode.NodeType == XmlNodeType.Element);
            BuilderInfo      mainNode  = record.MainNode;
            HtmlElementProps htmlProps = null;

            if (this.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 (this.isXmlOutput)
            {
                if (mainNode.Depth == 0)
                {
                    if (
                        secondRoot && (
                            output.DoctypeSystem != null ||
                            output.Standalone
                            )
                        )
                    {
                        throw new XsltException(Res.Xslt_MultipleRoots);
                    }
                    secondRoot = true;
                }
            }

            if (this.outputDoctype)
            {
                WriteDoctype(mainNode);
                this.outputDoctype = false;
            }

            if (this.cdataElements != null && this.cdataElements.Contains(new XmlQualifiedName(mainNode.LocalName, mainNode.NamespaceURI)) && this.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(!this.isHtmlOutput || mainNode.Prefix != null, "Html can't have abreviated 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(this.output.MediaType);
                Write("; charset=");
                Write(this.encoding.WebName);
                Write("\">");
            }
        }
Exemplo n.º 14
0
        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, /*ignoreCase:*/true, CultureInfo.InvariantCulture) ) {
                    // 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);
            }
        }