Skip to content

Commit

Permalink
Merge pull request #3534 from dita-ot/feature/metawriter-npe
Browse files Browse the repository at this point in the history
Handle metadata push to composite document without topic
  • Loading branch information
jelovirt committed Jun 14, 2020
2 parents 0ed2c3e + 573997b commit de3effa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/dita/dost/module/MoveMetaModule.java
Expand Up @@ -155,7 +155,6 @@ private void pushMetadata(final Map<URI, Map<String, Element>> mapSet) {
if (fi.format != null && ATTR_FORMAT_VALUE_DITAMAP.equals(fi.format)) {
mapInserter.setMetaTable(entry.getValue());
if (toFile(targetFileName).exists()) {
logger.info("Processing " + targetFileName);
try {
mapInserter.read(toFile(targetFileName));
} catch (DITAOTException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/dita/dost/writer/DitaMapMetaWriter.java
Expand Up @@ -53,7 +53,7 @@ public final class DitaMapMetaWriter extends AbstractDitaMetaWriter {
public Document process(final Document doc) {
Element root = getMatchingTopicElement(doc.getDocumentElement());
if (hasMetadata(topicmetaOrder)) {
final Element prolog = findMetadataContainer(root, topicmetaPosition, TOPIC_PROLOG);
final Element prolog = findMetadataContainer(root, topicmetaPosition, MAP_TOPICMETA);
processMetadata(prolog, topicmetaOrder);
}
return doc;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/dita/dost/writer/DitaMetaWriter.java
Expand Up @@ -65,7 +65,10 @@ public final class DitaMetaWriter extends AbstractDitaMetaWriter {
));

public Document process(final Document doc) {
Element root = getMatchingTopicElement(doc.getDocumentElement());
final Element root = getMatchingTopicElement(doc.getDocumentElement());
if (root == null) {
return doc;
}
if (hasMetadata(titlealtsOrder)) {
final Element titlealts = findMetadataContainer(root, titlealtsPosition, TOPIC_TITLEALTS);
processMetadata(titlealts, titlealtsOrder);
Expand Down
19 changes: 11 additions & 8 deletions src/main/plugins/org.dita.html5/xsl/topic.xsl
Expand Up @@ -2322,14 +2322,17 @@ See the accompanying LICENSE file for applicable license.

<!-- Generate links to CSS files -->
<xsl:template name="generateCssLinks">
<xsl:variable name="childlang">
<xsl:choose>
<!-- Update with DITA 1.2: /dita can have xml:lang -->
<xsl:when test="self::dita[not(@xml:lang)]">
<xsl:for-each select="*[1]"><xsl:call-template name="getLowerCaseLang"/></xsl:for-each>
</xsl:when>
<xsl:otherwise><xsl:call-template name="getLowerCaseLang"/></xsl:otherwise>
</xsl:choose>
<xsl:variable name="childlang" as="xs:string">
<xsl:variable name="lang">
<xsl:choose>
<!-- Update with DITA 1.2: /dita can have xml:lang -->
<xsl:when test="self::dita[not(@xml:lang)]">
<xsl:for-each select="*[1]"><xsl:call-template name="getLowerCaseLang"/></xsl:for-each>
</xsl:when>
<xsl:otherwise><xsl:call-template name="getLowerCaseLang"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:sequence select="($lang, $DEFAULTLANG)[normalize-space(.)][1]"/>
</xsl:variable>
<xsl:variable name="direction">
<xsl:apply-templates select="." mode="get-render-direction">
Expand Down

0 comments on commit de3effa

Please sign in to comment.