Code Snippets XML
Intellisense Code Snippets are pre-authored pieces of code that are ready to be inserted into your source using the Code Editor. These code snippets increase productivity by reducing the amount of time spent typing repetetive code or searching for samples. The snippets provided by the Code Editor are stored in a code snippet XML files. You can use the Code Snippet XML to create your own code snippets and add them to the collection of snippets that the Code Editor already includes.
A code snippet
A simple code snippet with a full header.
Smartsite SXML | Copy Code |
---|---|
<Snippet> <Header> <Title>SXML parameters block</Title> <Author>Smartsite Software</Author> <Description>An SXML parameters block</Description> </Header> <Code Kind="sxml" Language=""> <![CDATA[<se:parameters> <se:parameter name=""></se:parameter> </se:parameters>]]> </Code> <ImageIndex>43</ImageIndex> </Snippet> |
Customizable code snippets
When you add a snippet to your code, the inserted snippet code may have one or more replacement points highlighted in the code. You may or may not choose to change each replacement point. If you rest your mouse pointer over the replacement point, a ToolTip appears that explains how you need to change the code.
Replacement points are defined in Code Snippet XML using declarations and literals. The example below demonstrates the use of a replacable parameter name in a code snippet.
Smartsite SXML | Copy Code |
---|---|
<Snippet> <Header /> <Declarations> <Declaration> <Literals> <Literal> <ID>parameterName</ID> <Type>String</Type> <ToolTip>Replace with the name of a parameter.</ToolTip> <Default>parameterName</Default> </Literal> </Literals> </Declaration> </Declarations> <Code Delimiter="$" Kind="sxml" Language=""> <![CDATA[<se:parameters> <se:parameter name="$parameterName$"></se:parameter> </se:parameters>]]> </Code> <ImageIndex>43</ImageIndex> </Snippet> |
Code snippet collection
Code snippets are grouped within a named collection. Named collections form the categories in the code snippet selector.
Smartsite SXML | Copy Code |
---|---|
<Member> <Name>My SXML snippets</Name> <Path /> <ImageIndex>45</ImageIndex> <CodeSnippets> <Snippet> <!-- Content of snippet 1 --> </Snippet> <Snippet> <!-- Content of snippet 2 --> </Snippet> </CodeSnippets> </Member> |
Code snippet XML file
Finally all code snippet collections are combined into a single code snippet file. A code snippet file typically has the extension .snippet.
Smartsite SXML | Copy Code |
---|---|
<?xml version="1.0" encoding="utf-8" ?> <CodeSnippetCollection xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <CodeSnippetMembers> <Member> <Name>Common SXML snippets</Name> <Path /> <ImageIndex>45</ImageIndex> <CodeSnippets> <Snippet> <Header> <Title>SXML parameters block</Title> <Author>Smartsite Software</Author> <Description>An SXML parameters block</Description> <Shortcut></Shortcut> </Header> <Code Kind="sxml" Language=""> <![CDATA[<se:parameters> <se:parameter name=""></se:parameter> </se:parameters>]]> </Code> <ImageIndex>43</ImageIndex> </Snippet> </CodeSnippets> </Member> </CodeSnippetMembers> </CodeSnippetCollection> |
Intellisense Code Snippets Schema Elements
The following section describe attributes, child elements, and parent elements. Please note that the Snippet XML schema is similar to the schemas used in Microsoft Visual Studio.