XML and HTML

Features for XML and HTML are described below. See also XML/HTML Formatting.

XML

XML features in SlickEdit® Core include Context Tagging®, validation, well-formedness checking, a beautifier, Color Coding, URL Mapping, Syntax Expansion, and Syntax Indenting for XML, XSLT, and schemas (DTD or XSD).

XML Validation

If the XML file being edited references a DTD or schema, SlickEdit Core will attempt to access it. This is used for validating the XML file and for color coding. You can customize this capability in the following ways:

  • If the location of the DTD or schema is not accessible, you can map a local directory to that URL. From the main menu, select Window → SlickEdit Preferences → Network & Internet Options → URL Mappings. Then add the URL for this DTD/schema and specify a directory where that file can be found.

  • If you don't want to validate the document when it is opened, select Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Formatting and uncheck Auto validate on open.

  • Even if you turn off auto-validation, the DTD/schema will be loaded for color coding. To prevent it from being loaded, you can add the extension of the file specifying the DTD/schema to the def_xml_no_schema_list variable. For more information, see Setting/Changing Configuration Variables.

Tip

If you don't want to suppress the loading of DTDs or schema files for all files of a particular extension, you can define an empty DTD or schema and put it in a directory, then map the URL for that file to the directory as described above.

You can manually check the validity of an XML document using the xml_validate command. You can manually check if the document is well-formed using the xml_wellformedness command.

XML Formatting Options

Content in XML and HTML files may be set to automatically wrap and format as you edit, through the XML/HTML Formatting feature. See XML/HTML Formatting for complete information.

Other miscellaneous tag and attribute options are provided through the XML Formatting Options screen. To access these options, from the main menu, click Window → SlickEdit Preferences → Languages, expand XML/Text Languages > XML, then click XML Formatting Options.

Tip

You can also display the XML Formatting Options screen by clicking the XML Options button on the XML/HTML Formatting Scheme Configuration dialog (see Working with Schemes).

The following settings are available:

  • Auto validate on open - When this option is selected, XML files are automatically validated when they are opened. The result of the validation is displayed on the Output view.

  • Auto symbol translation - When selected, Auto Symbol Translation is enabled, a feature that automatically converts a character or sequence of characters to the appropriate entity reference. Click the Settings button to display the Symbol Translation Editor. See Auto Symbol Translation for more information.

  • Auto formatting options - These settings are used to configure XML/HTML Formatting.

    • Default formatting scheme - Specifies the default formatting scheme to use for the selected language. See Default Schemes for more information.

    • Enable content wrapping - When selected, content wrapping is enabled, based on the scheme configuration for the selected formatting scheme. See Working with Schemes for more information.

    • Enable tag layout - When selected, tag layout is enabled, based on the scheme configuration for the selected formatting scheme.

    • Configure Schemes - Use this button to open to the XML/HTML Formatting Schemes Configuration dialog to configure tags. See Working with Schemes.

XMLdoc Editor

Use the XMLdoc Editor to generate Microsoft XML syntax comments for C#, C, C++, Java, JavaScript, and Slick-C®. Note that by default, when creating a new comment, the Javadoc Editor is displayed for all file types except C#. To work around this limitation, start an XML comment with "///" and then right-click in the edit window and select Edit XML Comments.

Unknown XML tags are left "as is" and not removed.

XML Beautifier

To beautify XML source code, from the main menu click Format → Beautify (or use the gui_beautify command). The XML Beautifier dialog appears, where you can specify preferences for how the code is beautified.

Caution

The XML Beautifier is not affected by XML/HTML Formatting. If you run the beautifier on documents that have been automatically formatted through XML/HTML Formatting, you may find unexpected results.

You can use the commands xml_beautify or xml_beautify_selection to instantly beautify the file or the selection according to the settings on the Beautifier dialog.

Note

The XSD Beautifier contains the same options and settings as the XML Beautifier.

The following buttons and options are available on the Beautifier:

  • Beautify - Beautifies current selection or buffer and closes the dialog box.

  • Reset - Restores the dialog box settings to the values that appeared when you invoked the dialog.

  • Save Settings - Saves beautify options in uformat.ini file. These settings are used by the xml_beautify command.

  • Restrict to selection - When on, only lines in the selection are beautified.

  • Sync extension options - When on, the language options are updated to reflect any changes that these dialogs have in common.

The tabs on the XML Beautifier are described in the sections below.

Indent Tab

The Indent tab on the XML Beautifier is pictured below.

The following settings are available:

  • Indent for each level (Syntax indent) - The amount to indent for each new nesting level of tags. We have put the words "Syntax indent" in parenthesis to help indicate that this field has the same value as the Syntax indent text box setting on the language-specific Indent options screen (see Language-Specific Indent Options). By default, we initialize this text box with your current language setup setting.

  • Indent with tabs - When on, tab characters are used for leading indent of lines. This value defaults to the Tabs text box setting on the language-specific Indent options screen (see Language-Specific Indent Options).

  • Tab size - Specifies output tab size. The output tab size is only used if the Indent with tabs check box is on. This value defaults to the Syntax indent text box on the language-specific Indent options screen (see Language-Specific Indent Options).

  • Original tab size - Specifies what the original file's tab expansion size was. We need to know the tab expansion size of your original file to handle reusing indent amounts from your original file. Currently the beautifier only reuses the original source file's indenting for comments. This option has no effect if the original file has no tab characters.

  • Max line length - Specifies the maximum length a line can be before it is wrapped to a new line. This max line length is relative to the current indent level. For example, if you were inside an XHTML <td> block which was at an indent level of 30, and your max line length was set to 80, then that line would not be wrapped until it reached a total length of 30+80=110 characters. Set this value to 0 if you want your line breaks preserved.

  • Broken tag lines - Specify how broken tag lines are treated from the following options:

    • Indent from tag column by - Specifies the amount to indent for broken tag lines from the starting column of the tag. Specify 0 to align broken tag lines with the starting column of the tag.

    • Use original relative indent - Reindent broken tag lines using the original relative indent amount from the starting column of the tag.

    • Preserve original indent - Preserve the original absolute indent amount on broken tag lines.

