void Indent(RecordBuilder record)
 {
     if (!record.Manager.CurrentElementScope.Mixed)
     {
         Indent(record.MainNode.Depth);
     }
 }
        public ReaderOutput StartReader()
        {
            ReaderOutput output = new ReaderOutput(this);

            this.builder = new RecordBuilder(output, this.nameTable);
            return(output);
        }
        public Processor.OutputResult RecordDone(RecordBuilder record) {
            Debug.Assert(record != null);

            BuilderInfo mainNode = record.MainNode;
            documentIndex++;
            switch(mainNode.NodeType) {
                case XmlNodeType.Element: {                    
                    wr.WriteStartElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI );
                    for (int attrib = 0; attrib < record.AttributeCount; attrib ++) {
                        documentIndex++;
                        Debug.Assert(record.AttributeList[attrib] is BuilderInfo);
                        BuilderInfo attrInfo = (BuilderInfo) record.AttributeList[attrib];
                        if (attrInfo.NamespaceURI == XmlReservedNs.NsXmlNs) {
                            if( attrInfo.Prefix.Length == 0 )
                                wr.WriteNamespaceDeclaration(string.Empty, attrInfo.Value );
                            else
                                wr.WriteNamespaceDeclaration( attrInfo.LocalName, attrInfo.Value );                            
                        }
                        else {
                            wr.WriteAttributeString( attrInfo.Prefix, attrInfo.LocalName, attrInfo.NamespaceURI, attrInfo.Value );
                        }
                    }

                    wr.StartElementContent();

                    if (mainNode.IsEmptyTag)
                        wr.WriteEndElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI );
                    break;
                }

                case XmlNodeType.Text:
                    wr.WriteString( mainNode.Value );
                    break;
                case XmlNodeType.Whitespace:
                    break;
                case XmlNodeType.SignificantWhitespace:
                    wr.WriteString( mainNode.Value );
                    break;

                case XmlNodeType.ProcessingInstruction:
                    wr.WriteProcessingInstruction( mainNode.LocalName, mainNode.Value );
                    break;
                case XmlNodeType.Comment:
                    wr.WriteComment( mainNode.Value );
                    break;

                case XmlNodeType.Document:
                    break;

                case XmlNodeType.EndElement:
                    wr.WriteEndElement( mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI );
                    break;

                default:
                    Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType);
                    break;
            }
            record.Reset();
            return Processor.OutputResult.Continue;
        }
示例#4
0
        // RecordOutput interface method implementation
        //
        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            BuilderInfo mainNode = record.MainNode;

            switch (mainNode.NodeType)
            {
                case XmlNodeType.Element:
                    _writer.WriteStartElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI);

                    WriteAttributes(record.AttributeList, record.AttributeCount);

                    if (mainNode.IsEmptyTag)
                    {
                        _writer.WriteEndElement();
                    }
                    break;
                case XmlNodeType.Text:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    _writer.WriteString(mainNode.Value);
                    break;
                case XmlNodeType.CDATA:
                    Debug.Assert(false, "XSLT never gives us CDATA");
                    _writer.WriteCData(mainNode.Value);
                    break;
                case XmlNodeType.EntityReference:
                    _writer.WriteEntityRef(mainNode.LocalName);
                    break;
                case XmlNodeType.ProcessingInstruction:
                    _writer.WriteProcessingInstruction(mainNode.LocalName, mainNode.Value);
                    break;
                case XmlNodeType.Comment:
                    _writer.WriteComment(mainNode.Value);
                    break;
                case XmlNodeType.Document:
                    break;
                case XmlNodeType.DocumentType:
                    _writer.WriteRaw(mainNode.Value);
                    break;
                case XmlNodeType.EndElement:
                    _writer.WriteFullEndElement();
                    break;

                case XmlNodeType.None:
                case XmlNodeType.Attribute:
                case XmlNodeType.Entity:
                case XmlNodeType.Notation:
                case XmlNodeType.DocumentFragment:
                case XmlNodeType.EndEntity:
                    break;
                default:
                    Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType);
                    break;
            }

            record.Reset();
            return Processor.OutputResult.Continue;
        }
