Skip to content

Commit 601e50b

Browse files
committed
Add DisableDefaultXslt option.
1 parent a5e1169 commit 601e50b

File tree

13 files changed

+330
-266
lines changed

13 files changed

+330
-266
lines changed

docs/help/options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ documents.
3535
### XSLT
3636
Options that control how the the XSLT Output works.
3737
Set `Enable Scripts` to false if you don't trust the script code in your XSLT stylesheets.
38+
Set the `Disable default XSLT` to true if you do not want a default XSLT transform
39+
on documents that have no `<?xml-stylesheet` processing instruction.
3840
Toggle the Web Browser Version to WebView2 if you have the new
3941
[WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/)
4042
component installed on your machine.

docs/help/xslt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ for information on how to install this optional component.
4141

4242
You will know it is using WebView2 if you see that name mentioned
4343
in the status bar.
44+
45+
If there is no stylesheet associated with your XML document you will
46+
see a default stylesheet that produces an HTML document containing
47+
a colorized version of your XML document. This default transform
48+
can be disabled in the Options dialog.

src/Application/FormMain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ protected virtual void SetDefaultSettings()
260260
this._settings["UpdateLocation"] = XmlNotepad.Settings.DefaultUpdateLocation;
261261
this._settings["UpdateEnabled"] = true;
262262

263+
this._settings["DisableDefaultXslt"] = false;
263264
this._settings["AutoFormatOnSave"] = true;
264265
this._settings["IndentLevel"] = 2;
265266
this._settings["IndentChar"] = IndentChar.Space;

src/Application/FormOptions.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public class UserSettings
132132
private string _updateLocation;
133133
private bool _enableUpdate;
134134
private bool _noByteOrderMark;
135+
private bool _disableDefaultXslt;
135136
private bool _autoFormatOnSave;
136137
private int _indentLevel;
137138
private IndentChar _indentChar;
@@ -165,6 +166,7 @@ public UserSettings(Settings s)
165166
LoadColors();
166167
_updateLocation = this._settings.GetString("UpdateLocation");
167168
_enableUpdate = this._settings.GetBoolean("UpdateEnabled");
169+
_disableDefaultXslt = this._settings.GetBoolean("DisableDefaultXslt");
168170
_autoFormatOnSave = this._settings.GetBoolean("AutoFormatOnSave");
169171
_noByteOrderMark = this._settings.GetBoolean("NoByteOrderMark");
170172
_indentLevel = this._settings.GetInteger("IndentLevel");
@@ -230,6 +232,7 @@ public void Apply()
230232
this._settings["UpdateEnabled"] = this._enableUpdate;
231233
this._settings["UpdateLocation"] = this._updateLocation;
232234

235+
this._settings["DisableDefaultXslt"] = _disableDefaultXslt;
233236
this._settings["AutoFormatOnSave"] = _autoFormatOnSave;
234237
this._settings["IndentLevel"] = _indentLevel;
235238
this._settings["IndentChar"] = _indentChar;
@@ -272,6 +275,7 @@ public void Reset()
272275
_updateLocation = Settings.DefaultUpdateLocation;
273276
_enableUpdate = true;
274277
_autoFormatOnSave = true;
278+
_disableDefaultXslt = false;
275279
_noByteOrderMark = false;
276280
_indentLevel = 2;
277281
_indentChar = IndentChar.Space;
@@ -524,6 +528,7 @@ public bool AutoFormatOnSave
524528
this._autoFormatOnSave = value;
525529
}
526530
}
531+
527532
[SRCategory("FormatCategory")]
528533
[LocDisplayName("IndentLevel")]
529534
[SRDescription("IndentLevelDescription")]
@@ -659,6 +664,21 @@ public bool EnableXsltScripts
659664
}
660665
}
661666

667+
[SRCategory("XsltCategory")]
668+
[LocDisplayName("DisableDefaultXslt")]
669+
[SRDescription("DisableDefaultXsltDescription")]
670+
public bool DisableDefaultXslt
671+
{
672+
get
673+
{
674+
return this._disableDefaultXslt;
675+
}
676+
set
677+
{
678+
this._disableDefaultXslt = value;
679+
}
680+
}
681+
662682
[SRCategory("XsltCategory")]
663683
[LocDisplayName("WebBrowserPropertyName")]
664684
[SRDescription("WebBrowserDescription")]

src/Updates/Updates.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<history>https://github.com/microsoft/XmlNotepad/blob/master/src/Updates/Updates.xml</history>
1010
<frequency>1.00:00:00</frequency>
1111
</application>
12+
<version number="2.8.0.49">
13+
<feature>Add option to disable default XSLT stylesheet.</feature>
14+
</version>
1215
<version number="2.8.0.48">
1316
<bug>Fix single line text editor so it does not overlap the line below it.</bug>
1417
<bug>Fix XSLT Output browse button so it brings up the Save As File Dialog.</bug>

src/Version/Version.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
// Build Number
1616
// Revision
1717
//
18-
[assembly: AssemblyVersion("2.8.0.48")]
19-
[assembly: AssemblyFileVersion("2.8.0.48")]
18+
[assembly: AssemblyVersion("2.8.0.49")]
19+
[assembly: AssemblyFileVersion("2.8.0.49")]

src/Version/Version.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<ApplicationRevision>48</ApplicationRevision>
5-
<ApplicationVersion>2.8.0.48</ApplicationVersion>
4+
<ApplicationRevision>49</ApplicationRevision>
5+
<ApplicationVersion>2.8.0.49</ApplicationVersion>
66
</PropertyGroup>
77
</Project>

src/XmlNotepad/DefaultSS.xslt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</SCRIPT>
9292
</HEAD>
9393
<BODY class="st">
94-
<div style="border:1 dashed navy; padding-left:5px;padding-right:5px;background-color:#FFFFB3">
94+
<div style="padding:5px;background-color:#fffacd">
9595
<p>
9696
Your XML document contains no xml-stylesheet processing instruction. To provide
9797
an XSLT transform, add the following to the top of your file and edit the href
@@ -100,13 +100,15 @@
100100
<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>
101101
</pre>
102102
<p>
103-
You can also enter the XSLT file name using the above text box, but this will not
103+
You can also enter the XSLT file name using the above "XSLT Location:" text box, but this will not
104104
persist with your XML document.
105105
</p>
106106
<p>
107-
The following HTML is provided by the default XSLT transform which is designed
108-
to pretty print your XML document.
107+
You can specify a default output file name using the following in your XML documents:
109108
</p>
109+
<pre style="font-size:small">
110+
<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>
111+
</pre>
110112
</div>
111113
<x:apply-templates />
112114
</BODY>

src/XmlNotepad/StringResources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)