Tags Tab

The Tags tab on the XML Beautifier is pictured below.

The Tags tab contains the following options and settings:

  • Tag case - Specifies how you want your tag names cased. For example, if you choose UPPER, then <tag> would be beautified to <TAG>. Under normal circumstances you will want to preserve the case of your XML tags, but for certain special cases (e.g. XHTML) you may want to change this setting.

  • Tag settings - The settings in this group box apply to the tag that is selected in the list box. The <DEFAULT TAG> tag item in the list of tags specifies settings to use when no settings exist for a tag found during beautification.

    • Add - Display the Add Tag dialog. This dialog allows you to add a tag definition to the list and specify how it will be beautified.

    • Remove - Used to remove the currently selected tag.

  • Content - Specify how to beautify content from the following options:

    • Reformat - When off, all white space and line breaks are preserved. However, tags are formatted (tag case, attribute case, etc.).

    • Indent - When on, nested tags will be indented one syntax indent level. Furthermore, if Reformat is on, the selected tag's CDATA content (i.e. plain text), bounded by the opening and closing tag, will be indented one syntax indent level.

    • Literal - When on, all white space and line breaks are preserved. In addition, tags within the content are treated as literal text. If Reformat is on, then leading indent is adjusted. This option is useful for XHTML.

    Tip

    Some examples of content settings for specific tags are:

    • style - Literal (content is indented to the same level as the <style> open tag)

    • style - Reformat, Literal (content is indented one syntax indent level from the <style> open tag)

    • pre - All Content check boxes off

    • blockquote - Reformat, Indent

  • End tag - When on, the selected tag has an end tag. For XML you will normally want this to remain on.

  • End tag required - When on, the selected tag's ending tag is required. For XML you will normally want this to remain on.

  • Preserve tag body - When on, all properties of the body of the tag selected will be preserved. This is especially useful for processing instructions like <?xml ... ?> where you do not want the embedded text to be beautified.

  • Preserve tag position - When on, the position of the tag within the document is preserved. This is especially useful with JSP/ASP tags where reindenting the tag would interrupt the flow of the script code.

  • Line breaks - Select the way lines are broken:

    • Before open tag - Specify the number of line breaks before the opening tag. For example, if you were to set the number of line breaks before the opening tag to 3 for the XHTML <td> tag, and the original content was:

      <tr>
      <td>
      </td>
      </tr>

      The resulting content would be:

      <tr>
                
                
      <td>
      </td>
      </tr>

      Please note that the number of line breaks is not the same as the number of blank lines. If you wanted three blank lines, then you would set the number of line breaks to 4.

    • After close tag - Specify the number of line breaks after the closing tag. For example, if you were to set the number of line breaks after the closing tag to 3 for the XHTML <td> tag, and the original content was:

      <TR>
      <TD>
      </TD>
      </TR>

      The resulting content would be:

      <TR>
      <TD>
      </TD>
      
      
      </TR>

      Please note that the number of line breaks is not the same as the number of blank lines. If you wanted three blank lines, then you would set the number of line breaks to 4.

    • Stand-alone - When on, the selected tag will always have at least one preceding and trailing line break on both its opening and ending tag when beautified. You can specify that there be more than one line break by setting Line breaks for the opening and closing tags.

Attributes/Values Tab

The Attributes/Values tab of the XML Beautifier is pictured below.

The Attributes/Values tab contains the following settings:

  • Attribute case - Specifies how you want attributes cased inside the body of a tag. For example, if you choose UPPER, then <td align="right"> would be beautified to <td ALIGN="right">. Under normal circumstances you will want to preserve the case of your XML attributes, but for certain special cases (e.g. XHTML) you may want to change this setting.

  • Word value case - Not available for XML.

  • Hex value case - Not available for XML.

  • Quote word values - Specifies whether you want word values enclosed in double quotes after the = of an attribute inside the body of a tag. For example, <td align=right> would be beautified to <td align="right">. Select Preserve if you want word values left alone. Under normal circumstances you will want to preserve your XML values, but for certain special cases (e.g. XHTML) you may want to change this setting.

  • Quote number values - Specifies whether you want number values enclosed in double quotes after the = of an attribute inside the body of a tag. For example, <td width=590> would be beautified to <td width="590">. Select Preserve if you want number values left alone. Under normal circumstances you will want to preserve your XML values, but for certain special cases (e.g. XHTML) you may want to change this setting.

  • Quote all values - When on, all values will be quoted after the = of an attribute inside the body of a tag. For example, <td align=right> would be beautified to <td align="right">.Under normal circumstances you will want to preserve your XML values, but for certain special cases (e.g. XHTML) you may want to change this setting.

Comments Tab

The Comments tab of the XML Beautifier is pictured below.