示例#5
0
        private void OutputRecord(RecordBuilder record)
        {
            BuilderInfo mainNode = record.MainNode;

            if (_outputXmlDecl)
            {
                WriteXmlDeclaration();
            }

            switch (mainNode.NodeType)
            {
            case XmlNodeType.Element:
                WriteStartElement(record);
                break;

            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                WriteTextNode(record);
                break;

            case XmlNodeType.CDATA:
                Debug.Fail("Should never get here");
                break;

            case XmlNodeType.EntityReference:
                Write(s_Ampersand);
                WriteName(mainNode.Prefix, mainNode.LocalName);
                Write(s_Semicolon);
                break;

            case XmlNodeType.ProcessingInstruction:
                WriteProcessingInstruction(record);
                break;

            case XmlNodeType.Comment:
                Indent(record);
                Write(s_CommentBegin);
                Write(mainNode.Value);
                Write(s_CommentEnd);
                break;

            case XmlNodeType.Document:
                break;

            case XmlNodeType.DocumentType:
                Write(mainNode.Value);
                break;

            case XmlNodeType.EndElement:
                WriteEndElement(record);
                break;

            default:
                break;
            }
        }
示例#6
0
        private void CacheRecord(RecordBuilder record)
        {
            if (_outputCache == null)
            {
                _outputCache = new ArrayList();
            }

            _outputCache.Add(record.MainNode.Clone());
        }
示例#7
0
        //
        // Construction
        //
        public Processor(
            XPathNavigator doc, XsltArgumentList args, XmlResolver resolver,
            Stylesheet stylesheet, List <TheQuery> queryStore, RootAction rootAction,
            IXsltDebugger debugger
            )
        {
            _stylesheet = stylesheet;
            _queryStore = queryStore;
            _rootAction = rootAction;
            _queryList  = new Query[queryStore.Count];
            {
                for (int i = 0; i < queryStore.Count; i++)
                {
                    _queryList[i] = Query.Clone(queryStore[i].CompiledQuery.QueryTree);
                }
            }

            _xsm         = new StateMachine();
            _document    = doc;
            _builder     = null;
            _actionStack = new HWStack(StackIncrement);
            _output      = _rootAction.Output;
            _resolver    = resolver ?? XmlNullResolver.Singleton;
            _args        = args ?? new XsltArgumentList();
            _debugger    = debugger;
            if (_debugger != null)
            {
                _debuggerStack  = new HWStack(StackIncrement, /*limit:*/ 1000);
                _templateLookup = new TemplateLookupActionDbg();
            }

            // Clone the compile-time KeyList
            if (_rootAction.KeyList != null)
            {
                _keyList = new Key[_rootAction.KeyList.Count];
                for (int i = 0; i < _keyList.Length; i++)
                {
                    _keyList[i] = _rootAction.KeyList[i].Clone();
                }
            }

            _scriptExtensions = new Hashtable(_stylesheet.ScriptObjectTypes.Count);
            {
                foreach (DictionaryEntry entry in _stylesheet.ScriptObjectTypes)
                {
                    string namespaceUri = (string)entry.Key;
                    if (GetExtensionObject(namespaceUri) != null)
                    {
                        throw XsltException.Create(SR.Xslt_ScriptDub, namespaceUri);
                    }
                    _scriptExtensions.Add(namespaceUri, Activator.CreateInstance((Type)entry.Value,
                                                                                 BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, null, null));
                }
            }

            this.PushActionFrame(_rootAction, /*nodeSet:*/ null);
        }
示例#8
0
        //
        // Builder stack
        //
        internal void PushOutput(IRecordOutput output)
        {
            Debug.Assert(output != null);
            _builder.OutputState = _xsm.State;
            RecordBuilder lastBuilder = _builder;

            _builder      = new RecordBuilder(output, _nameTable);
            _builder.Next = lastBuilder;

            _xsm.Reset();
        }
        //
        // Builder stack
        //
        internal void PushOutput(RecordOutput output)
        {
            Debug.Assert(output != null);
            this.builder.OutputState = this.xsm.State;
            RecordBuilder lastBuilder = this.builder;

            this.builder      = new RecordBuilder(output, this.nameTable);
            this.builder.Next = lastBuilder;

            this.xsm.Reset();
        }
