Skip to content

Commit

Permalink
Add DisableDefaultXslt option.
Browse files Browse the repository at this point in the history
  • Loading branch information
clovett committed Nov 26, 2021
1 parent a5e1169 commit 601e50b
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 266 deletions.
2 changes: 2 additions & 0 deletions docs/help/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ documents.
### XSLT
Options that control how the the XSLT Output works.
Set `Enable Scripts` to false if you don't trust the script code in your XSLT stylesheets.
Set the `Disable default XSLT` to true if you do not want a default XSLT transform
on documents that have no `<?xml-stylesheet` processing instruction.
Toggle the Web Browser Version to WebView2 if you have the new
[WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/)
component installed on your machine.
5 changes: 5 additions & 0 deletions docs/help/xslt.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ for information on how to install this optional component.

You will know it is using WebView2 if you see that name mentioned
in the status bar.

If there is no stylesheet associated with your XML document you will
see a default stylesheet that produces an HTML document containing
a colorized version of your XML document. This default transform
can be disabled in the Options dialog.
1 change: 1 addition & 0 deletions src/Application/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ protected virtual void SetDefaultSettings()
this._settings["UpdateLocation"] = XmlNotepad.Settings.DefaultUpdateLocation;
this._settings["UpdateEnabled"] = true;

this._settings["DisableDefaultXslt"] = false;
this._settings["AutoFormatOnSave"] = true;
this._settings["IndentLevel"] = 2;
this._settings["IndentChar"] = IndentChar.Space;
Expand Down
20 changes: 20 additions & 0 deletions src/Application/FormOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public class UserSettings
private string _updateLocation;
private bool _enableUpdate;
private bool _noByteOrderMark;
private bool _disableDefaultXslt;
private bool _autoFormatOnSave;
private int _indentLevel;
private IndentChar _indentChar;
Expand Down Expand Up @@ -165,6 +166,7 @@ public UserSettings(Settings s)
LoadColors();
_updateLocation = this._settings.GetString("UpdateLocation");
_enableUpdate = this._settings.GetBoolean("UpdateEnabled");
_disableDefaultXslt = this._settings.GetBoolean("DisableDefaultXslt");
_autoFormatOnSave = this._settings.GetBoolean("AutoFormatOnSave");
_noByteOrderMark = this._settings.GetBoolean("NoByteOrderMark");
_indentLevel = this._settings.GetInteger("IndentLevel");
Expand Down Expand Up @@ -230,6 +232,7 @@ public void Apply()
this._settings["UpdateEnabled"] = this._enableUpdate;
this._settings["UpdateLocation"] = this._updateLocation;

this._settings["DisableDefaultXslt"] = _disableDefaultXslt;
this._settings["AutoFormatOnSave"] = _autoFormatOnSave;
this._settings["IndentLevel"] = _indentLevel;
this._settings["IndentChar"] = _indentChar;
Expand Down Expand Up @@ -272,6 +275,7 @@ public void Reset()
_updateLocation = Settings.DefaultUpdateLocation;
_enableUpdate = true;
_autoFormatOnSave = true;
_disableDefaultXslt = false;
_noByteOrderMark = false;
_indentLevel = 2;
_indentChar = IndentChar.Space;
Expand Down Expand Up @@ -524,6 +528,7 @@ public bool AutoFormatOnSave
this._autoFormatOnSave = value;
}
}

[SRCategory("FormatCategory")]
[LocDisplayName("IndentLevel")]
[SRDescription("IndentLevelDescription")]
Expand Down Expand Up @@ -659,6 +664,21 @@ public bool EnableXsltScripts
}
}

[SRCategory("XsltCategory")]
[LocDisplayName("DisableDefaultXslt")]
[SRDescription("DisableDefaultXsltDescription")]
public bool DisableDefaultXslt
{
get
{
return this._disableDefaultXslt;
}
set
{
this._disableDefaultXslt = value;
}
}

[SRCategory("XsltCategory")]
[LocDisplayName("WebBrowserPropertyName")]
[SRDescription("WebBrowserDescription")]
Expand Down
3 changes: 3 additions & 0 deletions src/Updates/Updates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<history>https://github.com/microsoft/XmlNotepad/blob/master/src/Updates/Updates.xml</history>
<frequency>1.00:00:00</frequency>
</application>
<version number="2.8.0.49">
<feature>Add option to disable default XSLT stylesheet.</feature>
</version>
<version number="2.8.0.48">
<bug>Fix single line text editor so it does not overlap the line below it.</bug>
<bug>Fix XSLT Output browse button so it brings up the Save As File Dialog.</bug>
Expand Down
4 changes: 2 additions & 2 deletions src/Version/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.8.0.48")]
[assembly: AssemblyFileVersion("2.8.0.48")]
[assembly: AssemblyVersion("2.8.0.49")]
[assembly: AssemblyFileVersion("2.8.0.49")]
4 changes: 2 additions & 2 deletions src/Version/Version.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>48</ApplicationRevision>
<ApplicationVersion>2.8.0.48</ApplicationVersion>
<ApplicationRevision>49</ApplicationRevision>
<ApplicationVersion>2.8.0.49</ApplicationVersion>
</PropertyGroup>
</Project>
10 changes: 6 additions & 4 deletions src/XmlNotepad/DefaultSS.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</SCRIPT>
</HEAD>
<BODY class="st">
<div style="border:1 dashed navy; padding-left:5px;padding-right:5px;background-color:#FFFFB3">
<div style="padding:5px;background-color:#fffacd">
<p>
Your XML document contains no xml-stylesheet processing instruction. To provide
an XSLT transform, add the following to the top of your file and edit the href
Expand All @@ -100,13 +100,15 @@
<span class="d">&lt;?</span><span class="t">xml-stylesheet</span>&#160;<span class="at">type</span><span class="d">=</span>"<span class="av">text/xsl</span>" <span class="at">href</span><span class="d">=</span>"<span class="av">stylesheet.xsl</span>"<span class="d">?&gt;</span>
</pre>
<p>
You can also enter the XSLT file name using the above text box, but this will not
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>
<p>
The following HTML is provided by the default XSLT transform which is designed
to pretty print your XML document.
You can specify a default output file name using the following in your XML documents:
</p>
<pre style="font-size:small">
<span class="d">&lt;?</span><span class="t">xsl-output</span>&#160;<span class="at">default</span><span class="d">=</span>"<span class="av">xslt_output</span>" <span class="d">?&gt;</span>
</pre>
</div>
<x:apply-templates />
</BODY>
Expand Down
18 changes: 18 additions & 0 deletions src/XmlNotepad/StringResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 601e50b

Please sign in to comment.