Setting Metadata Automatically
To create custom metadata rules, create a file called harp-metadata.xsl
in
a folder called HARP-META
at the root level of a project or document type.
Metadata rules for a doctype will apply for all documents of that doctype in all projects
using
that doctype. Rules in a project apply for all XML documents in that project. If a
file has
metadata rules associated with both its project and its doctype, both transforms will
be run, and
the union of all metadata gathered from both will be assigned to the object.
The stylesheet should output XML in the following format:
<root> <metadata name="name">value</metadata> <!-- Other metadata --> </root>
If a given metadata name has more than one value, the XSLT should output multiple
<metadata>
elements with that name. Any markup within
<metadata>
elements will be ignored; only character data will be used.
Default Metadata Rules for DITA Documents
The built-in DITA doctypes are configured with the following metadata rules. The default stylesheet will work for the given element names as well as any specializations of those elements.
product
- The
@product
attribute on the root element. - The
<prodname>
elements within<prodinfo>
elements within<prolog>
(on topics) or top-level<topicmeta>
(on maps). audience
- The
@audience
attribute on the root element. - The
@type
attribute on<audience>
elements within<prolog>
(on topics) or top-level<topicmeta>
(on maps). experiencelevel
- The
@expriencelevel
attribute on<audience>
elements within<prolog>
(on topics) or top-level<topicmeta>
(on maps). platform
- The
@platform
attribute on the root element. - The
<platform>
elements within<prodinfo>
elements with<prolog>
(on topics) or top-level<topicmeta>
(on maps). brand
- The
<brand>
elements within<prodinfo>
elements within<prolog>
(on topics) or top-level<topicmeta>
(on maps). permission
- The
@view
attribute on any<permission>
elements within<prolog>
(on topics) or top-level<topicmeta>
(on maps). category
- Any
<category>
elements within<prolog>
(on topics) or top-level<topicmeta>
(on maps).
The default rules will also capture <data>
elements wtithin
<metadata>
elements within <prolog>
(on topics) or
top-level <topicmeta>
(on maps). The metadata name is drawn from the
@name
attribute, and the value is drawn from the @value
attribute and the element contents. If both the @value
attribute is present and
the element contains content, two values will be assigned to the metadata name.
Finally, the default rules will automatically capture <othermeta>
elements
within <prolog>
(on topics) or top-level <topicmeta>
(on
maps). The name will be drawn from the @name
attribute, and the value from
@content
.