示例#10
0
        //
        // RecordOutput interface method implementation
        //

        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            this.builder        = record;
            this.mainNode       = record.MainNode;
            this.attributeList  = record.AttributeList;
            this.attributeCount = record.AttributeCount;
            this.manager        = record.Manager;

            this.haveRecord = true;
            SetMainNode();

            return(Processor.OutputResult.Interrupt);
        }
示例#11
0
        internal IRecordOutput PopOutput()
        {
            Debug.Assert(_builder != null);

            RecordBuilder topBuilder = _builder;

            _builder   = topBuilder.Next;
            _xsm.State = _builder.OutputState;

            topBuilder.TheEnd();

            return(topBuilder.Output);
        }
        internal RecordOutput PopOutput()
        {
            Debug.Assert(this.builder != null);

            RecordBuilder topBuilder = this.builder;

            this.builder   = topBuilder.Next;
            this.xsm.State = this.builder.OutputState;

            topBuilder.TheEnd();

            return(topBuilder.Output);
        }
示例#13
0
        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);
        }
示例#14
0
        //
        // RecordOutput interface method implementation
        //

        public Processor.OutputResult RecordDone(RecordBuilder record) {
            BuilderInfo mainNode       = record.MainNode;

            switch (mainNode.NodeType) {
            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                this.writer.Write(mainNode.Value);
                break;
            default:
                break;
            }

            record.Reset();
            return Processor.OutputResult.Continue;
        }
示例#15
0
        //
        // RecordOutput interface method implementation
        //

        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            BuilderInfo mainNode = record.MainNode;

            switch (mainNode.NodeType)
            {
            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                _writer.Write(mainNode.Value);
                break;

            default:
                break;
            }

            record.Reset();
            return(Processor.OutputResult.Continue);
        }
示例#16
0
        public void Execute(Stream stream)
        {
            IRecordOutput recOutput = null;

            switch (_output.Method)
            {
            case XsltOutput.OutputMethod.Text:
                recOutput = new TextOnlyOutput(this, stream);
                break;

            case XsltOutput.OutputMethod.Xml:
            case XsltOutput.OutputMethod.Html:
            case XsltOutput.OutputMethod.Other:
            case XsltOutput.OutputMethod.Unknown:
                recOutput = new TextOutput(this, stream);
                break;
            }
            _builder = new RecordBuilder(recOutput, _nameTable);
            Execute();
        }
        public void Execute(TextWriter writer)
        {
            RecordOutput recOutput = null;

            switch (this.output.Method)
            {
            case XsltOutput.OutputMethod.Text:
                recOutput = new TextOnlyOutput(this, writer);
                break;

            case XsltOutput.OutputMethod.Xml:
            case XsltOutput.OutputMethod.Html:
            case XsltOutput.OutputMethod.Other:
            case XsltOutput.OutputMethod.Unknown:
                recOutput = new TextOutput(this, writer);
                break;
            }
            this.builder = new RecordBuilder(recOutput, this.nameTable);
            Execute();
        }
示例#18
0
        private void WriteTextNode(RecordBuilder record)
        {
            BuilderInfo mainNode = record.MainNode;
            OutputScope scope    = record.Manager.CurrentElementScope;

            scope.Mixed = true;

            if (scope.HtmlElementProps != null && scope.HtmlElementProps.NoEntities)
            {
                // script or stile
                Write(mainNode.Value);
            }
            else if (scope.ToCData)
            {
                WriteCDataSection(mainNode.Value);
            }
            else
            {
                WriteTextNode(mainNode);
            }
        }
