Skip to content

Commit

Permalink
sort xml element names
Browse files Browse the repository at this point in the history
add documentation.
  • Loading branch information
lovettchris committed Sep 20, 2024
1 parent b6000cd commit b235b93
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 108 deletions.
Binary file modified docs/assets/images/schemas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions docs/help/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ XML schemas. These schemas are used for [Validation](validation.md) and [Intelli
![Schemas](../assets/images/schemas.png)

You can click the browse buttons on the right-hand side to bring up the Open File Dialog to browse for new files, or you
can select the "Add Files" item in the [File Menu](menus.md) to add a batch of schemas. You can click the column
can select the "Add Files" item in the File Menu to add a batch of schemas. You can click the column
headings to sort by that column.

The first column contains checkboxes, which can be used to temporarily disable a schema from being used in validation.
Expand All @@ -16,4 +16,8 @@ This list of schemas is persisted in the `XmlNotepad.settings` file, so it is re

When you add schemas this way you can create a new document and when you add a new root element you should see some
intellisense showing possible root elements and when you select from the dropdown the new element is associated with the
correct namespace so that intellisense continues from there.
correct namespace so that intellisense continues from there.

You can also select a row in this dialog and choose `File/Generate XML Instance` to get a new document that contains
a template containing all required elements from the associated schema. If there is more than one top level element
in the schema a menu will appear from which you can select the element you would like to start with.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ There have been over 6 million downloads since then - thanks to everyone who tri
- Handy "XML statistics" tool to summarize info about your XML documents.
- [Dynamic help](help/dynamic.md) from XSD annotations.
- Goto definition to navigate includes and XSD schema information.
- Generate XML document from [XSD Schema](help/schemas.md).
- Vibrant community with many [updates and bug fixes](help/updates.md).

Go to the [installer page](install.md).
Expand Down
13 changes: 12 additions & 1 deletion src/Application/FormSchemas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,11 @@ private void GenerateXmlFrom(SchemaItem item)
}
else if (names.Count > 1)
{
names.Sort(new Comparison<XmlSchemaElement>((a, b) =>
{
return a.Name.CompareTo(b.Name);
}));

ContextMenu menu = new ContextMenu();
foreach (var e in names)
{
Expand All @@ -1143,7 +1148,8 @@ private void GenerateXmlFrom(SchemaItem item)
menuItem.Click += OnSelectElement;
menu.MenuItems.Add(menuItem);
}
this.ContextMenu = menu;
this.ContextMenu = menu;
menu.Collapse += OnMenuClose;
menu.Show(this, new System.Drawing.Point(100, 100));
return;
}
Expand All @@ -1156,6 +1162,11 @@ private void GenerateXmlFrom(SchemaItem item)
}
}

private void OnMenuClose(object sender, EventArgs e)
{
this.ContextMenu = null;
}