The Comments tab contains the following options and settings:

  • Indent stand alone comments - When on, indicates whether comments which appear on lines by themselves with no content to the left are indented to the current content indent level. The following is an example of a stand-alone comment:

    <!-- stand alone
         comment
    -->
  • Indent column 1 comments - Normally comments that start in column 1 are left alone. Turn this on if you want the indent for these comments to be adjusted as well.

  • Define Comments - Displays the XML Comments dialog. This dialog allows you to define what the beautifier recognizes as a comment. The sequence <!-- --> is defined as the XML comment by default. If you delete all comment definitions then all comments will be parsed as content.

  • Trailing comments - Specify how trailing comments are treated from the following options:

    • Specific column - This text box specifies the column that "trailing comments" should be placed at. By trailing comments, we mean comments which appear at the end of lines which contain tags. An example of a trailing comment is:

      <TD>   <!-- trailing comment -->
    • Original absolute column - When on, "trailing comments" are placed at the same column as the original source file. By trailing comments, we mean comments which appear at the end of lines which contain tags.

    • Original relative column - When on, "trailing comments" are indented by reusing the indent after the last character of the end of the statement or declaration of the original source file. By trailing comments, we mean comments which appear at the end of lines which contain tags.

    The following is an example of code before beautifying trailing comments:

    <Outer>
    <Inner><four characters><!-- trailing comment -->
    </Inner>
    </Outer>

    The resulting code would be:

    <Outer>
      <Inner><four characters><!-- trailing comment -->
      </Inner>
    </Outer>
Advanced Tab

The Advanced tab of the XML Beautifier is pictured below.

The following option is available on the Advanced tab:

  • Remove blank lines - When on, blank lines are deleted.

Schemes Tab

The Schemes tab of the XML Beautifier is pictured below.

To define a new scheme, use the Beautifier to set the various beautify options and then press the Save Scheme button on the Schemes tab. User defined schemes are stored in uformat.ini.

DTD Caching

When you open an XML document that has a document type definition of (!DOCTYPE) that refers to a remote external DTD, the DTD file is downloaded and cached locally. The DTD is processed to provide Context Tagging® and better color coding. Currently, only HTTP (and not FTP) remote files are supported. This automatic caching allows you to work offline and edit XML documents that reference remote DTDs when you do not have an Internet connection. If you want to force re-caching of the DTD for the current XML document, right-click to open the context menu and select Apply DTD changes. Applying DTD changes is necessary after you create a new XML document and complete the document type definition (!DOCTYPE).

Opening DTD Files from XML

To open the external DTD referenced by document type definition (!DOCTYPE), place the cursor anywhere on the !DOCTYPE tag and press Alt+1 (or right-click to display the context menu and select Go to Error/Include File).

URL Mapping

SlickEdit® Core provides a way to map URLs to different locations. Whenever opening a URL, the URL map is examined to see if this URL is mapped to a different location. If the URL is mapped elsewhere, then that mapped location is used.

This feature allows you to work offline or from a test location. For example, if you need to work with XML documents that contain external DTDs while offline you can map the URL to the DTD to a local file. Similarly, if you wanted to test changes to a DTD without modifying every XML document's DTD references, you can map the URL to the test DTD location.

Optionally, you can specify a default lookup directory that contains all of your DTDs and namespace schemas files. Every mapping doesn't need to be explicitly configured. You can also create mappings for namespace URIs as well as DTD files.

To map a URL, complete the following steps.

  1. From the main menu, click Window → SlickEdit Preferences → Network & Internet Options → URL Mappings.

  2. Click the Add button, and a new line opens.

  3. In the From field, type in the URL that will be mapped to a different location.

  4. Press Tab or click in the To field and type in the location to use for this URL.

  5. Optionally, use the Search directory field to specify the default lookup directory for DTDs and namespaces. Files in this directory are searched prior to validation.

  6. Click OK to save the changes and close the Options dialog.

Toggling Between Begin and End XML Tags

Place the cursor anywhere on the begin or end tag and press Ctrl+]to find the corresponding end or begin tag respectively.

HTML

This section describes some of the features and options that are available for HTML, including language-specific options, the HTML Beautifier, and more.

HTML support includes Context Tagging®, a beautifier, Color Coding, Syntax Expansion, and Syntax Indenting for HTML, JSP, and ASP. Many of the language features in SlickEdit® Core are supported for languages embedded in HTML, including Context Tagging, Color Coding, SmartPaste®, Syntax Expansion, and Syntax Indenting.

Tip

When working with HTML files, you can toggle between the begin and end HTML tags by pressing Ctrl+].

Exporting to HTML

To save the current open buffer as HTML file with formatting and color coding, from the main menu, click File → Export to HTML (or use the export_html command).

Configuring the Web Browser

To specify the Web browser that is used for previewing, from the main menu click Window → SlickEdit Preferences → Network & Internet Options → Web Browser Setup. See Web Browser Setup Options for more information.

HTML Formatting Options

Content in XML and HTML files may be set to automatically wrap and format as you edit, through the XML/HTML Formatting feature. See XML/HTML Formatting for complete information.

Other miscellaneous tag and attribute options are provided through the HTML Formatting Options screen. To access these options, from the main menu, click Window → SlickEdit Preferences → Languages, expand Web Authoring Languages > HTML, then click HTML Formatting Options.

Tip

You can also display the HTML Formatting Options screen by clicking the HTML Options button on the XML/HTML Formatting Scheme Configuration dialog (see Working with Schemes).

Note

Languages similar to HTML have similar Formatting Options screens that are not specifically documented.