示例#19
0
        //
        // RecordOutput interface method implementation
        //

        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            if (_output.Method == XsltOutput.OutputMethod.Unknown)
            {
                if (!DecideDefaultOutput(record.MainNode))
                {
                    CacheRecord(record);
                }
                else
                {
                    OutputCachedRecords();
                    OutputRecord(record);
                }
            }
            else
            {
                OutputRecord(record);
            }

            record.Reset();
            return(Processor.OutputResult.Continue);
        }
        private void CacheRecord(RecordBuilder record) {
            if (this.outputCache == null) {
                this.outputCache = new ArrayList();
            }

            this.outputCache.Add(record.MainNode.Clone());
        }
        private void OutputRecord(RecordBuilder record) {
            BuilderInfo mainNode = record.MainNode;

            if(this.outputXmlDecl) {
                WriteXmlDeclaration();
            }

            switch (mainNode.NodeType) {
            case XmlNodeType.Element:
                WriteStartElement(record);
                break;
            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                WriteTextNode(record);
                break;
            case XmlNodeType.CDATA:
                Debug.Fail("Should never get here");
                break;
            case XmlNodeType.EntityReference:
                Write(s_Ampersand);
                WriteName(mainNode.Prefix, mainNode.LocalName);
                Write(s_Semicolon);
                break;
            case XmlNodeType.ProcessingInstruction:
                WriteProcessingInstruction(record);
                break;
            case XmlNodeType.Comment:
                Indent(record);
                Write(s_CommentBegin);
                Write(mainNode.Value);
                Write(s_CommentEnd);
                break;
            case XmlNodeType.Document:
                break;
            case XmlNodeType.DocumentType:
                Write(mainNode.Value);
                break;
            case XmlNodeType.EndElement:
                WriteEndElement(record);
                break;
            default:
                break;
            }
        }
 void Indent(RecordBuilder record) {
     if (! record.Manager.CurrentElementScope.Mixed) {
         Indent(record.MainNode.Depth);
     }
 }
示例#23
0
        public void Execute(Stream stream)
        {
            RecordOutput recOutput = null;

            switch (_output.Method)
            {
                case XsltOutput.OutputMethod.Text:
                    recOutput = new TextOnlyOutput(this, stream);
                    break;
                case XsltOutput.OutputMethod.Xml:
                case XsltOutput.OutputMethod.Html:
                case XsltOutput.OutputMethod.Other:
                case XsltOutput.OutputMethod.Unknown:
                    recOutput = new TextOutput(this, stream);
                    break;
            }
            _builder = new RecordBuilder(recOutput, _nameTable);
            Execute();
        }
        void WriteTextNode(RecordBuilder record) {
            BuilderInfo mainNode = record.MainNode;
            OutputScope scope = record.Manager.CurrentElementScope;

            scope.Mixed = true;

            if(scope.HtmlElementProps != null && scope.HtmlElementProps.NoEntities) {
                // script or stile
                Write(mainNode.Value);
            }
            else if (scope.ToCData) {
                WriteCDataSection(mainNode.Value);
            }
            else {
                WriteTextNode(mainNode);
            }
        }
示例#25
0
 public void Execute(XmlWriter writer) {
     this.builder = new RecordBuilder(new WriterOutput(this, writer), this.nameTable);
     Execute();
 }
        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);
        }