private void GenerateXmlInstance(XmlSchemaElement e)
{
XmlSchema s = XsdInstanceGenerator.GetSchema(e);
Expand Down
122 changes: 17 additions & 105 deletions src/Application/Samples/Employee.htm
Original file line number Diff line number Diff line change
@@ -1,107 +1,19 @@
<HTML xmlns:dt="http://www.w3.org/2001/XMLSchema-instance" xmlns:d2="urn:schemas-microsoft-com:datatypes">
<HEAD>
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<STYLE>

body {font-family:Courier New;font-size:10pt;margin-right:1.5em;background:AliceBlue}
.c{ }
.m{color:#505050} /* markup */
.b{color:red;font-weight:bold;text-decoration:none} /* non breaking space */
.e{margin-left:1em;text-indent:-1em;margin-right:1em} /* expandable */
.k{margin-left:1em;text-indent:-1em;margin-right:1em} /* outer comment (non-expandable)? */
.at{color:Maroon} /* attribute name */
.av {color:Black;} /* attribute value */
.t {color:#004080} /* element name */
.tx{color:Black} /* text content */
.pi{color:Purple} /* pi name and content */
.ci{color:Green} /* comment value */
.side{background-color:#FFFACD} /* intro div */
.outputtip { display:none }
a { color:#004080 }
a:visited { color:Purple }
a:hover { color:Purple }
pre {margin:0px;display:inline}
</STYLE>
</HEAD>
<BODY class="st">
<div style="padding:5px;" class="side tx">

Your XML document contains no xml-stylesheet processing instruction. To provide
an <a href="https://www.tutorialspoint.com/xslt/index.htm" target="_new">XSLT transform</a>, add the following to the top of your file and edit the href
attribute accordingly:

<pre><span class="m">&lt;?</span><span class="pi">xml-stylesheet</span> <span class="at">type</span><span class="m">="</span><span class="av">text/xsl</span><span class="m">" </span><span class="at">href</span><span class="m">="</span><span class="av">stylesheet.xsl</span><span class="m">" ?&gt;</span></pre>
<title>
</title>
<style>
body, td, th { font-family:Verdana, Arial, helvetica, sans-serif; font-size:x-small; }
</style>
</head>
<body STYLE=" background-color:#EEEEEE">
<center>
<h1>
</h1>
<p>
You can also enter the XSLT file name using the above "XSLT Location:" text box, but this will not
persist with your XML document.
</p>
<div class="outputtip">
You can specify a default output file name using the following in your XML documents:
<pre><span class="m">&lt;?</span><span class="pi">xsl-output</span> <span class="at">default</span><span class="m">="</span><span class="av">xslt_output</span><span class="m">" ?&gt;</span></pre>
</div>
</div>
<div class="e"><span class="m">&lt;?</span><span class="pi">xsl-output 
default="Employee.htm"</span><span class="m">?&gt;</span></div>
<div class="e">
<div class="c" STYLE="margin-left:1em;text-indent:-2em"><A href="#" onclick="return false" onfocus="h()" class="b"></A><span class="m">&lt;</span><span class="t">Employees</span>
<span class="at">xsi:schemaLocation</span><span class="m">="</span><span class="av">http://Employees Employee.xsd</span><span class="m">"</span>
<span class="m">&gt;</span></div>
<div>
<div class="e">
<div class="c" STYLE="margin-left:1em;text-indent:-2em"><A href="#" onclick="return false" onfocus="h()" class="b"></A><span class="m">&lt;</span><span class="t">Employee</span>
<span class="at">id</span><span class="m">="</span><span class="av">12615</span><span class="m">"</span>

<span class="at">title</span><span class="m">="</span><span class="av">Architect</span><span class="m">"</span>
<span class="m">&gt;</span></div>
<div>
<div class="k"><span><span class="m">&lt;!--</span></span><span id="clean" class="ci"><pre>This is a comment</pre></span><span class="b">&nbsp;</span><span class="m">--&gt;</span></div>
<div class="e">
<div class="c" STYLE="margin-left:1em;text-indent:-2em"><A href="#" onclick="return false" onfocus="h()" class="b"></A><span class="m">&lt;</span><span class="t">Name</span><span class="m">&gt;</span></div>
<div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">First</span><span class="m">&gt;</span><span class="tx">Nancy</span><span class="m">&lt;/</span><span class="t">First</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Middle</span><span class="m">&gt;</span><span class="tx">J.</span><span class="m">&lt;/</span><span class="t">Middle</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Last</span><span class="m">&gt;</span><span class="tx">Davolio</span><span class="m">&lt;/</span><span class="t">Last</span><span class="m">&gt;</span></div>
</div>
<div><span class="b">&nbsp;</span><span class="m">&lt;/</span><span class="t">Name</span><span class="m">&gt;</span></div>
</div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Street</span><span class="m">&gt;</span><span class="tx">507 - 20th Ave. E. Apt. 2A</span><span class="m">&lt;/</span><span class="t">Street</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">City</span><span class="m">&gt;</span><span class="tx">Seattle</span><span class="m">&lt;/</span><span class="t">City</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Zip</span><span class="m">&gt;</span><span class="tx">98122</span><span class="m">&lt;/</span><span class="t">Zip</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div class="c" STYLE="margin-left:1em;text-indent:-2em"><A href="#" onclick="return false" onfocus="h()" class="b"></A><span class="m">&lt;</span><span class="t">Country</span><span class="m">&gt;</span></div>
<div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Name</span><span class="m">&gt;</span><span class="tx">U.S.A.</span><span class="m">&lt;/</span><span class="t">Name</span><span class="m">&gt;</span></div>
</div>
<div><span class="b">&nbsp;</span><span class="m">&lt;/</span><span class="t">Country</span><span class="m">&gt;</span></div>
</div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Office</span><span class="m">&gt;</span><span class="tx">5/7682</span><span class="m">&lt;/</span><span class="t">Office</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Phone</span><span class="m">&gt;</span><span class="tx">(206) 555-9857</span><span class="m">&lt;/</span><span class="t">Phone</span><span class="m">&gt;</span></div>
</div>
<div class="e">
<div STYLE="margin-left:1em;text-indent:-2em"><span class="b">&nbsp;</span><span class="m">&lt;</span><span class="t">Photo</span><span class="m">&gt;</span><span class="tx">Photo.jpg</span><span class="m">&lt;/</span><span class="t">Photo</span><span class="m">&gt;</span></div>
</div>
<div><span class="b">&nbsp;</span><span class="m">&lt;/</span><span class="t">Employee</span><span class="m">&gt;</span></div>
</div>
</div>
<div><span class="b">&nbsp;</span><span class="m">&lt;/</span><span class="t">Employees</span><span class="m">&gt;</span></div>
</div>
</div>
</BODY>
</HTML>
<h2>William Shakespeare</h2>
</p>
</center>
</body>
</html>

0 comments on commit b235b93

Please sign in to comment.