Пример #1
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);
            }
        }
Пример #2
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("\">");
            }
        }