The following settings are available:

  • Case for inserted tags - This option is where you specify if you want the tag names to be lowercase or uppercase. For example, if you select Uppercase, then <td> becomes <TD>. The hyperlink indicates if Adaptive Formatting is on or off for this setting.

  • Case for inserted attributes - This option is where you specify if you want attributes to be lowercase or uppercase inside the body of a tag. For example, if you select Uppercase, then <td align=right> would become <td ALIGN=right>. The hyperlink indicates if Adaptive Formatting is on or off for this setting.

  • Case for inserted single word values - This option is where you specify if you want word values to be uppercase or lowercase when the = of an attribute is inside the body of a tag. For example, if you select Uppercase, then <td align=right> becomes <td align=RIGHT>. The hyperlink indicates if Adaptive Formatting is on or off for this setting.

  • Case for hex values - This option is where you specify if you want hex values to be uppercase or lowercase after the = of an attribute inside the body of a tag. For example, if you select Uppercase, then <body bgcolor=#ffffff> would become <body bgcolor=#FFFFFF>. The hyperlink indicates if Adaptive Formatting is on or off for this setting.

  • Embedded ASP dialect - The language that you select here determines the default embedded language mode for ASP files.

  • Use path for file entries - This option is used by the HTML toolbar. When this attribute is selected, path information is included when inserting file names into the value of an attribute. For example, creating a link with this option turned on might result in the following example.

    <A HREF=file://c:/dev/html/index.htm#>sample link</A>

    When this option is not selected, the result is the following example.

    <A HREF= index.htm#>sample link</A>
  • Use lower case file names when inserting links - This option is used by the HTML toolbar. When this option is selected, the lowercase file names are used when inserting links into the value of an attribute. See the example for Use paths for file entries.

  • Use quotes for numerical values - When this option is selected, word values are enclosed in double quotes after the = of an attribute inside the body of a tag.

  • Use quotes for single word values - When this option is selected, number values are enclosed in double quotes after the = of an attribute inside the body of a tag.

  • Insert colors using color names (if possible) - When this option is selected, colors are inserted by using the color names if possible. For example, instead of using #ff0000 to represent the color red, the color name red is used.

    <BODY bgcolor=#ff0000>
    <!-- and -->
    <BODY bgcolor=red>
    <!-- are identical -->
  • Use <DIV> tags for alignment - This option is used by the HTML toolbar. When this option is selected, the <DIV> tag is used for aligning text. For example, rather than using a <CENTER> tag to designate alignment, use the following tagging:

    <DIV ALIGN=CENTER>
    </DIV>
  • Automatically insert '>' when typing '<' - When this option is selected, you can type the open brace of a start tag (<), and SlickEdit Core automatically inserts the closing brace (>) while leaving the cursor positioned between the braces, ready for you to type the tag.

  • Auto symbol translation - When selected, Auto Symbol Translation is enabled, a feature that automatically converts a character or sequence of characters to the appropriate entity reference. Click the Settings button to display the Symbol Translation Editor. See Auto Symbol Translation for more information.

  • Auto formatting options - These settings are used to configure XML/HTML Formatting.

    • Default formatting scheme - Specifies the default formatting scheme to use for the selected language. See Default Schemes for more information.

    • Enable content wrapping - When selected, content wrapping is enabled, based on the scheme configuration for the selected formatting scheme. See Working with Schemes for more information.

    • Enable tag layout - When selected, tag layout is enabled, based on the scheme configuration for the selected formatting scheme.

    • Configure Schemes - Use this button to open to the XML/HTML Formatting Schemes Configuration dialog to configure tags. See Working with Schemes.

HTML Beautifier

To beautify an HTML document, open the document you want to beautify, then from the main menu, click Format → Beautify (or use the gui_beautify command). The HTML Beautifier dialog will be displayed, which allows you to make settings for how the code will be beautified.

Caution

The HTML Beautifier is not affected by XML/HTML Formatting. If you run the beautifier on documents that have been automatically formatted through XML/HTML Formatting, you may find unexpected results.

You can use the commands h_beautify or h_beautify_selection to instantly beautify the file or the selection according to the settings on the Beautifier dialog.

Note

The CFML Beautifier contains the same options and settings as the HTML Beautifier.

The following buttons and options are available on the Beautifier:

  • Beautify - Beautifies current selection or buffer and closes the dialog box.

  • Reset - Restores the dialog box settings to the values that appeared when you invoked the dialog.

  • Save Settings - Saves beautify options in uformat.ini file. These settings are used by the h_beautify command.

  • Restrict to selection - When on, only lines in the selection are beautified.

  • Sync extension options - When on, the language options are updated to reflect any changes that these dialogs have in common.

The tabs on the HTML Beautifier are described in the sections below.

Indent Tab

The Indent tab on the HTML Beautifier is pictured below.

The following settings are available:

  • Indent for each level (Syntax indent) - The amount to indent for each new nesting level. We have put the words "Syntax indent" in parenthesis to help indicate that this field has the same value as the Syntax indent text box on the language-specific Indent options screen (see Language-Specific Indent Options). By default, we initialize this text box with your current extension setup setting.

  • Indent with tabs - When on, tab characters are used for leading indent of lines. This value defaults to the Tabs text box on the language-specific Indent options screen (see Language-Specific Indent Options).

  • Tab size - Specifies output tab size. The output tab size is only used if Indent with tabs check box is on. This value defaults to the Syntax indent text box on the language-specific Indent options screen (see Language-Specific Indent Options).

  • Original tab size - Specifies what the original file's tab expansion size was. We need to know the tab expansion size of your original file to handle reusing indent amounts from your original file. Currently the beautifier only reuses the original source file's indenting for comments. This option has no effect if the original file has no tab characters.

  • Max line length - Specifies the maximum length a line can be before it is wrapped to a new line. This max line length is relative to the current indent level. For example, if you were inside a <TD> block which was at an indent level of 30, and your max line length was set to 80, then that line would not be wrapped until it reached a total length of 30+80=110 characters. Set this value to 0 if you want your line breaks preserved.

  • Broken tag lines - Specify how broken tag lines are treated from the following options:

    • Indent from tag column by - Specifies the amount to indent for broken tag lines from the starting column of the tag. Specify 0 to align broken tag lines with the starting column of the tag.

    • Use original relative indent - Reindent broken tag lines using the original relative indent amount from the starting column of the tag.

    • Preserve original indent - Preserve the original absolute indent amount on broken tag lines.

