コード例 #1
0
        /// <summary> Create canonical text from a document </summary>
        public static string Print(AXmlDocument doc)
        {
            CanonicalPrintAXmlVisitor visitor = new CanonicalPrintAXmlVisitor();

            visitor.VisitDocument(doc);
            return(visitor.Output);
        }
コード例 #2
0
		public override void VisitDocument(AXmlDocument document)
		{
			this.CompilationUnit.ErrorsDuringCompile = document.SyntaxErrors.Any();
			this.document = document;

			base.VisitDocument(document);
		}
コード例 #3
0
        /// <summary> Create XML text from a document </summary>
        public static string PrettyPrint(AXmlDocument doc)
        {
            PrettyPrintAXmlVisitor visitor = new PrettyPrintAXmlVisitor();

            visitor.VisitDocument(doc);
            return(visitor.Output);
        }
コード例 #4
0
 /// <summary> Visit RawDocument </summary>
 public virtual void VisitDocument(AXmlDocument document)
 {
     foreach (AXmlObject child in document.Children)
     {
         child.AcceptVisitor(this);
     }
 }
コード例 #5
0
		/// <summary> Visit RawDocument </summary>
		public override void VisitDocument(AXmlDocument document)
		{
			foreach(AXmlObject child in document.Children) {
				AXmlTag tag = child as AXmlTag;
				// Only procssing instructions or elements
				if (tag != null && tag.IsProcessingInstruction && tag.Name != "xml") {
					VisitTag(tag);
				} else if (child is AXmlElement) {
					VisitElement((AXmlElement)child);
				}
			}
		}
コード例 #6
0
ファイル: AXmlParser.cs プロジェクト: zhouweiaccp/gitscc
 void ClearInternal()
 {
     this.UnknownEntityReferenceIsError = true;
     this.TrackedSegments = new TrackedSegmentCollection();
     this.userDocument    = new AXmlDocument()
     {
         Parser = this
     };
     this.userDocument.Document = this.userDocument;
     // Track the document
     this.TrackedSegments.AddParsedObject(this.userDocument, null);
     this.userDocument.IsCached = false;
 }
コード例 #7
0
        /// <summary> Create new parser </summary>
        public AXmlParser()
        {
            this.UnknownEntityReferenceIsError = true;
            this.TrackedSegments = new TrackedSegmentCollection();
            this.Lock            = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            this.userDocument = new AXmlDocument()
            {
                Parser = this
            };
            this.userDocument.Document = this.userDocument;
            // Track the document
            this.TrackedSegments.AddParsedObject(this.userDocument, null);
            this.userDocument.IsCached = false;
        }
コード例 #8
0
 /// <summary> Visit RawDocument </summary>
 public override void VisitDocument(AXmlDocument document)
 {
     foreach (AXmlObject child in document.Children)
     {
         AXmlTag tag = child as AXmlTag;
         // Only procssing instructions or elements
         if (tag != null && tag.IsProcessingInstruction && tag.Name != "xml")
         {
             VisitTag(tag);
         }
         else if (child is AXmlElement)
         {
             VisitElement((AXmlElement)child);
         }
     }
 }
コード例 #9
0
        /// <summary> Raises Changed event </summary>
        protected void OnChanged()
        {
            AXmlParser.Log("Changed {0}", this);
            if (Changed != null)
            {
                Changed(this, new AXmlObjectEventArgs()
                {
                    Object = this
                });
            }
            AXmlDocument doc = this.Document;

            if (doc != null)
            {
                doc.OnObjectChanged(this);
            }
            // As a convenience, also rasie an event for the parent element
            AXmlTag me = this as AXmlTag;

            if (me != null && (me.IsStartOrEmptyTag || me.IsEndTag) && me.Parent is AXmlElement)
            {
                me.Parent.OnChanged();
            }
        }
コード例 #10
0
ファイル: AXmlParser.cs プロジェクト: Altaxo/Altaxo
		void ClearInternal()
		{
			this.UnknownEntityReferenceIsError = true;
			this.TrackedSegments = new TrackedSegmentCollection();
			this.userDocument = new AXmlDocument() { Parser = this };
			this.userDocument.Document = this.userDocument;
			// Track the document
			this.TrackedSegments.AddParsedObject(this.userDocument, null);
			this.userDocument.IsCached = false;
		}
