1
1
mirror of https://github.com/dgis/xsddiagram.git synced 2024-08-17 06:20:23 +03:00

Add the infer XSD from XML menu.

This commit is contained in:
dgis 2016-09-04 23:26:09 +02:00
parent b6bc9a5860
commit a4cab091fa
6 changed files with 108 additions and 21 deletions

57
MainForm.Designer.cs generated
View File

@ -23,6 +23,8 @@ namespace XSDDiagram
this.openURLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveDiagramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.validateXMLFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.generateSampleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.inferXSDFromXMLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
@ -63,7 +65,6 @@ namespace XSDDiagram
this.splitContainerMain = new System.Windows.Forms.SplitContainer();
this.tabControlView = new System.Windows.Forms.TabControl();
this.tabPageDiagram = new System.Windows.Forms.TabPage();
this.panelDiagram = new XSDDiagram.DiagramControlContainer();
this.splitContainerDiagramElement = new System.Windows.Forms.SplitContainer();
this.tabControlElement = new System.Windows.Forms.TabControl();
this.tabPageElementAttibutes = new System.Windows.Forms.TabPage();
@ -103,6 +104,7 @@ namespace XSDDiagram
this.expandOneLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textBoxElementPath = new System.Windows.Forms.TextBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.panelDiagram = new XSDDiagram.DiagramControlContainer();
this.menuStripMain.SuspendLayout();
this.statusStripMain.SuspendLayout();
this.toolStripMain.SuspendLayout();
@ -140,7 +142,9 @@ namespace XSDDiagram
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openToolStripMenuItem,
this.openURLToolStripMenuItem,
this.inferXSDFromXMLToolStripMenuItem,
this.saveDiagramToolStripMenuItem,
this.generateSampleToolStripMenuItem,
this.validateXMLFileToolStripMenuItem,
this.recentFilesToolStripMenuItem,
this.closeToolStripMenuItem,
@ -188,6 +192,21 @@ namespace XSDDiagram
this.validateXMLFileToolStripMenuItem.Text = "&Validate XML File...";
this.validateXMLFileToolStripMenuItem.Click += new System.EventHandler(this.validateXMLFileToolStripMenuItem_Click);
//
// generateSampleToolStripMenuItem
//
this.generateSampleToolStripMenuItem.Name = "generateSampleToolStripMenuItem";
this.generateSampleToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.generateSampleToolStripMenuItem.Text = "&Generate Sample...";
this.generateSampleToolStripMenuItem.Visible = false;
this.generateSampleToolStripMenuItem.Click += new System.EventHandler(this.generateSampleToolStripMenuItem_Click);
//
// inferXSDFromXMLToolStripMenuItem
//
this.inferXSDFromXMLToolStripMenuItem.Name = "inferXSDFromXMLToolStripMenuItem";
this.inferXSDFromXMLToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.inferXSDFromXMLToolStripMenuItem.Text = "Infer XSD from XML...";
this.inferXSDFromXMLToolStripMenuItem.Click += new System.EventHandler(this.inferXSDFromXMLToolStripMenuItem_Click);
//
// recentFilesToolStripMenuItem
//
this.recentFilesToolStripMenuItem.Name = "recentFilesToolStripMenuItem";
@ -601,23 +620,6 @@ namespace XSDDiagram
this.tabPageDiagram.Text = "Diagram";
this.tabPageDiagram.UseVisualStyleBackColor = true;
//
// panelDiagram
//
this.panelDiagram.AllowDrop = true;
this.panelDiagram.AutoScroll = true;
this.panelDiagram.BackColor = System.Drawing.Color.WhiteSmoke;
this.panelDiagram.CausesValidation = false;
this.panelDiagram.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelDiagram.Location = new System.Drawing.Point(0, 0);
this.panelDiagram.Margin = new System.Windows.Forms.Padding(0);
this.panelDiagram.Name = "panelDiagram";
this.panelDiagram.Size = new System.Drawing.Size(650, 499);
this.panelDiagram.TabIndex = 0;
this.panelDiagram.VirtualPoint = new System.Drawing.Point(0, 0);
this.panelDiagram.VirtualSize = new System.Drawing.Size(10, 10);
this.panelDiagram.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelDiagram_DragDrop);
this.panelDiagram.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelDiagram_DragEnter);
//
// splitContainerDiagramElement
//
this.splitContainerDiagramElement.Dock = System.Windows.Forms.DockStyle.Fill;
@ -967,6 +969,23 @@ namespace XSDDiagram
this.toolTip.OwnerDraw = true;
this.toolTip.ShowAlways = true;
//
// panelDiagram
//
this.panelDiagram.AllowDrop = true;
this.panelDiagram.AutoScroll = true;
this.panelDiagram.BackColor = System.Drawing.Color.WhiteSmoke;
this.panelDiagram.CausesValidation = false;
this.panelDiagram.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelDiagram.Location = new System.Drawing.Point(0, 0);
this.panelDiagram.Margin = new System.Windows.Forms.Padding(0);
this.panelDiagram.Name = "panelDiagram";
this.panelDiagram.Size = new System.Drawing.Size(650, 499);
this.panelDiagram.TabIndex = 0;
this.panelDiagram.VirtualPoint = new System.Drawing.Point(0, 0);
this.panelDiagram.VirtualSize = new System.Drawing.Size(10, 10);
this.panelDiagram.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelDiagram_DragDrop);
this.panelDiagram.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelDiagram_DragEnter);
//
// MainForm
//
this.AllowDrop = true;
@ -1102,6 +1121,8 @@ namespace XSDDiagram
private System.Windows.Forms.ToolStripMenuItem recentFilesToolStripMenuItem;
private System.Windows.Forms.ToolStripButton toolStripButtonShowDocumentation;
private System.Windows.Forms.ToolStripMenuItem expandToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem generateSampleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem inferXSDFromXMLToolStripMenuItem;
}
}

