Exemplo n.º 1
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.º 2
0
        void WriteProcessingInstruction(BuilderInfo node)
        {
            Write(s_LessThanQuestion);
            WriteName(node.Prefix, node.LocalName);
            Write(s_Space);
            Write(node.Value);

            if (this.isHtmlOutput)
            {
                Write(s_GreaterThan);
            }
            else
            {
                Write(s_QuestionGreaterThan);
            }
        }
Exemplo n.º 3
0
        private void OutputCachedRecords()
        {
            if (this.outputCache == null)
            {
                return;
            }

            for (int record = 0; record < this.outputCache.Count; record++)
            {
                Debug.Assert(this.outputCache[record] is BuilderInfo);
                BuilderInfo info = (BuilderInfo)this.outputCache[record];

                OutputRecord(info);
            }

            this.outputCache = null;
        }
Exemplo n.º 4
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.º 5
0
        private void ResetRecord(int state)
        {
            Debug.Assert(this.recordState == NoRecord || this.recordState == SomeRecord);

            if ((state & StateMachine.BeginRecord) != 0)
            {
                this.attributeCount = 0;
                this.namespaceCount = 0;
                this.currentInfo    = this.mainNode;

                LocalName = NamespaceURI = Prefix = this.atoms.Empty;
                this.currentInfo.ClearValue();
                NodeType      = XmlNodeType.None;
                IsEmptyTag    = false;
                htmlProps     = null;
                htmlAttrProps = null;
            }
        }
