Ejemplo n.º 1
0
        //
        // Construction
        //

        private Processor(XPathNavigator doc, XsltArgumentList args, XmlResolver resolver, XslTransform transform)
        {
            transform.LoadCompiledStylesheet(out this.stylesheet, out this.queryList, out this.queryStore, out this.rootAction, doc);

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

            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 new XsltException(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);
        }
Ejemplo n.º 2
0
 void Indent(RecordBuilder record)
 {
     if (!record.Manager.CurrentElementScope.Mixed)
     {
         Indent(record.MainNode.Depth);
     }
 }
Ejemplo n.º 3
0
        private void CacheRecord(RecordBuilder record)
        {
            if (this.outputCache == null)
            {
                this.outputCache = new ArrayList();
            }

            this.outputCache.Add(record.MainNode.Clone());
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        // RecordOutput interface method implementation
        //
        public Processor.OutputResult RecordDone(RecordBuilder record) {
            BuilderInfo mainNode       = record.MainNode;

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

                WriteAttributes(record.AttributeList, record.AttributeCount);

                if (mainNode.IsEmptyTag) {
                    this.writer.WriteEndElement();
                }
                break;
            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                this.writer.WriteString(mainNode.Value);
                break;
            case XmlNodeType.CDATA:
                Debug.Assert(false, "XSLT never gives us CDATA");
                this.writer.WriteCData(mainNode.Value);
                break;
            case XmlNodeType.EntityReference:
                this.writer.WriteEntityRef(mainNode.LocalName);
                break;
            case XmlNodeType.ProcessingInstruction:
                this.writer.WriteProcessingInstruction(mainNode.LocalName, mainNode.Value);
                break;
            case XmlNodeType.Comment:
                this.writer.WriteComment(mainNode.Value);
                break;
            case XmlNodeType.Document:
                break;
            case XmlNodeType.DocumentType:
                this.writer.WriteRaw(mainNode.Value);
                break;
            case XmlNodeType.EndElement:
                this.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: " + ((int)mainNode.NodeType).ToString());
                break;
            }

            record.Reset();
            return Processor.OutputResult.Continue;
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        private void InitializeOutput(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);
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        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);
            }
        }
Ejemplo n.º 16
0
 void WriteProcessingInstruction(RecordBuilder record) {
     Indent(record);
     WriteProcessingInstruction(record.MainNode);
 }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
 void WriteProcessingInstruction(RecordBuilder record)
 {
     Indent(record);
     WriteProcessingInstruction(record.MainNode);
 }
Ejemplo n.º 19
0
        //
        // Construction
        //

        private Processor(XPathNavigator doc, XsltArgumentList args, XmlResolver resolver, XslTransform transform) {
            transform.LoadCompiledStylesheet(out this.stylesheet, out this.queryList, out this.queryStore, out this.rootAction, doc);

            this.xsm                 = new StateMachine();
            this.document            = doc;
            this.builder             = null;
            this.actionStack         = new HWStack(StackIncrement, /*limit:*/1000);
            this.output              = this.rootAction.Output;
            this.resolver            = resolver != null ? resolver : new XmlUrlResolver();
            this.args                = args     != null ? args     : new XsltArgumentList();
            this.debugger            = transform.Debugger;
            if (this.debugger != null) {
                this.debuggerStack = new HWStack(StackIncrement, /*limit:*/1000);
                templateLookup     = new TemplateLookupActionDbg();
            }
            
            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 new XsltException(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);
        }
Ejemplo n.º 20
0
        public Processor.OutputResult RecordDone(RecordBuilder record) {
            Debug.Assert(record != null);

            BuilderInfo mainNode = record.MainNode;
            documentIndex++;
            mainNode.LocalName  = doc.nt.Add(mainNode.LocalName);
            mainNode.NamespaceURI   = doc.nt.Add(mainNode.NamespaceURI);
            switch(mainNode.NodeType) {
                case XmlNodeType.Element: {                    
                    XPathElement e = mainNode.IsEmptyTag ? 
                        new XPathEmptyElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI, 0, 0, node.topNamespace, documentIndex) :
                        new XPathElement(     mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI, 0, 0, node.topNamespace, documentIndex)
                    ;
                    node.AppendChild( e );

                    XPathNamespace last = null;
                    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 == Keywords.s_XmlnsNamespace) {
                            XPathNamespace tmp = new XPathNamespace(attrInfo.Prefix == string.Empty ? string.Empty : attrInfo.LocalName, attrInfo.Value, documentIndex);
                            tmp.next = last;
                            last = tmp;
                        }
                        else {
                            e.AppendAttribute( new XPathAttribute( attrInfo.Prefix, attrInfo.LocalName, attrInfo.NamespaceURI, attrInfo.Value, documentIndex ) );
                        }
                    }

                    if (last != null) {
                        e.AppendNamespaces(last);
                    }

                    if (!mainNode.IsEmptyTag) {
                        node = e;
                    }
                    break;
                }

                case XmlNodeType.Text:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    node.AppendChild( new XPathText( mainNode.Value, 0, 0, documentIndex ) );
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node.AppendChild( new XPathProcessingInstruction( mainNode.LocalName, mainNode.Value, documentIndex ) );
                    break;

                case XmlNodeType.Comment:
                    node.AppendChild( new XPathComment( mainNode.Value, documentIndex ) );
                    break;

                case XmlNodeType.Document:
                    break;

                case XmlNodeType.EndElement:
                    node = node.parent;
                    break;

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

            record.Reset();
            return Processor.OutputResult.Continue;
        }