コード例 #11
0
		/// <summary> Visit RawDocument </summary>
		public virtual void VisitDocument(AXmlDocument document)
		{
			foreach(AXmlObject child in document.Children) child.AcceptVisitor(this);
		}
コード例 #12
0
		/// <summary> Create canonical text from a document </summary>
		public static string Print(AXmlDocument doc)
		{
			CanonicalPrintAXmlVisitor visitor = new CanonicalPrintAXmlVisitor();
			visitor.VisitDocument(doc);
			return visitor.Output;
		}
コード例 #13
0
        public AXmlDocument ReadDocument()
        {
            AXmlDocument doc = new AXmlDocument()
            {
                Parser = parser
            };

            // AXmlParser.Log("Flat stream: {0}", PrintObjects(tags));
            List <AXmlObject> valid = MatchTags(tags);
            // AXmlParser.Log("Fixed stream: {0}", PrintObjects(valid));
            IEnumerator <AXmlObject> validStream = valid.GetEnumerator();

            validStream.MoveNext();             // Move to first
            while (true)
            {
                // End of stream?
                try {
                    if (validStream.Current == null)
                    {
                        break;
                    }
                } catch (InvalidCastException) {
                    break;
                }
                doc.AddChild(ReadTextOrElement(validStream));
            }

            if (doc.Children.Count > 0)
            {
                doc.StartOffset = doc.FirstChild.StartOffset;
                doc.EndOffset   = doc.LastChild.EndOffset;
            }

            // Check well formed
            foreach (AXmlTag xmlDeclaration in doc.Children.OfType <AXmlTag>().Where(t => t.IsProcessingInstruction && t.Name.ToLower() == "xml"))
            {
                if (xmlDeclaration.StartOffset != 0)
                {
                    TagReader.OnSyntaxError(doc, xmlDeclaration.StartOffset, xmlDeclaration.StartOffset + 5,
                                            "XML declaration must be at the start of document");
                }
            }
            int elemCount = doc.Children.OfType <AXmlElement>().Count();

            if (elemCount == 0)
            {
                TagReader.OnSyntaxError(doc, doc.EndOffset, doc.EndOffset,
                                        "Root element is missing");
            }
            if (elemCount > 1)
            {
                AXmlElement next = doc.Children.OfType <AXmlElement>().Skip(1).First();
                TagReader.OnSyntaxError(doc, next.StartOffset, next.StartOffset,
                                        "Only one root element is allowed");
            }
            foreach (AXmlTag tag in doc.Children.OfType <AXmlTag>())
            {
                if (tag.IsCData)
                {
                    TagReader.OnSyntaxError(doc, tag.StartOffset, tag.EndOffset,
                                            "CDATA not allowed in document root");
                }
            }
            foreach (AXmlText text in doc.Children.OfType <AXmlText>())
            {
                if (!text.ContainsOnlyWhitespace)
                {
                    TagReader.OnSyntaxError(doc, text.StartOffset, text.EndOffset,
                                            "Only whitespace is allowed in document root");
                }
            }


            AXmlParser.Log("Constructed {0}", doc);
            trackedSegments.AddParsedObject(doc, null);
            return(doc);
        }
コード例 #14
0
 /// <summary> Visit RawDocument </summary>
 public override void VisitDocument(AXmlDocument document)
 {
     base.VisitDocument(document);
 }
コード例 #15
0
		/// <summary> Create XML text from a document </summary>
		public static string PrettyPrint(AXmlDocument doc)
		{
			PrettyPrintAXmlVisitor visitor = new PrettyPrintAXmlVisitor();
			visitor.VisitDocument(doc);
			return visitor.Output;
		}
コード例 #16
0
ファイル: AXmlParser.cs プロジェクト: pusp/o2platform
		/// <summary> Create new parser </summary>
		public AXmlParser()
		{
			this.UnknownEntityReferenceIsError = true;
			this.TrackedSegments = new TrackedSegmentCollection();
			this.Lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
			
			this.userDocument = new AXmlDocument() { Parser = this };
			this.userDocument.Document = this.userDocument;
			// Track the document
			this.TrackedSegments.AddParsedObject(this.userDocument, null);
			this.userDocument.IsCached = false;
		}
コード例 #17
0
		/// <summary> Visit RawDocument </summary>
		public override void VisitDocument(AXmlDocument document)
		{
			base.VisitDocument(document);
		}