Tags Tab

The Tags tab on the HTML Beautifier is pictured below.

The Tags tab contains the following options and settings:

  • Tag case - Specifies how you want your tag names cased. For example, if you choose UPPER, then <td> would be beautified to <TD>.

  • Tag settings - The settings in this group box apply to the tag that is selected in the list box. The <DEFAULT TAG> tag item in the list of tags specifies settings to use when no settings exist for a tag found during beautification.

  • Add - Display the Add Tag dialog. This dialog allows you to add a tag definition to the list and specify how it will be beautified.

  • Remove - Used to remove the currently selected tag.

  • Content - Specify how to beautify content from the following options:

    • Reformat - When off, all white space and line breaks are preserved. However, tags are formatted (tag case, attribute case, etc.).

    • Indent - When on, the selected tag's content, bounded by the opening and closing tag, will be indented one syntax indent level.

    • Literal - When on, all white space and line breaks are preserved. In addition, tags within the content are treated as literal text. If Reformat is on, then leading indent is adjusted.

    Tip

    Some examples of content settings for specific tags are:

    • XMP - Literal

    • PRE - All Content check boxes off

    • BLOCKQUOTE - Reformat, Indent

    • STYLE - Reformat, Literal

  • End tag - When on, the selected tag has an end tag. For example, the tag <TD> has an ending tag that is </TD>, so End tag would be checked in this case.

  • End tag required - When on, the selected tag's ending tag is required. This means that the ending tag is not optional. An example of a tag whose ending tag could be optional is <P>.

  • Preserve tag body - When on, all properties of the body of the tag selected will be preserved. This is especially useful for JSP/ASP tags where you do not want the embedded Java or VBScript inside the <% ... %> to be beautified.

  • Preserve tag position - When on, the position of the tag within the document is preserved. This is especially useful with JSP/ASP tags where reindenting the tag would interrupt the flow of the script code.

  • Line breaks - Select the way lines are broken:

    • Before open tag - Specify the number of line breaks before the opening tag. For example, if you were to set the number of line breaks before the opening tag to 3 for the <TD> tag, and the original content was:

      <TR>
      <TD>
      </TD>
      </TR>

      The resulting content would be:

      <TR>
                  
                  
      <TD>
      </TD>
      </TR>

      Please note that the number of line breaks is not the same as the number of blank lines. If you wanted three blank lines, then you would set the number of line breaks to 4.

    • After close tag - Specify the number of line breaks after the closing tag. For example, if you were to set the number of line breaks after the closing tag to 3 for the <TD> tag, and the original content was:

      <TR>
      <TD>
      </TD>
      </TR>

      The resulting content would be:

      <TR>
      <TD>
      </TD>
      
      
      </TR>

      Please note that the number of line breaks is not the same as the number of blank lines. If you wanted three blank lines, then you would set the number of line breaks to 4.

    • Stand-alone - When on, the selected tag will always have at least one preceding and trailing line break on both its opening and ending tag when beautified. You can specify that there be more than one line break by setting Line breaks for the opening and closing tags.

Attributes/Values Tab

The Attributes/Values tab of the HTML Beautifier is pictured below.

The Attributes/Values tab contains the following settings:

  • Attribute case - Specifies how you want attributes cased inside the body of a tag. For example, if you choose UPPER, then <td align="right"> would be beautified to <td ALIGN="right">.

  • Word value case - Specifies how you want word values cased after the = of an attribute inside the body of a tag. For example, if you choose UPPER, then <td align="right"> would be beautified to <td align=RIGHT>.

  • Hex value case - Specifies how you want hex values cased after the = of an attribute inside the body of a tag. For example, if you choose UPPER, then <body bgcolor="#ffffff"> would be beautified to <body bgcolor="#FFFFFF">.

  • Quote word values - Specifies whether you want word values enclosed in double quotes after the = of an attribute inside the body of a tag. For example, <td align=right> would be beautified to <td align="right">. Select Preserve if you want word values left alone.

  • Quote number values - Specifies whether you want number values enclosed in double quotes after the = of an attribute inside the body of a tag. For example, <td width=590> would be beautified to <td width="590">. Select Preserve if you want number values left alone.

  • Quote all values - When on, all values will be quoted after the = of an attribute inside the body of a tag. For example, <td align=right> would be beautified to <td align="right">.

Comments Tab

The Comments tab of the HTML Beautifier is pictured below.

The Comments tab contains the following options and settings:

  • Indent stand alone comments - When on, indicates whether comments which appear on lines by themselves with no content to the left are indented to the current content indent level. The following is an example of a stand-alone comment:

    <!-- stand alone
         comment
    -->
  • Indent column 1 comments - Normally comments that start in column 1 are left alone. Turn this on if you want the indent for these comments to be adjusted as well.

  • Define Comments - Displays the HTML Comments dialog. This dialog allows you to define what the beautifier recognizes as a comment. The sequence <!-- --> is defined as the HTML comment by default. If you delete all comment definitions then all comments will be parsed as content and possibly word-wrapped.

  • Trailing comments - Specify how trailing comments are treated from the following options:

    • Specific column - This text box specifies the column that "trailing comments" should be placed at. By trailing comments, we mean comments which appear at the end of lines which contain tags. An example of a trailing comment is:

      <TD>   <!-- trailing comment -->
    • Original absolute column - When on, "trailing comments" are placed at the same column as the original source file. By trailing comments, we mean comments which appear at the end of lines which contain tags.

    • Original relative column - When on, "trailing comments" are indented by reusing the indent after the last character of the end of the statement or declaration of the original source file. By trailing comments, we mean comments which appear at the end of lines which contain tags.

    The following is an example of code before beautifying trailing comments:

    <TR>
    <TD><four characters><!-- trailing comment -->
    </TD>
    </TR>

    The resulting code would be:

    <TR>
      <TD><four characters><!-- trailing comment -->
      </TD>
    </TR>
