Token File

Sandcastle MAML

Sandcastle MAML Guide Token File

A token is used as a replaceable tag within a topic and is represented using a token element. The inner text of the element is a token name. The tokens are defined in a separate token file. They are an easy way to represent common items that you use regularly such as a common phrase or external link.

Token File Format

Below is an example of a token file.

Example Token File
<?xml version="1.0" encoding="utf-8"?>
<!-- This is an example tokens file -->
<content xml:space="preserve"
  xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5"
  xmlns:xlink="http://www.w3.org/1999/xlink">

  <item id="Sandcastle"><ddue:externalLink>
    <ddue:linkText>Sandcastle</ddue:linkText>
    <ddue:linkUri>https://GitHub.com/EWSoftware/SHFB</ddue:linkUri>
</ddue:externalLink></item>
  <item id="SHFB"><ddue:externalLink>
    <ddue:linkText>Sandcastle Help File Builder</ddue:linkText>
    <ddue:linkUri>https://GitHub.com/EWSoftware/SHFB</ddue:linkUri>
</ddue:externalLink></item>
  <item id="autoOutline"><autoOutline /></item>
</content>

The file consists of a root content node that contains one or more item nodes. Be sure to add the xml:space attribute to preserve whitespace and the two namespace attributes on the content element.

The item element has an id attribute that gives each one a unique identifier. This is used as the inner text of the token element in a topic to represent the token. The inner XML of the item will be used to replace the token at build-time.

Note Note

The token ID is not case-sensitive.

Token Content

The content of a token item can be anything you like and may include other MAML elements. In the example above, the first four elements are used to define common external links used by this project.

Note Note

If you embed MAML elements within a token, you must prefix each element name with "ddue:" (without the quotes) as shown in the example above. If not, the elements are inserted using the default empty namespace and they will not be processed by the Sandcastle transformations.

The autoOutline token is a special case used by earlier versions of Sandcastle to insert an auto-generated section outline within a topic's introduction or sub-sections. See the autoOutline topic for more information.

Tip Tip

The Sandcastle Help File Builder adds the autoOutline token as part of the build automatically. As such, you do not need to define it in the project yourself.

Tip Tip

Sandcastle contains an extension to the MAML schema and the autoOutline element can be added directly in the topic without the need for embedding it in a token.

See Also