Ejemplo n.º 21
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;
        }
Ejemplo n.º 22
0
        private void CacheRecord(RecordBuilder record) {
            if (this.outputCache == null) {
                this.outputCache = new ArrayList();
            }

            this.outputCache.Add(record.MainNode.Clone());
        }
Ejemplo n.º 23
0
        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;
            }
        }
Ejemplo n.º 24
0
        //
        // Output Initialization
        //

        private void InitializeOutput() {
            this.builder = new RecordBuilder(new ReaderOutput(this), this.nameTable);
        }
Ejemplo n.º 25
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("\">");
            }
        }
Ejemplo n.º 26
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("\">");
            }
        }
Ejemplo n.º 27
0
        private void InitializeOutput(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);
        }
Ejemplo n.º 28
0
 void Indent(RecordBuilder record) {
     if (! record.Manager.CurrentElementScope.Mixed) {
         Indent(record.MainNode.Depth);
     }
 }
Ejemplo n.º 29
0
        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            Debug.Assert(record != null);

            BuilderInfo mainNode = record.MainNode;

            documentIndex++;
            mainNode.LocalName    = doc.nt.Add(mainNode.LocalName);
            mainNode.NamespaceURI = doc.nt.Add(mainNode.NamespaceURI);
            switch (mainNode.NodeType)
            {
            case XmlNodeType.Element: {
                XPathElement e = mainNode.IsEmptyTag ?
                                 new XPathEmptyElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI, 0, 0, node.topNamespace, documentIndex) :
                                 new XPathElement(mainNode.Prefix, mainNode.LocalName, mainNode.NamespaceURI, 0, 0, node.topNamespace, documentIndex)
                ;
                node.AppendChild(e);

                XPathNamespace last = null;
                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 == Keywords.s_XmlnsNamespace)
                    {
                        XPathNamespace tmp = new XPathNamespace(attrInfo.Prefix == string.Empty ? string.Empty : attrInfo.LocalName, attrInfo.Value, documentIndex);
                        tmp.next = last;
                        last     = tmp;
                    }
                    else
                    {
                        e.AppendAttribute(new XPathAttribute(attrInfo.Prefix, attrInfo.LocalName, attrInfo.NamespaceURI, attrInfo.Value, documentIndex));
                    }
                }

                if (last != null)
                {
                    e.AppendNamespaces(last);
                }

                if (!mainNode.IsEmptyTag)
                {
                    node = e;
                }
                break;
            }

            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                node.AppendChild(new XPathText(mainNode.Value, 0, 0, documentIndex));
                break;

            case XmlNodeType.ProcessingInstruction:
                node.AppendChild(new XPathProcessingInstruction(mainNode.LocalName, mainNode.Value, documentIndex));
                break;

            case XmlNodeType.Comment:
                node.AppendChild(new XPathComment(mainNode.Value, documentIndex));
                break;

            case XmlNodeType.Document:
                break;

            case XmlNodeType.EndElement:
                node = node.parent;
                break;

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

            record.Reset();
            return(Processor.OutputResult.Continue);
        }
Ejemplo n.º 30
0
 private void InitializeOutput(XmlWriter writer) {
     this.builder = new RecordBuilder(new WriterOutput(this, writer), this.nameTable);
 }
Ejemplo n.º 31
0
        //
        // Output Initialization
        //

        private void InitializeOutput()
        {
            this.builder = new RecordBuilder(new ReaderOutput(this), this.nameTable);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 33
0
 private void InitializeOutput(XmlWriter writer)
 {
     this.builder = new RecordBuilder(new WriterOutput(this, writer), this.nameTable);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 35
0
        // RecordOutput interface method implementation
        //
        public Processor.OutputResult RecordDone(RecordBuilder record)
        {
            BuilderInfo mainNode = record.MainNode;

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

                WriteAttributes(record.AttributeList, record.AttributeCount);

                if (mainNode.IsEmptyTag)
                {
                    this.writer.WriteEndElement();
                }
                break;

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

            case XmlNodeType.CDATA:
                Debug.Assert(false, "XSLT never gives us CDATA");
                this.writer.WriteCData(mainNode.Value);
                break;

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

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

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

            case XmlNodeType.Document:
                break;

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

            case XmlNodeType.EndElement:
                this.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: " + ((int)mainNode.NodeType).ToString());
                break;
            }

            record.Reset();
            return(Processor.OutputResult.Continue);
        }
Ejemplo n.º 36
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;
        }