Advanced Tab

The Advanced tab of the HTML Beautifier is pictured below.

The following options are available on the Advanced tab:

  • End previous <P> tag when - Select from the following options:

    • Hitting another <P> tag - When on, the beautifier will interpret a <P> tag as a signal of the end of any previous paragraphs.

    • Hitting a standalone tag - When on, the beautifier will interpret a standalone tag as a signal of the end of any previous paragraphs. For example, in the following content, the <TABLE> tag (assuming that the <TABLE> tag is a standalone tag) signals the end of the previous <P> paragraph. This has the benefit of cleaning up unwanted (and unexpected) indenting. For example:

      <P>
      This is a paragraph of content.  The paragraph will be ended by the
      start of the table below it.
      
      <TABLE>
        <TR>
          <TD>a table cell</TD>
        </TR>
      </TABLE>
  • Remove blank lines - When on, blank lines are deleted.

  • Beautify JavaScript - When on, embedded JavaScript is beautified according to your JavaScript beautifier settings.

  • Edit JavaScript Settings - Click on this button to configure the JavaScript Beautifier settings. The JavaScript Beautifier is the same as the C/C++ Beautifier - see C/C++ Beautifier for more information.

Schemes Tab

To define a new scheme, set the various beautify options and press the Save Scheme button. User defined schemes are stored in uformat.ini.

Auto Symbol Translation

Auto Symbol Translation automatically converts a character or sequence of characters to the appropriate entity reference, saving you from having to repeatedly guess at the correct entity or look up reference charts. This feature works automatically as you type, so you don't need to press a special key or key sequence to trigger the translation. For example, type >>, and SlickEdit® Core automatically converts the >> sequence to >, which is the entity reference for the right angle bracket (>). Typing && translates to &, the entity reference for the ampersand symbol (&).

Auto Symbol Translation uses the Alias mechanism in SlickEdit Core'the character or character sequence that you type to trigger translation is actually a special kind of alias, henceforth called a "symbol alias". SlickEdit Core comes with some predefined symbol aliases. You can view these, customize them, and create your own by using the Symbol Translation Editor dialog. The first time Auto Symbol Translation is triggered, a prompt appears that describes the feature and lets you open the Symbol Translation Editor.

Enabling/Disabling Auto Symbol Translation

Auto Symbol Translation is enabled by default. The first time you type a symbol alias and automatic translation occurs, a prompt is displayed that explains the feature and provides a button to access the Symbol Translation Editor. You can also choose to prevent the prompt from appearing again in the future.

To turn off Auto Symbol Translation, from the main menu, click Window → SlickEdit Preferences. Expand Languages and your language category, then select your language and click [Language] Formatting Options. Clear the Auto symbol translation option.

Configuring Symbol Aliases

The Symbol Translation Editor dialog is used to configure symbol aliases. It can be displayed by clicking Yes on the prompt that appears the first time a symbol translation occurs, or by clicking the Settings button on the Formatting Options screen for your language (Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Formatting).

The box on the left shows a list of symbol aliases. The edit window on the right contains the translation for the selected alias. Click New to enter a new symbol alias, or click Delete to remove a selected alias. Working with symbol aliases is the same as working with language-specific aliases. You can even use escape sequences and Parameter Prompting for some interesting translation results. See Creating a Language-Specific Alias for more information.

XML/HTML Formatting

Content in XML and HTML files may be set to automatically wrap and format as you edit. XML/HTML Formatting is essentially comprised of two features: Content Wrap, which wraps the content between tags, and Tag Layout, which formats tags according to a specified layout. Both can be activated individually for all XML and HTML files that are opened in SlickEdit® Core, or just for the current document.

Formatting schemes form the basis for how tags and content are formatted. A formatting scheme contains any number of XML or HTML tags, each of which can be configured individually for indent levels, wrapping, and tag structure. Multiple schemes can be defined®for example, you may want one scheme for HTML files and another for XML files, or perhaps you are required to code certain files to various standards. Schemes can be saved and imported, so they can be shared with your team. Tags for each scheme can be entered manually or you can import tags from the current file.

Caution

XML/HTML Formatting does not currently affect XML or HTML Beautifier settings. If you run the beautifier on documents that have been automatically formatted through XML/HTML Formatting, you may find unexpected results.

Enabling/Disabling XML/HTML Formatting

XML/HTML Formatting is on by default for XML and HTML files that you open in SlickEdit® Core. You can activate and/or deactivate Tag Layout and/or Content Wrap for either file type on a global basis or on a per document basis. Options to turn these features on/off are located on the Format → XML/HTML Formatting menu.

Enabling/Disabling Globally

Automatic formatting can be enabled or disabled for every XML and/or HTML file that is created or opened in SlickEdit® Core. These XML- and HTML-specific global options are toggled on/off by placing a check next to Enable XML Formatting and/or Enable HTML Formatting. To toggle Tag Layout and/or Content Wrap on or off for either file type, check or uncheck those items. For example, if you want both Tag Layout and Content Wrap enabled for XML files, but you only want Content Wrap enabled for HTML files, place a check next to Enable XML Formatting and its sub-menu items Tag Layout and Content Wrap, then place a check next to Enable HTML Formatting and its sub-menu item Content Wrap.

