示例#1
0
 public XQuery(XSDocument doc)
 {
     if (doc == null)
     {
         throw new ArgumentNullException("doc");
     }
     _document = doc;
     InitializeComponent();
 }
示例#2
0
        public EditorFrame(XSDocument doc, Data data)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            InitializeComponent();

            Data             = data;
            Data.EditorFrame = this;
            XSDocument       = doc;

            try
            {
                if (doc.XsdFile != null)
                {
                    Data.ValidationData.Xsd = doc.XsdFile;
                }
            }
            catch (Exception)
            {
                Data.ValidationData.Xsd = null;
            }

            if (!(doc.Filename != null && doc.Filename.ToLower().EndsWith(".xsd")))
            {
                _xsdPropertiesDockable.Visibility = Visibility.Collapsed;
                _xsdVisualizerDockable.Visibility = Visibility.Collapsed;
            }

            _xmlEditor.Editor = this;
            _editorValidation.ValidationData = data.ValidationData;
            _editorValidation.XSDocument     = doc;

            _gridView.Editor              = this;
            _editorValidation.Editor      = this;
            _editorTree.Editor            = this;
            _webBrowser.Editor            = this;
            _xPathQuery.Editor            = this;
            _xPathSearchAndReplace.Editor = this;
            _xsdVisualizer.Editor         = this;
//            _schemaInfo.Editor = this;

            _xPathSearchAndReplaceDockable.Visibility = Visibility.Collapsed;

            //trigger Selector_OnSelectionChanged...
            _xPathQueryDockable.IsSelected = true;
            _editorTreeDockable.IsSelected = true;

            MainWindow wnd = (MainWindow)Application.Current.MainWindow;

            wnd.Ribbon.SelectedTabIndex = 0;  //do not select TreeView-ContextRib initially
        }
示例#3
0
        public void Update(XSDocument xsdoc)
        {
            _lastXmlUsedInUpdate = new XSDocument(xsdoc.Xml, xsdoc.XsdFile);

            _tree.Items.Clear();
            Cursor = Cursors.Wait;

            _lblUpdateInProgress.Visibility = Visibility.Visible;
            _tree.Visibility = Visibility.Collapsed;

            try
            {
                _rootNode = new ViewerNode(xsdoc);
                _backgroundExpander.SetNodeToExpand(_rootNode);
                if (_filter != null)
                {
                    _tree.Background = Brushes.LightYellow;
                    _tree.Items.Add(TreeViewHelper.BuildTreeView(_rootNode,
                                                                 x =>
                                                                 !((ViewerNode)x.Tag).OriginalNode.OuterXml.Contains(_filter, StringComparison.CurrentCultureIgnoreCase)));
                }
                else
                {
                    _tree.Background = Brushes.White;
                    _tree.Items.Add(TreeViewHelper.BuildTreeView(_rootNode));
                }
                ((TreeViewItem)_tree.Items[0]).IsExpanded = true;
            }
            catch (Exception)
            {
                _tree.Items.Clear();
            }
            finally
            {
                _lblUpdateInProgress.Visibility = Visibility.Collapsed;
                _tree.Visibility = Visibility.Visible;
                Cursor           = null;
            }
        }
示例#4
0
        public void Open(XSDocument xml)
        {
            _textEditor.Text = xml.Xml;
            installFoldingManager();

            try
            {
//                XmlDocument xmldoc = xml.XmlDoc;  //throws exception if it is not wellformed or invalid

                string xsd = xml.XsdFile;
                if (xsd != null)
                {
                    SetXsdFile(xsd);
                }
            }
            catch (XmlException)
            {
                //ignore
            }
//            catch (XmlSchemaValidationException)
//            {
//                //ignore
//            }
        }
示例#5
0
        private void displayNavigator(XPathNodeIterator xpi)
        {
            if ((xpi != null) && (xpi.Count > 0))
            {
                for (bool hasNext = xpi.MoveNext(); hasNext; hasNext = xpi.MoveNext())
                {
                    // IXmlLineInfo lineInfo = xpi.Current as IXmlLineInfo;

                    switch (xpi.Current.NodeType)
                    {
                    case XPathNodeType.Text:
                    {
                        TreeViewItem node = new TreeViewItem();
                        node.Header     = xpi.Current.Value;
                        node.Foreground = Brushes.Brown;
                        node.ToolTip    = "(Nodeset/Text)";
                        _treeResult.Items.Add(node);
                        break;
                    }

                    case XPathNodeType.Attribute:
                    {
                        TreeViewItem node = new TreeViewItem();
                        node.Header     = "@" + xpi.Current.Name + ": " + xpi.Current.Value;
                        node.Foreground = Brushes.Brown;
                        node.ToolTip    = "(Nodeset/Attribute)";
                        node.Tag        = xpi.Current.Clone();
                        _treeResult.Items.Add(node);
                        break;
                    }

                    case XPathNodeType.Element:
                    {
                        var          document = new XSDocument(xpi.Current.OuterXml);
                        ViewerNode   vNode    = new ViewerNode(document);
                        TreeViewItem tvi      = TreeViewHelper.BuildTreeView(vNode);

                        //expand all to lazy-load all subitems
                        tvi.ExpandSubtree();
                        //now we can change the tags of all subitems
                        setTag(tvi, xpi.Current.Clone());
                        //collapse them again
                        var allChilds = tvi.AsDepthFirstEnumerable(
                            x => x.Items.Cast <TreeViewItem>());
                        foreach (TreeViewItem treeViewItem in allChilds)
                        {
                            treeViewItem.IsExpanded = false;
                        }

                        _treeResult.Items.Add(tvi);
                        break;
                    }
                    }
                    if (string.IsNullOrEmpty(_editorUserControl1.Text))
                    {
                        _editorUserControl1.Text = xpi.Current.OuterXml;
                    }
                    else
                    {
                        _editorUserControl1.Text = _editorUserControl1.Text + "\r\n" + xpi.Current.OuterXml;
                    }
                }
            }
            else
            {
                _treeResult.Items.Add("Nothing found.");
                _editorUserControl1.Text = "";
            }
        }