13. linkScheme

<linkScheme>
  Content: [ class | scheme ]?
</linkScheme>

<class>
  Content: Java class name
</class>

<scheme
  name = non empty token
>
  Content: [ anchor ]+ [ link ]+
</scheme>

<anchor
  name = NMTOKEN
  element = QNAME
  attribute = QNAME
  value = string
  attribute2 = QNAME
  value2 = string
  text = string
>

<link
  anchors = NMTOKENS
  element = QNAME
  attribute = QNAME
  value = string
  attribute2 = QNAME
  value2 = string
  text = string
>

Associates a link scheme to a document type. An empty linkScheme element may be used to remove the link scheme associated to a document type.

There are two ways to associate a link scheme to a document type:

  1. Implement the com.xmlmind.xmleditapp.cmd.link.LinkScheme interface and declare the fully qualified name of the Java™ class implementing this interface in the class child element.

  2. Define a link scheme using the scheme element.

The scheme element has a required name attribute uniquely identifying the link scheme. This element contains one or more anchor child elements, followed by one or more link child elements.

An anchor element specifies a given kind of anchor (that is, a link target) elements. Its attributes are:

name

Optional attribute. Used to identify this kind of anchors. This name may be referenced in the anchors attribute of a link element.

element

Name of an element acting as an anchor. May be omitted, which means: any element.

attribute

An element acting as an anchor must have this attribute.

One of attribute, attribute2 or text must be specified with an "$anchor" value.

value

Required if attribute has been specified. Value of the attribute specified by attribute:

  • If this value is "$anchor", then the attribute specified by attribute is used to identify the anchor.

  • If this value is a non-empty string, then the attribute specified by attribute must be present and must have this fixed value.

  • If this value is an empty string, then the attribute specified by attribute must be present, but may have any value.

attribute2

An element acting as an anchor must have this attribute.

value2

Required if attribute2 has been specified. Value of the attribute specified by attribute2:

  • If this value is "$anchor", then the attribute specified by attribute2 is used to identify the anchor.

  • If this value is a non-empty string, then the attribute specified by attribute2 must be present and must have this fixed value.

  • If this value is an empty string, then the attribute specified by attribute2 must be present but may have any value.

text

An element acting as an anchor must contain text (just text, not a mix). The allowed values for the text attribute are:

  • If the value is "$anchor", then the text content of the element is used to identify the anchor.

  • If the value is a non-empty string, then the text content of the element must have this fixed value.

  • If this value is an empty string, then the text content of the element may have any value.

A link element specifies a given kind of link elements. Its attributes are:

anchors

Optional attribute. Contains a list of anchor names separated by space, which means: this kind of link may be used to target all the kinds of anchors referenced in the list. In other words, it may not be used to target kinds of anchors not specified in the list.

When this attribute is not specified, this kind of link is ``compatible'' with any kind of anchor.

element

Required attribute. Name of an element acting as a link.

attribute

An element acting as a link must have this attribute.

One of attribute, attribute2 or text must be specified with an "$anchor" or "$fragment" value.

value

Required if attribute has been specified. Value of the attribute specified by attribute:

  • If this value is "$anchor", then the attribute specified by attribute is used to identify the link target.

  • If the value is "$fragment", then after removing a "#" prefix, the attribute specified by attribute is used to identify the link target.

  • If this value is a non-empty string, then the attribute specified by attribute must be present and must have this fixed value.

  • If this value is an empty string, then the attribute specified by attribute must be present, but may have any value.

attribute2

An element acting as a link must have this attribute.

value2

Required if attribute2 has been specified. Value of the attribute specified by attribute2:

  • If this value is "$anchor", then the attribute specified by attribute2 is used to identify the link target.

  • If the value is "$fragment", then after removing a "#" prefix, the attribute specified by attribute2 is used to identify the link target.

  • If this value is a non-empty string, then the attribute specified by attribute2 must be present and must have this fixed value.

  • If this value is an empty string, then the attribute specified by attribute2 must be present, but may have any value.

text

An element acting as a link must contain text (just text, not a mix). The allowed values for the text attribute are:

  • If the value is "$anchor", then the text content of the element is used to identify the link target.

  • If the value is "$fragment", then after removing a "#" prefix, the text content of the element is used to identify the link target.

  • If the value is a non-empty string, then the text content of the element must have this fixed value.

  • If this value is an empty string, then the text content of the element may have any value.

DITA topic example:

<linkScheme>
  <class>com.xmlmind.xmleditext.dita.DITALinkScheme</class>
</linkScheme>

Simplified DocBook example:

<cfg:linkScheme>
  <cfg:scheme name="Simplified DocBook" xmlns="">
    <cfg:anchor attribute="id" value="$anchor" />

    <cfg:link element="link" attribute="linkend" value="$anchor" text="" />
    <cfg:link element="xref" attribute="linkend" value="$anchor" />
  </cfg:scheme>
</cfg:linkScheme>

XHTML example:

<cfg:linkScheme>
  <cfg:scheme name="XHTML" xmlns="http://www.w3.org/1999/xhtml">
    <cfg:anchor element="a" attribute="name" value="$anchor" />
    <cfg:anchor attribute="id" value="$anchor" />

    <cfg:link element="a" attribute="href" value="$fragment" text=""/>
  </cfg:scheme>
</cfg:linkScheme>

Extended XHTML example (not used in an actual configuration):

<cfg:linkScheme>
  <cfg:scheme name="Extended XHTML" xmlns="http://www.w3.org/1999/xhtml">
    <cfg:anchor name="name"
                element="a" attribute="name" value="$anchor" />
    <cfg:anchor name="id"
                attribute="id" value="$anchor" />

    <cfg:anchor name="anchor-class"
                element="span" attribute="class" value="anchor" 
                text="$anchor"/>

    <cfg:link anchors="name id" 
              element="a" attribute="href" value="$fragment" text=""/>

    <cfg:link anchors="anchor-class"
              element="span" attribute="class" value="link" 
              text="$anchor"/>
  </cfg:scheme>
</cfg:linkScheme>

In addition to the <a href="#..."> element, a span element having attribute class="link" is considered to be a link targeting a <span class="anchor"> element.

In addition to the id attribute and to the <a name="..."> element, a span element having attribute class="anchor" is considered to be a possible link target for <span class="link"> elements.

Snippet making use of the "Extended XHTML" link scheme:

<p>This <span class="link">a1</span> is a link to "a1".</p>

<p>This paragraph contains anchor "a1" <span class="anchor">a1</span>.</p>