public void EmptyCommentNode()
		{
			string xml = "<!----><root/>";
			XPathQuery query = new XPathQuery(xml);
			XPathNodeMatch[] nodes = query.FindNodes("//comment()");
			
			ServiceContainer container = new ServiceContainer();
			container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
			
			IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
			doc.Text = xml;
			XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
			xpathNodeMarker.AddMarkers(nodes);
			
			ITextMarkerService service = doc.GetService(typeof(MockTextMarkerService)) as ITextMarkerService;
			List<ITextMarker> markers = new List<ITextMarker>(service.TextMarkers);
			
			Assert.AreEqual(0, markers.Count);
			Assert.AreEqual(1, nodes.Length);
		}
		public void Init()
		{
			string xml = "<root><foo/></root>";
			XPathQuery query = new XPathQuery(xml);
			XPathNodeMatch[] nodes = query.FindNodes("//root");
			
			IDocument doc = MockTextMarkerService.CreateDocumentWithMockService();
			doc.Text = xml;
			XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
			xpathNodeMarker.AddMarkers(nodes);
			
			ITextMarkerService service = doc.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
			markers = new List<ITextMarker>(service.TextMarkers);
			
			// Remove markers.
			XPathNodeTextMarker.RemoveMarkers(doc);
			markersAfterRemove = new List<ITextMarker>(service.TextMarkers);
			
			xpathNodeTextMarker = markers[0];
		}
		public void NamespaceQuery()
		{
			string xml = 
				"<?xml version='1.0'?>\r\n" +
				"<Xml1></Xml1>";
			XPathQuery query = new XPathQuery(xml);
			XPathNodeMatch[] nodes = query.FindNodes("//namespace::*");
			
			ServiceContainer container = new ServiceContainer();
			container.AddService(typeof(MockTextMarkerService), new MockTextMarkerService());
			
			IDocument doc = new ICSharpCode.AvalonEdit.Document.TextDocument() { ServiceProvider = container };
			doc.Text = xml;
			XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc);
			xpathNodeMarker.AddMarkers(nodes);
			
			ITextMarkerService service = doc.GetService(typeof(MockTextMarkerService)) as ITextMarkerService;
			List<ITextMarker> markers = new List<ITextMarker>(service.TextMarkers);
			
			Assert.AreEqual(0, markers.Count);
			Assert.AreEqual(1, nodes.Length);
		}
Exemplo n.º 4
0
        void RunXPathQuery()
        {
            XmlView xmlView = XmlView.ActiveXmlView;

            if (xmlView == null)
            {
                return;
            }

            try {
                fileName = xmlView.File.FileName;

                // Clear previous XPath results.
                ClearResults();
                XPathNodeTextMarker.RemoveMarkers(xmlView.TextEditor.Document);

                // Run XPath query.
                XPathQuery       query = new XPathQuery(xmlView.TextEditor, GetNamespaces());
                XPathNodeMatch[] nodes = query.FindNodes(xpathComboBox.Text);
                if (nodes.Length > 0)
                {
                    AddXPathResults(nodes);
                    XPathNodeTextMarker marker = new XPathNodeTextMarker(xmlView.TextEditor.Document);
                    marker.AddMarkers(nodes);
                }
                else
                {
                    AddNoXPathResult();
                }
                AddXPathToHistory();
            } catch (XPathException xpathEx) {
                AddErrorResult(xpathEx);
            } catch (XmlException xmlEx) {
                AddErrorResult(xmlEx);
            } finally {
                BringResultsTabToFront();
            }
        }
Exemplo n.º 5
0
        void RunXPathQuery()
        {
            XmlView view = XmlView.ActiveXmlView;

            if (view == null)
            {
                return;
            }

            try {
                MarkerStrategy markerStrategy = view.TextEditorControl.Document.MarkerStrategy;
                fileName = view.PrimaryFileName;

                // Clear previous XPath results.
                ClearResults();
                XPathNodeTextMarker.RemoveMarkers(markerStrategy);

                // Run XPath query.
                XPathNodeMatch[] nodes = view.SelectNodes(xPathComboBox.Text, GetNamespaces());
                if (nodes.Length > 0)
                {
                    AddXPathResults(nodes);
                    XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
                }
                else
                {
                    AddNoXPathResult();
                }
                AddXPathToHistory();
            } catch (XPathException xpathEx) {
                AddErrorResult(xpathEx);
            } catch (XmlException xmlEx) {
                AddErrorResult(xmlEx);
            } finally {
                BringResultsTabToFront();
                view.TextEditorControl.Refresh();
            }
        }
Exemplo n.º 6
0
        void RunXPathQuery()
        {
            XmlView xmlView = XmlView.ActiveXmlView;
            if (xmlView == null) {
                return;
            }

            try {
                fileName = xmlView.File.FileName;

                // Clear previous XPath results.
                ClearResults();
                XPathNodeTextMarker.RemoveMarkers(xmlView.TextEditor.Document);

                // Run XPath query.
                XPathQuery query = new XPathQuery(xmlView.TextEditor, GetNamespaces());
                XPathNodeMatch[] nodes = query.FindNodes(xpathComboBox.Text);
                if (nodes.Length > 0) {
                    AddXPathResults(nodes);
                    XPathNodeTextMarker marker = new XPathNodeTextMarker(xmlView.TextEditor.Document);
                    marker.AddMarkers(nodes);
                } else {
                    AddNoXPathResult();
                }
                AddXPathToHistory();
            } catch (XPathException xpathEx) {
                AddErrorResult(xpathEx);
            } catch (XmlException xmlEx) {
                AddErrorResult(xmlEx);
            } finally {
                BringResultsTabToFront();
            }
        }