View File

@ -1922,6 +1922,60 @@ namespace XSDDiagram
e.Exception.LineNumber, e.Exception.LinePosition, e.Exception.Message, validationErrorMessages.Count, e.Severity));
}
private void generateSampleToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void inferXSDFromXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
Cursor = Cursors.WaitCursor;
//https://msdn.microsoft.com/en-us/library/system.xml.schema.xmlschemainference.aspx
XmlReader reader = XmlReader.Create(openFileDialog.FileName);
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchemaInference schema = new XmlSchemaInference();
schemaSet = schema.InferSchema(reader);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "xsd files (*.xsd) | *.xsd | All files(*.*) | *.* ";
saveFileDialog.FilterIndex = 0;
saveFileDialog.RestoreDirectory = true;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string outputFilename = saveFileDialog.FileName;
using (TextWriter textWriter = File.CreateText(outputFilename))
{
foreach (XmlSchema xmlSchema in schemaSet.Schemas())
{
xmlSchema.Write(textWriter);
}
}
if(MessageBox.Show(this, "Would you open the newly inferred XSD file?", "Open XSD file", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
LoadSchema(outputFilename);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Cursor = Cursors.Default;
}
}
private void toolStripButtonShowDocumentation_Click(object sender, EventArgs e)
{
this.diagram.ShowDocumentation = this.toolStripButtonShowDocumentation.Checked;

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]

View File

@ -1,6 +1,6 @@
XSD Diagram is a free xml schema definition diagram viewer (http://regis.cosnier.free.fr).
Version 1.1 Copyright (c) 2006-2016 Regis Cosnier, All Rights Reserved.
Version 1.2alpha Copyright (c) 2006-2016 Regis Cosnier, All Rights Reserved.
This program is free software and may be distributed
according to the terms of the GNU General Public License (GPL).
@ -107,6 +107,15 @@ NOTES:
TODO LIST:
- Add the infer XSD file in the command line.
- NoukNouk suggestions:
+ Add some display parameter like font type / size for tags / annotation... background color, vertical margin between tags...
+ Element window should be logically sorted - for example I think that name, type, minoccur, maxoccur,
nillable should be on the top of this windows... and other unquoted data can remain in alphabetical order after these 5 first...
+ In element window again, type is showing the related namespace. It could be great to have the possibilty
to hide it (or maybe duplicate type with a full type with namespace and short type W/O namespace)
+ "Pattern" tab addition with the Annotation / Element window in order to show tag restriction/pattern
like this one: <xs:restriction base="xs:string"><xs:pattern value="[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}" /></xs:restriction>
- BUG: Cascading substitution groups may appear weird.
- Add include a possibility to show the length of an element (Jörg S.)
- Add the attributes to the element in the diagram (suggested by bob)
@ -121,6 +130,9 @@ TODO LIST:
CHANGES:
version 1.2alpha (2016-09-??)
- Add infer XSD from XML menu.
version 1.1 (2016-07-08)
- Fix SVG page size.
- The error dialog should now appear if a local dependency cannot be loaded.

Binary file not shown.

Binary file not shown.