示例#27
0
        //
        // Construction
        //
        public Processor(
            XPathNavigator doc, XsltArgumentList args, XmlResolver resolver,
            Stylesheet stylesheet, List<TheQuery> queryStore, RootAction rootAction,
            IXsltDebugger debugger
        ) {
            this.stylesheet = stylesheet;
            this.queryStore = queryStore;
            this.rootAction = rootAction;
            this.queryList  = new Query[queryStore.Count]; {
                for(int i = 0; i < queryStore.Count; i ++) {
                    queryList[i] = Query.Clone(queryStore[i].CompiledQuery.QueryTree);
                }
            }

            this.xsm                 = new StateMachine();
            this.document            = doc;
            this.builder             = null;
            this.actionStack         = new HWStack(StackIncrement);
            this.output              = this.rootAction.Output;
            this.permissions         = this.rootAction.permissions;
            this.resolver            = resolver ?? XmlNullResolver.Singleton;
            this.args                = args     ?? new XsltArgumentList();
            this.debugger            = debugger;
            if (this.debugger != null) {
                this.debuggerStack = new HWStack(StackIncrement, /*limit:*/1000);
                templateLookup     = new TemplateLookupActionDbg();
            }

            // Clone the compile-time KeyList
            if (this.rootAction.KeyList != null) {
                this.keyList = new Key[this.rootAction.KeyList.Count];
                for (int i = 0; i < this.keyList.Length; i ++) {
                    this.keyList[i] = this.rootAction.KeyList[i].Clone();
                }
            }

            this.scriptExtensions = new Hashtable(this.stylesheet.ScriptObjectTypes.Count); {
                foreach(DictionaryEntry entry in this.stylesheet.ScriptObjectTypes) {
                    string namespaceUri = (string)entry.Key;
                    if (GetExtensionObject(namespaceUri) != null) {
                        throw XsltException.Create(Res.Xslt_ScriptDub, namespaceUri);
                    }
                    scriptExtensions.Add(namespaceUri, Activator.CreateInstance((Type)entry.Value,
                        BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null));
                }
            }

            this.PushActionFrame(this.rootAction, /*nodeSet:*/null);
        }
示例#28
0
 public ReaderOutput StartReader() {
     ReaderOutput output = new ReaderOutput(this);
     this.builder = new RecordBuilder(output, this.nameTable);
     return output;
 }
示例#29
0
        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            Debug.Assert(record != null);

            BuilderInfo mainNode = record.MainNode;

            _documentIndex++;
            switch (mainNode.NodeType)
            {
            case XmlNodeType.Element:
            {
                _wr.WriteStartElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI);
                for (int attrib = 0; attrib < record.AttributeCount; attrib++)
                {
                    _documentIndex++;
                    Debug.Assert(record.AttributeList[attrib] is BuilderInfo);
                    BuilderInfo attrInfo = (BuilderInfo)record.AttributeList[attrib] !;
                    if (attrInfo.NamespaceURI == XmlReservedNs.NsXmlNs)
                    {
                        if (attrInfo.Prefix.Length == 0)
                        {
                            _wr.WriteNamespaceDeclaration(string.Empty, attrInfo.Value);
                        }
                        else
                        {
                            _wr.WriteNamespaceDeclaration(attrInfo.LocalName, attrInfo.Value);
                        }
                    }
                    else
                    {
                        _wr.WriteAttributeString(attrInfo.Prefix, attrInfo.LocalName, attrInfo.NamespaceURI, attrInfo.Value);
                    }
                }

                _wr.StartElementContent();

                if (mainNode.IsEmptyTag)
                {
                    _wr.WriteEndElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI);
                }
                break;
            }

            case XmlNodeType.Text:
                _wr.WriteString(mainNode.Value);
                break;

            case XmlNodeType.Whitespace:
                break;

            case XmlNodeType.SignificantWhitespace:
                _wr.WriteString(mainNode.Value);
                break;

            case XmlNodeType.ProcessingInstruction:
                _wr.WriteProcessingInstruction(mainNode.LocalName, mainNode.Value);
                break;

            case XmlNodeType.Comment:
                _wr.WriteComment(mainNode.Value);
                break;

            case XmlNodeType.Document:
                break;

            case XmlNodeType.EndElement:
                _wr.WriteEndElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI);
                break;

            default:
                Debug.Fail($"Invalid NodeType on output: {mainNode.NodeType}");
                break;
            }
            record.Reset();
            return(Processor.OutputResult.Continue);
        }
        //
        // RecordOutput interface method implementation
        //

        public Processor.OutputResult RecordDone(RecordBuilder record) {
            if (output.Method == XsltOutput.OutputMethod.Unknown) {
                if (! DecideDefaultOutput(record.MainNode)) {
                    CacheRecord(record);
                }
                else {
                    OutputCachedRecords();
                    OutputRecord(record);    
                }
            }
            else {
                OutputRecord(record);
            }

            record.Reset();
            return Processor.OutputResult.Continue;
        }
示例#31
0
 private void WriteProcessingInstruction(RecordBuilder record)
 {
     Indent(record);
     WriteProcessingInstruction(record.MainNode);
 }