Exemplo n.º 6
0
        private void FixupAttributes(int attributeCount)
        {
            for (int attr = 0; attr < attributeCount; attr++)
            {
                Debug.Assert(this.attributeList[attr] is BuilderInfo);
                BuilderInfo info = (BuilderInfo)this.attributeList[attr];


                if (Keywords.Equals(info.NamespaceURI, this.atoms.Empty))
                {
                    info.Prefix = this.atoms.Empty;
                }
                else
                {
                    if (Keywords.Equals(info.Prefix, this.atoms.Empty))
                    {
                        info.Prefix = GetPrefixForNamespace(info.NamespaceURI);
                    }
                    else
                    {
                        bool   thisScope = false;
                        string nspace    = this.scopeManager.ResolveNamespace(info.Prefix, out thisScope);
                        if (nspace != null)
                        {
                            if (!Keywords.Equals(info.NamespaceURI, nspace))
                            {
                                if (thisScope)  // prefix conflict
                                {
                                    info.Prefix = GetPrefixForNamespace(info.NamespaceURI);
                                }
                                else
                                {
                                    DeclareNamespace(info.NamespaceURI, info.Prefix);
                                }
                            }
                        }
                        else
                        {
                            DeclareNamespace(info.NamespaceURI, info.Prefix);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        private void BeginNamespace(string name, string nspace)
        {
            bool thisScope = false;

            if (Keywords.Equals(name, this.atoms.Empty))
            {
                if (Keywords.Equals(nspace, this.scopeManager.DefaultNamespace))
                {
                    // Main Node is OK
                }
                else if (Keywords.Equals(this.mainNode.NamespaceURI, this.atoms.Empty))
                {
                    // http://www.w3.org/1999/11/REC-xslt-19991116-errata/ E25
                    // Should throw an error but ingnoring it in Everett.
                    // Would be a breaking change
                }
                else
                {
                    DeclareNamespace(nspace, name);
                }
            }
            else
            {
                string nspaceDeclared = this.scopeManager.ResolveNamespace(name, out thisScope);
                if (nspaceDeclared != null)
                {
                    if (!Keywords.Equals(nspace, nspaceDeclared))
                    {
                        if (!thisScope)
                        {
                            DeclareNamespace(nspace, name);
                        }
                    }
                }
                else
                {
                    DeclareNamespace(nspace, name);
                }
            }
            this.currentInfo     = dummy;
            currentInfo.NodeType = XmlNodeType.Attribute;
        }
Exemplo n.º 9
0
        private void BeginAttribute(string prefix, string name, string nspace, Object htmlAttrProps, bool search)
        {
            int attrib = FindAttribute(name, nspace, ref prefix);

            if (attrib == -1)
            {
                attrib = NewAttribute();
            }

            Debug.Assert(this.attributeList[attrib] != null && this.attributeList[attrib] is BuilderInfo);

            BuilderInfo attribute = (BuilderInfo)this.attributeList[attrib];

            attribute.Initialize(prefix, name, nspace);
            attribute.Depth         = this.recordDepth;
            attribute.NodeType      = XmlNodeType.Attribute;
            attribute.htmlAttrProps = htmlAttrProps as HtmlAttributeProps;
            attribute.search        = search;
            this.currentInfo        = attribute;
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        private bool FindAttribute(String name, out int attrIndex)
        {
            if (name == null)
            {
                name = String.Empty;
            }

            for (int index = 0; index < this.attributeCount; index++)
            {
                Debug.Assert(this.attributeList[index] is BuilderInfo);

                BuilderInfo attribute = (BuilderInfo)this.attributeList[index];
                if (attribute.Name == name)
                {
                    attrIndex = index;
                    return(true);
                }
            }

            attrIndex = -1;
            return(false);
        }
Exemplo n.º 12
0
        private void DeclareNamespace(string nspace, string prefix)
        {
            int index = NewNamespace();

            Debug.Assert(this.namespaceList[index] != null && this.namespaceList[index] is BuilderInfo);

            BuilderInfo ns = (BuilderInfo)this.namespaceList[index];

            if (prefix == this.atoms.Empty)
            {
                ns.Initialize(this.atoms.Empty, this.atoms.Xmlns, this.atoms.XmlnsNamespace);
            }
            else
            {
                ns.Initialize(this.atoms.Xmlns, prefix, this.atoms.XmlnsNamespace);
            }
            ns.Depth    = this.recordDepth;
            ns.NodeType = XmlNodeType.Attribute;
            ns.Value    = nspace;

            this.scopeManager.PushNamespace(prefix, nspace);
        }
Exemplo n.º 13
0
        public override bool ReadAttributeValue()
        {
            if (ReadState != ReadState.Interactive || NodeType != XmlNodeType.Attribute)
            {
                return(false);
            }

            if (this.attributeValue == null)
            {
                this.attributeValue          = new BuilderInfo();
                this.attributeValue.NodeType = XmlNodeType.Text;
            }
            if (this.currentInfo == this.attributeValue)
            {
                return(false);
            }

            this.attributeValue.Value = this.currentInfo.Value;
            this.attributeValue.Depth = this.currentInfo.Depth + 1;
            this.currentInfo          = this.attributeValue;

            return(true);
        }
Exemplo n.º 14
0
        private void BeginNamespace(string name, string nspace)
        {
            bool thisScope = false;

            if (Keywords.Equals(name, this.atoms.Empty))
            {
                if (Keywords.Equals(nspace, this.scopeManager.DefaultNamespace))
                {
                    // Main Node is OK
                }
                else
                {
                    DeclareNamespace(nspace, name);
                }
            }
            else
            {
                string nspaceDeclared = this.scopeManager.ResolveNamespace(name, out thisScope);
                if (nspaceDeclared != null)
                {
                    if (!Keywords.Equals(nspace, nspaceDeclared))
                    {
                        if (!thisScope)
                        {
                            DeclareNamespace(nspace, name);
                        }
                    }
                }
                else
                {
                    DeclareNamespace(nspace, name);
                }
            }
            this.currentInfo     = dummy;
            currentInfo.NodeType = XmlNodeType.Attribute;
        }
Exemplo n.º 15
0
        private void AnalyzeSpaceLang()
        {
            Debug.Assert(this.mainNode.NodeType == XmlNodeType.Element);

            for (int attr = 0; attr < this.attributeCount; attr++)
            {
                Debug.Assert(this.attributeList[attr] is BuilderInfo);
                BuilderInfo info = (BuilderInfo)this.attributeList[attr];

                if (Keywords.Equals(info.Prefix, this.atoms.Xml))
                {
                    OutputScope scope = this.scopeManager.CurrentElementScope;

                    if (Keywords.Equals(info.LocalName, this.atoms.Lang))
                    {
                        scope.Lang = info.Value;
                    }
                    else if (Keywords.Equals(info.LocalName, this.atoms.Space))
                    {
                        scope.Space = TranslateXmlSpace(info.Value);
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void SetAttribute(int attrib) {
            Debug.Assert(0 <= attrib && attrib < this.attributeCount);
            Debug.Assert(0 <= attrib && attrib < this.attributeList.Count);
            Debug.Assert(this.attributeList[attrib] is BuilderInfo);

            this.currentIndex = attrib;
            this.currentInfo  = (BuilderInfo) this.attributeList[attrib];
        }
Exemplo n.º 17
0
        //
        // Implementation internals
        //

        private void SetMainNode() {
            this.currentIndex   = -1;
            this.currentInfo    = this.mainNode;
        }
Exemplo n.º 18
0
 void WriteTextNode(BuilderInfo node) {
     for(TextInfo textInfo = node; textInfo != null; textInfo = textInfo.nextTextInfo) {
         if(textInfo.disableEscaping) {
             Write(textInfo.valueBuilder.ToString());
         }
         else {
             WriteWithReplace(textInfo.valueBuilder.ToString(), s_TextValueFind, s_TextValueReplace);
         }
     }
 }
Exemplo n.º 19
0
 private void Reset() {
     this.currentIndex = -1;
     this.currentInfo  = s_DefaultInfo;
     this.mainNode     = s_DefaultInfo;
     this.manager      = null;
 }
Exemplo n.º 20
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.º 21
0
        private void BeginAttribute(string prefix, string name, string nspace, Object htmlAttrProps, bool search) {
            int attrib = FindAttribute(name, nspace, ref prefix);

            if (attrib == -1) {
                attrib = NewAttribute();
            }

            Debug.Assert(this.attributeList[attrib] != null && this.attributeList[attrib] is BuilderInfo);

            BuilderInfo attribute = (BuilderInfo) this.attributeList[attrib];
            attribute.Initialize(prefix, name, nspace);
            attribute.Depth    = this.recordDepth;
            attribute.NodeType = XmlNodeType.Attribute;
            attribute.htmlAttrProps = htmlAttrProps as HtmlAttributeProps;
            attribute.search = search;
            this.currentInfo  = attribute;
        }
Exemplo n.º 22
0
        private void OutputRecord(BuilderInfo node) {
            if(this.outputXmlDecl) {
                WriteXmlDeclaration();
            }

            Indent(0); // we can have only top level stuff here

            switch (node.NodeType) {
            case XmlNodeType.Element:
                Debug.Fail("Should never get here");
                break;
            case XmlNodeType.Text:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                WriteTextNode(node);
                break;
            case XmlNodeType.CDATA:
                Debug.Fail("Should never get here");
                break;
            case XmlNodeType.EntityReference:
                Write(s_Ampersand);
                WriteName(node.Prefix, node.LocalName);
                Write(s_Semicolon);
                break;
            case XmlNodeType.ProcessingInstruction:
                WriteProcessingInstruction(node);
                break;
            case XmlNodeType.Comment:
                Write(s_CommentBegin);
                Write(node.Value);
                Write(s_CommentEnd);
                break;
            case XmlNodeType.Document:
                break;
            case XmlNodeType.DocumentType:
                Write(node.Value);
                break;
            case XmlNodeType.EndElement:
                Debug.Fail("Should never get here");
                break;
            default:
                break;
            }
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 private void BeginNamespace(string name, string nspace) {
     bool thisScope = false;
     if (Keywords.Equals(name, this.atoms.Empty)) {
         if (Keywords.Equals(nspace, this.scopeManager.DefaultNamespace)) {
             // Main Node is OK
         }
         else {
             DeclareNamespace(nspace, name);
         }
     }
     else {
         string nspaceDeclared = this.scopeManager.ResolveNamespace(name, out thisScope);
         if (nspaceDeclared != null) {
             if (! Keywords.Equals(nspace, nspaceDeclared)) {
                 if(!thisScope) {
                     DeclareNamespace(nspace, name);
                 }
             }
         }
         else {
              DeclareNamespace(nspace, name);
         }
     }
     this.currentInfo = dummy;
     currentInfo.NodeType = XmlNodeType.Attribute;
 }
Exemplo n.º 25
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.º 26
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;
        }
Exemplo n.º 27
0
        private void ResetRecord(int state) {
            Debug.Assert(this.recordState == NoRecord || this.recordState == SomeRecord);

            if ((state & StateMachine.BeginRecord) != 0) {
                this.attributeCount     = 0;
                this.namespaceCount     = 0;
                this.currentInfo        = this.mainNode;

                LocalName    = NamespaceURI = Prefix = this.atoms.Empty;
                this.currentInfo.ClearValue();
                NodeType      = XmlNodeType.None;
                IsEmptyTag    = false;
                htmlProps     = null;
                htmlAttrProps = null;
            }
        }
Exemplo n.º 28
0
        void WriteProcessingInstruction(BuilderInfo node) {
            Write(s_LessThanQuestion);
            WriteName(node.Prefix, node.LocalName);
            Write(s_Space);
            Write(node.Value);

            if(this.isHtmlOutput) {
                Write(s_GreaterThan);
            }
            else {
                Write(s_QuestionGreaterThan);
            }
        }
Exemplo n.º 29
0
        public override string GetAttribute(int i)
        {
            BuilderInfo attribute = GetBuilderInfo(i);

            return(attribute.Value);
        }
Exemplo n.º 30
0
 void WriteDoctype(BuilderInfo mainNode) {
     Debug.Assert(this.outputDoctype == true, "It supposed to check this condition before actual call");
     Debug.Assert(this.output.DoctypeSystem != null || (this.isHtmlOutput && this.output.DoctypePublic != null), "We set outputDoctype == true only if");
     Indent(0);
     Write(s_DocType);
     if (this.isXmlOutput) {
         WriteName(mainNode.Prefix, mainNode.LocalName);
     }
     else {
         WriteName(string.Empty, s_Html);
     }
     Write(s_Space);
     if (output.DoctypePublic != null) {
         Write(s_Public);
         Write(s_Quote);
         Write(output.DoctypePublic);
         Write(s_QuoteSpace);
     }
     else {
         Write(s_System);
     }
     if (output.DoctypeSystem != null) {
         Write(s_Quote);
         Write(output.DoctypeSystem);
         Write(s_Quote);
     }
     Write(s_GreaterThan);
 }
Exemplo n.º 31
0
        //
        // Implementation internals
        //

        private void SetMainNode()
        {
            this.currentIndex = -1;
            this.currentInfo  = this.mainNode;
        }
Exemplo n.º 32
0
 private bool DecideDefaultOutput(BuilderInfo node) {
     XsltOutput.OutputMethod method = XsltOutput.OutputMethod.Xml;
     switch (node.NodeType) {
     case XmlNodeType.Element:
         if (node.NamespaceURI.Length == 0 && String.Compare(Keywords.s_Html, node.LocalName, /*ignoreCase:*/true, CultureInfo.InvariantCulture) == 0) {
             method = XsltOutput.OutputMethod.Html;
         }
         break;
     case XmlNodeType.Text:
     case XmlNodeType.Whitespace:
     case XmlNodeType.SignificantWhitespace:
         if (XmlCharType.IsOnlyWhitespace(node.Value)) {
             return false;
         }
         method = XsltOutput.OutputMethod.Xml;
         break;
     default :
         return false;
     }
     if(this.processor.SetDefaultOutput(method)) {
         CacheOuptutProps(processor.Output);                
     }
     return true;
 }
Exemplo n.º 33
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);
        }
Exemplo n.º 34
0
        public override bool ReadAttributeValue() {
            if (ReadState != ReadState.Interactive || NodeType != XmlNodeType.Attribute) {
                return false;
            }

            if (this.attributeValue == null) {
                this.attributeValue = new BuilderInfo();
                this.attributeValue.NodeType = XmlNodeType.Text;
            }
            if (this.currentInfo == this.attributeValue) {
                return false;
            }

            this.attributeValue.Value = this.currentInfo.Value;
            this.attributeValue.Depth = this.currentInfo.Depth + 1;
            this.currentInfo          = this.attributeValue;

            return true;
        }