The xml_formatting_toggle and html_formatting_toggle commands can also be used to toggle all respective formatting features on/off. For use in macros, two more commands are available: xml_formatting and html_formatting. When you use any of these commands, the command line prompts for yes (Y) or no (N). When these commands are used to enable/disable XML/HTML Formatting, both Tag Layout and Content Wrap are enabled/disabled for both XML and HTML files on a global basis.

You can also turn automatic formatting on and off through the language-specific Formatting Options screen: from the main menu, click Window → SlickEdit Preferences, expand Languages and your language category, then select your language and click [Language] Formatting Options. In the Auto formatting options group box, select the default formatting scheme you want to use for this language, then enable/disable the content wrapping or tag layout options. Click the Configure Schemes button to open the XML/HTML Formatting Scheme Configuration dialog (see Working with Schemes).

Enabling/Disabling for the Current Document

Current document options are available so that you can turn off aspects of global formatting for just the current document. For example, if you have both aspects of HTML formatting enabled globally, but you need to edit an old HTML file and do not want automatic tag layout to occur, you can disable HTML Tag Layout for that specific file. The current document settings are remembered each time you open that file.

To change XML or HTML formatting for just the current document, click Format → XML/HTML Formatting → Current Document Options, or use the xml_html_document_options command. The Current Document Options dialog is displayed.

Select the Formatting scheme that you want applied, then check or uncheck the Auto formatting options that you want enabled or disabled. Click Configure Schemes if you want to modify or create a new scheme to apply to the current document.

Global formatting must be enabled for the current file type in order for these options to be available. For example, see the two screen shots shown previously. The menu screen shot shows that global HTML formatting is enabled for Content Wrap only. This means that tag content for every HTML file that you create or open in SlickEdit® Core will be wrapped, but no Tag Layout settings will be applied. The second screen shot (the Current Document Options dialog) reflects that the global setting for Tag Layout is disabled. Therefore it cannot be enabled for the current document. To enable it for the current document, you would first need to enable the global setting by placing a check next to Format → XML/HTML Formatting → Enable HTML Formatting → Tag Layout. Then you can use the Current Document Options dialog to enable it for the current document.

Working with Schemes

A formatting scheme is comprised of any number of individually configurable XML or HTML tags and controls the formatting of your text when XML/HTML Formatting is enabled. You can create different schemes for use with either XML or HTML, and/or different schemes for use with different individual files. For example, you may want one scheme for HTML and a different scheme for XML. Or, you may want one scheme for creating new files and another for editing existing files.

Schemes are stored as XML files in the format SchemeName.xml, and are located in the formatschemes/xwschemes subdirectory of your user configuration directory. Scheme files can be shared or checked into version control to ensure consistency in the formatting of your team's XML/HTML files.

Use the XML/HTML Formatting Scheme Configuration dialog to work with schemes. To access this dialog, from the main menu, click Format → XML/HTML Formatting → Current Document Options, then click the Configure Schemes button on the Current Document Options dialog. You can also display the dialog by using the xml_html_options command. Available schemes are listed in the Schemes column. The tags that make up each scheme are listed in the Tags column.

Default Schemes

XML/HTML Formatting comes with two default schemes. Each time that you open an HTML file for editing, by default, the html (default html) scheme is used. Each time an XML file is opened, the xml (default xml) scheme is used. You can configure the settings for each default scheme or specify your own default schemes (see Specifying a Different Default Scheme).

The html (default html) scheme is comprised of a (default) tag as well as a list of commonly used HTML tags, that are preconfigured with standard settings. The xml (default xml) scheme is comprised of one (default) tag preconfigured with standard settings.

For any tag that does not appear in the Tags list, the (default) tag settings are used.

Specifying the Scheme to Use

You can specify a scheme to use for just the current document, or a default scheme to use for all HTML and/or XML files that are created or opened in SlickEdit® Core.

To specify the scheme for the current document, click Format → XML/HTML Formatting → Current Document Options, and pick the scheme to use from the drop-down list. The scheme you choose is remembered the next time that the document is opened.

Specifying a Different Default Scheme

SlickEdit® Core has two predefined default schemes (see Default Schemes). You can specify your own default scheme for new XML or HTML files by selecting a scheme, then from the right-click context menu, choose Set as Default XML Scheme or Set as Default HTML Scheme. The name in the Scheme list will be appended with the text "(default xml)" or "(default html)". For example, if you have an HTML scheme named readmes and set it as the default, the name in the Schemes list will change to readmes (default html).

Creating Schemes

To create your own scheme, right-click in the Scheme column of the XML/HTML Formatting dialog, and select New Scheme.

Type a name for your scheme, then select an existing scheme on which it should be based. This will "copy" all of the tags and settings from the selected existing scheme to your new scheme. Click Create when finished.

Saving and Deleting Schemes

In the XML/HTML Formatting Scheme Configuration dialog, modified schemes are denoted by asterisks around the name (for example, *html*). To save a modified scheme, right-click on it and select Save Scheme Changes. Alternatively, when you close the XML/HTML Formatting dialog, you are prompted whether to save modified schemes.

To delete a selected scheme, right-click and choose Delete Scheme.

Working with Tags

As described previously, formatting schemes are comprised of individual tags with associated formatting settings. For example, in HTML, you may want start and end <div> tags to be on separate lines above/below the text, while start/end style tags (such as <b> and <i>) are formatted inline with the text.

In order to configure formatting for individual tags, you must first define a scheme (see Creating Schemes), or you can use one of the default schemes (see Default Schemes). The Tags column of the XML/HTML Formatting dialog shows a list of tags associated with the selected scheme.

Default Tags

For all schemes, a (default) tag is included. It defines the settings that are applied to tags that are not specifically listed in the Tags list. It can also be used as a basis for other tags when you use the Match tag style ofoption on the General tab.