示例#32
0
        //
        // Builder stack
        //
        internal void PushOutput(RecordOutput output) {
            Debug.Assert(output != null);
            this.builder.OutputState = this.xsm.State;
            RecordBuilder lastBuilder = this.builder;
            this.builder      = new RecordBuilder(output, this.nameTable);
            this.builder.Next = lastBuilder;

            this.xsm.Reset();
        }
示例#33
0
        public void Execute(TextWriter writer) {
            RecordOutput recOutput = null;

            switch (this.output.Method) {
            case XsltOutput.OutputMethod.Text:
                recOutput = new TextOnlyOutput(this, writer);
                break;
            case XsltOutput.OutputMethod.Xml:
            case XsltOutput.OutputMethod.Html:
            case XsltOutput.OutputMethod.Other:
            case XsltOutput.OutputMethod.Unknown:
                recOutput = new TextOutput(this, writer);
                break;
            }
            this.builder = new RecordBuilder(recOutput, this.nameTable);
            Execute();
        }
示例#34
0
        internal RecordOutput PopOutput() {
            Debug.Assert(this.builder != null);

            RecordBuilder topBuilder = this.builder;
            this.builder              = topBuilder.Next;
            this.xsm.State            = this.builder.OutputState;

            topBuilder.TheEnd();

            return topBuilder.Output;
        }
示例#35
0
        private void CacheRecord(RecordBuilder record)
        {
            _outputCache ??= new ArrayList();

            _outputCache.Add(record.MainNode.Clone());
        }
        //
        // 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 XsltException.Create(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("\">");
            }
        }
示例#37
0
        // RecordOutput interface method implementation
        //
        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            BuilderInfo mainNode = record.MainNode;

            switch (mainNode.NodeType)
            {
            case XmlNodeType.Element:
                _writer.WriteStartElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI);

                WriteAttributes(record.AttributeList, record.AttributeCount);

                if (mainNode.IsEmptyTag)
                {
                    _writer.WriteEndElement();
                }
                break;

            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                _writer.WriteString(mainNode.Value);
                break;

            case XmlNodeType.CDATA:
                Debug.Fail("XSLT never gives us CDATA");
                _writer.WriteCData(mainNode.Value);
                break;

            case XmlNodeType.EntityReference:
                _writer.WriteEntityRef(mainNode.LocalName);
                break;

            case XmlNodeType.ProcessingInstruction:
                _writer.WriteProcessingInstruction(mainNode.LocalName, mainNode.Value);
                break;

            case XmlNodeType.Comment:
                _writer.WriteComment(mainNode.Value);
                break;

            case XmlNodeType.Document:
                break;

            case XmlNodeType.DocumentType:
                _writer.WriteRaw(mainNode.Value);
                break;

            case XmlNodeType.EndElement:
                _writer.WriteFullEndElement();
                break;

            case XmlNodeType.None:
            case XmlNodeType.Attribute:
            case XmlNodeType.Entity:
            case XmlNodeType.Notation:
            case XmlNodeType.DocumentFragment:
            case XmlNodeType.EndEntity:
                break;

            default:
                Debug.Fail("Invalid NodeType on output: " + mainNode.NodeType);
                break;
            }

            record.Reset();
            return(Processor.OutputResult.Continue);
        }
 public void Execute(XmlWriter writer)
 {
     this.builder = new RecordBuilder(new WriterOutput(this, writer), this.nameTable);
     Execute();
 }
示例#39
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("\">");
            }
        }
        //
        // RecordOutput interface method implementation
        //

        public Processor.OutputResult RecordDone(RecordBuilder record) {
            this.builder        = record;
            this.mainNode       = record.MainNode;
            this.attributeList  = record.AttributeList;
            this.attributeCount = record.AttributeCount;
            this.manager        = record.Manager;

            this.haveRecord     = true;
            SetMainNode();

            return Processor.OutputResult.Interrupt;
        }
 void WriteProcessingInstruction(RecordBuilder record) {
     Indent(record);
     WriteProcessingInstruction(record.MainNode);
 }