css:map-styles (in library map-style-names.xpl) map-styles

A wrapper for the individual other steps in this library.

Here’s an explanation of the style mapping concept:

  • The tilde ('~') and the string '_-_' may be used interchangeably in both first columns. They are called “tilde metacharacters”.
  • Table rows without td will be ignored.
  • Otherwise the first td in a row needs to hold the canonical (system) style name, while the second td contains the user-defined style name that is found in the actual content and that should be mapped to the system name.
  • Both names may contain tilde metacharacters.
  • The first table in the body will be used for mapping purposes.
  • The user style name values in the second column are regular expressions. Likewise, the first column contains replacements. You may refer to matching groups by $1, $2, etc.
  • All mappings will be applied to each style, sequentially from top to bottom.
  • A given mapping instruction will first be tested against css:rule/@native-name then against css:rule/@name. If native-name matches, the replacement is taken from first column and applied to native-name. The name attribute will then be generated from the updated native-name attribute.
  • The comment column is irrelevant to the mapping process.
  • If there are multiple style maps in a configuration hierarchy, they will be merged. If the system names of two rows match, the row from the more specific map file will win.
  • The merged file will appear in the debug dir als map-style-names/consolidated-map.xhtml. It will contain provenance information in the first, all-th column, as links to the source map file for each rule.

Input Ports

NameDocumentationConnections

source

A document (or douments) with CSSa, where the /*/@css:rule-selection-attribute designates the name of the @role, @rend, @class, etc. attribute(s) that contain(s) style names.

paths

A transpect paths document (c:param-set with certain c:params that enable cascaded loading).

Output Ports

NameDocumentationConnections

result

The source document(s) with mapped styles.

Options

NameDocumentationDefault

debug

'no'

debug-dir-uri

'debug'

map-name

'styles/map.xhtml'

status-dir-uri

'debug/status'

Subpipeline

StepInputsOutputsOptions

tr:load-whole-cascade all-maps

paths

paths on map-styles

result

order = 'most-specific-first'

filename = $map-name

css:consolidate-maps consolidate-maps

source

result on all-maps

result

debug = $debug

debug-dir-uri = $debug-dir-uri

p:sink d220e328

source

result on consolidate-maps

p:for-each iter

source on map-styles

css:apply-map apply-map

source

current on iter

map

result on consolidate-maps

result

debug = $debug

debug-dir-uri = $debug-dir-uri

tr:store-debug store

source

result on apply-map

result

pipeline-step = concat('map-style-names/', replace(base-uri(), '^.+/(.+?)(\..+)?', '$1'), '.processed')

active = $debug

base-uri = $debug-dir-uri