The default settings for the (default) tag are based on a block-style tag, in that the start and end tags are on separate lines, content and nested tags are indented according to your extension indent style, and content is wrapped to a fixed right margin at column 80. Use the Preview area at the bottom of the dialog to see how tags based on the (default) tag will be formatted in your code.

Base Tags

Base tags are used to define groups of tags with similar behaviors. By creating a base tag and associating a set of actual tags with that tag, you can configure that set of tags by changing the settings for the base tag. The sample HTML schemes included with SlickEdit® Core include two base tags: (block) and (semi-block). When creating your own base tags, be sure to use unique tag names that are not used in formatting to make it easy to spot them.

The (block) tag is useful as a base tag for tags like <div>, where you want the start and end tags on separate lines from the content and aligned vertically. By default, this style indents nested tags and content according to your extension indent style, and content is wrapped to a fixed right margin at column 80. Because this is a common style in HTML, the (block) tag has the same settings as the (default) tag.

The (semi-block) tag is useful as a base tag for tags such as <h1>, where you want the start and end tags on the same line as the content. The default settings for (semi-block) are the same as for (block), except for the start and end tags.

Use the Preview area at the bottom of the dialog to see how tags based on these base tags will be formatted in your code. The following are examples:

<div>
    Sample text of a tag set to (block) style.
</div>
 
<h1>Sample text of a tag set to (semi-block) style. Notice how wrapping
occurs within this tag.</h1>
Adding and Deleting Tags

To add individual tags to a selected scheme, right-click in the Tags column and select New Tag. Type the name of the tag without angle brackets or attributes. Click OK and the new tag is now listed in the Tags column.

Note

Tag names cannot have spaces. If you create a new tag with spaces, SlickEdit Core converts the spaces to underscores in the dialog.

To add all of the tags from the current file to a selected scheme, right-click in the Tags column and select Add Tags from Current File.

To remove a tag from a selected scheme, right-click on the tag and select Delete Tag. Deleting SlickEdit® Core(default) tags, or any tag that is based on another, is not recommended. If you attempt to do this, you will be prompted whether to continue.

Formatting Settings

The tabs on the XML/HTML Formatting dialog contain settings that control how your text is formatted when XML/HTML Formatting is enabled. For descriptions of these options, see Working with Schemes.

Caution

XML/HTML Formatting does not currently affect XML or HTML Beautifier settings. If you run the beautifier on documents that have been automatically formatted through XML/HTML Formatting, you may find unexpected results.

Outline View for XML

For XML documents, the Outline View also provides a more customizable way of representing any XML file. This allows you to set up rules for how you want to see any type of XML node that is presented in the tree. There are several ways that you can customize a particular element's appearance:

  • Determining whether or not we want the element to be shown.

  • Using static text, attribute values or the node's value itself to build a format string for each node type.

Formatting Rule Sets

Formatting rule sets define how each element in an XML file is displayed in the tree. Each rule in the set represents an XML element that may be found in the XML file, and each is assigned a formatting string. This formatting string works very similarly to formatting strings in programming; you may use static text, and you may also include replaceable text, or aliases, for values that come from each specific node. There are currently two aliases that are available in for a format string:

  • (%attribute): This alias retrieves the value of a specific attribute on an XML node. For example, (%src) would retrieve the "src" attribute value.

  • (%\v): This alias retrieves the actual value of the node between the tags.

For instance, if we have a sect1 node like the following:

<sect1 xreflabel="Introduction">Hello world!</sect1>

and a format string defined for sect1 like this:

Section 1 (%xreflabel) : "(%\v)"

then the XML Outline View representation for this sect1 node would look like this:

Section 1 (Introduction) : "Hello world"

By controlling the way each XML element is displayed in the tree, we can create a much more readable presentation of the XML file.

Activating the XML Outline View

To activate the XML Outline View, right click in the Outline View and select Outline View → Use Outline View. This will only be enabled if the current document is an XML document. If you have not used the Outline View before, and you open an XML document, you will be prompted for whether or not you would like to use it, and whether you would like to configure a set of formatting rules for the current document. If you don't want to see the XML Outline View anymore, you may simply right click the tree and uncheck Outline View → Use Outline View to toggle it off.

Formatting Rule Set Configuration

The following dialog allows you to set up the formatting rule set you want to use for any specific XML document. You may be prompted to set up formatting rules the first time you view an XML document, or you may return to this dialog at any time by selecting Outline View → Edit Format Rules.

The current rule set is shown at the top of the dialog and represents the rule set you are currently editing. In the screen shot, which shows a rule set for docbook files, there is a rule for the para element, and a rule for the sect1 to sect5 elements.

To add a new element to the current rule set, click the New button underneath the XML element list. You will be prompted to select the name of the element from a combo box (which is populated with unique element names from the current document) or you can enter your own name if it's not in the list. Next, you will enter a formatting string for the element. You may also delete the current rule by clicking the Delete button underneath the XML element list. If an element is not in the list, it will not be represented in the XML Outline View.

If you would like to create a new formatting rule set, you may click the New button next to the rule set drop down. You will be prompted to enter the name of the new rule set, and then you may begin adding rules to it. If you no longer want a rule set, you may delete it by clicking the Delete button next to the rule set drop down.

Applying Formatting Rules to XML Files

Once you have a formatting rule set to apply to one or more of your XML files, you can make that assignment by right clicking the tree and selecting Outline View → Select Format Rules. This will bring up the following dialog:

Here, you may select the formatting rule set that you wish to use with the current file. You may also select the scope to which it is applied. You may:

  • Use the scheme for the current document.

  • Use the scheme for all XML files with the same extension as the current document.

From this dialog, you may also click the Configure button to go back to the Formatting Rule Set Configuration dialog.