Appendix to another topic
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 3
- Joined: Wed Oct 19, 2022 4:51 pm
Appendix to another topic
Post by dorian_topsolid »
Hello,
I'm looking for ideas as to how to categorize some topics as appendices to other topics.
As an appendix, a topic would bear the name "Appendix to chapter x", where "to chapter x" references a <chapter> with a number created with the CSS function counter().
I realise I need to link the appendix to its corresponding chapter, but I'm not really sure how.
Could a relationship table help with this? Is this even possible?
I work with Oxygen PDF Chemistry.
Kind regards,
Dorian
I'm looking for ideas as to how to categorize some topics as appendices to other topics.
As an appendix, a topic would bear the name "Appendix to chapter x", where "to chapter x" references a <chapter> with a number created with the CSS function counter().
I realise I need to link the appendix to its corresponding chapter, but I'm not really sure how.
Could a relationship table help with this? Is this even possible?
I work with Oxygen PDF Chemistry.
Kind regards,
Dorian
-
- Posts: 667
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Appendix to another topic
Post by julien_lacour »
Hello Dorian,
You can already use DITA <appendices> and <appendix> elements in your bookmaps to obtain a specific display in PDF.
You can also use <xref> elements to link appendix to chapter, something like this:
And finally, you can create some custom CSS rule to add the chapter number, like this:
Regards,
Julien
You can already use DITA <appendices> and <appendix> elements in your bookmaps to obtain a specific display in PDF.
You can also use <xref> elements to link appendix to chapter, something like this:
Code: Select all
<title>Appendix to <ph><xref href="snowdrop.dita"/></ph></title>
Code: Select all
*[class ~= "topic/topic"] > *[class ~= "topic/title"] *[class ~= "topic/xref"] {
content: "Chapter " target-counter(attr(href), chapter);
}
/* To remove the (on page X) label */
*[class ~= "topic/topic"] > *[class ~= "topic/title"] *[class ~= "topic/xref"]::after {
content: none;
}
Julien
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Appendix to another topic
Post by chrispitude »
For references to book-structure topics, our writers manually set a specialized @xformat attribute, then we use that for <xref> formatting:
You could also use @outputclass instead of specializing a separate attribute.
We use separate editor-specific rules to show a "#" where the number would normally be.
Code: Select all
/**************************************
** Print-specific formatting
*/
@media print {
/* references to bookmap things */
*.topic\/link[xformat~="part"]::before,
*.topic\/xref[xformat~="part"]::before {
content: "Part\00a0#, " !important;
}
*.topic\/link[xformat~="chapter"]::before,
*.topic\/xref[xformat~="chapter"]::before {
content: "Chapter\00a0#, " !important;
}
*.topic\/link[xformat~="appendix"]::before,
*.topic\/xref[xformat~="appendix"]::before {
content: "Appendix\00a0#, " !important;
}
}
/**************************************
** Editor-specific formatting
*/
@media oxygen {
/* references to bookmap things */
.topic\/link[xformat~="part"]::before,
.topic\/xref[xformat~="part"]::before {
content: "Part\00a0" target-counter(attr(href), part) ', ' !important;
}
.topic\/link[xformat~="chapter"]::before,
.topic\/xref[xformat~="chapter"]::before {
content: "Chapter\00a0" target-counter(attr(href), chapter) ', ' !important;
}
.topic\/link[xformat~="appendix"]::before,
.topic\/xref[xformat~="appendix"]::before {
content: "Appendix\00a0" target-counter(attr(href), chapter, upper-latin) ', ' !important;
}
}
We use separate editor-specific rules to show a "#" where the number would normally be.
-
- Posts: 3
- Joined: Wed Oct 19, 2022 4:51 pm
Re: Appendix to another topic
Post by dorian_topsolid »
Bonjour Julien,
Works brilliantly, thank you!
The only issue is that your code doesn't work in my ToC, what would need to be changed?
Indeed, I see that the link isn't kept during the transformation if I look under:
There's no <a>, like in the content. However, in my ToC, I get the name of the topic which I'm trying to link to.
I did try to remove the "topic/xref" but it just continues counting the number of chapters since I'm already using a "counter(chapter)".
Thank you again!
Dorian
Works brilliantly, thank you!
The only issue is that your code doesn't work in my ToC, what would need to be changed?
Indeed, I see that the link isn't kept during the transformation if I look under:
Code: Select all
<div class="- toc/toc">
<div class="- map/topicref">
<div class="- map/topicmeta">
<div class="- topic/navtitle">
I did try to remove the "topic/xref" but it just continues counting the number of chapters since I'm already using a "counter(chapter)".
Thank you again!
Dorian
-
- Posts: 667
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Appendix to another topic
Post by julien_lacour »
Hello Dorian,
For the TOC, you will need to use an XSLT Extension Point, you can follow this topic to setup the publishing template.
You will need to obtain something like this:
Regards,
Julien
For the TOC, you will need to use an XSLT Extension Point, you can follow this topic to setup the publishing template.
You will need to obtain something like this:
- A publishing template declaring the CSS and the XSLT files:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?> <publishing-template> <name>Custom</name> <pdf> <resources> <css file="custom.css"/> </resources> <xslt> <extension file="m2m-toc-elements.xsl" id="com.oxygenxml.pdf.css.xsl.merged2merged"/> </xslt> </pdf> </publishing-template>
- An XSLT stylesheet with the following template:
Code: Select all
<!-- Keep navtitle elements --> <xsl:template match="node()[not(empty(child::node()))]" mode="navtitle-remove-tms-indexes"> <xsl:element name="{local-name()}"> <xsl:copy-of select="@*"/> <xsl:next-match/> </xsl:element> </xsl:template>
- A CSS Stylesheet with the following rules:
Code: Select all
/* * TOC */ *[class ~= "map/topicref"] *[class ~= "topic/navtitle"] *[class ~= "topic/xref"] { content: "Chapter " target-counter(attr(href), chapter); -oxy-link: none; color: unset; } /* To remove the (on page X) label */ *[class ~= "map/topicref"] *[class ~= "topic/navtitle"] *[class ~= "topic/xref"]::after { content: none; } /* * BOOKMARKS */ *[class ~= "topic/topic"] > *[class ~= "topic/title"]:has(* * *[class ~= "topic/xref"]) { bookmark-label: content(before) content(text) " Chapter " target-counter(oxy_xpath(".//@href"), chapter); } /* * CONTENT */ *[class ~= "topic/topic"] > *[class ~= "topic/title"] *[class ~= "topic/xref"] { content: "Chapter " target-counter(attr(href), chapter); } /* To remove the (on page X) label */ *[class ~= "topic/topic"] > *[class ~= "topic/title"] *[class ~= "topic/xref"]::after { content: none; }
Regards,
Julien
-
- Posts: 3
- Joined: Wed Oct 19, 2022 4:51 pm
Re: Appendix to another topic
Post by dorian_topsolid »
Hello Julien,
I've followed your suggestions, they did fix the bookmark labels (thank you!) but unfortunately, they did not work in my ToC...
Here's what I have right now:
I did try your code exactly as it was (copied and pasted), but it did not work.
Here's a screenshot:
Could it be that the XSLT file is not doing its job properly? I don't understand it to be honest, but I believe I've implemented it correctly.
I already had a .opt file, in which I referenced it. Oxygen also tells me it's valid. I've never worked with .xslt.
I'm not sure what to do.
Kind regards,
Dorian
I've followed your suggestions, they did fix the bookmark labels (thank you!) but unfortunately, they did not work in my ToC...
Here's what I have right now:
Code: Select all
*[class ~= "map/topicref"][outputclass~="annex"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]:before {
content: "Annexe du chapitre " !important;
}
*[class ~= "map/topicref"][outputclass~="annex"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"] *[class ~= "topic/xref"] {
content: target-counter(attr(href), chapter) " - ";
-oxy-link: none;
color: unset;
}
/* To remove the (on page X) label */
*[class ~= "map/topicref"][outputclass~="annex"] *[class ~= "topic/navtitle"] *[class ~= "topic/xref"]::after {
content: none;
}
Here's a screenshot:
image.png
Here's the <title>:
Code: Select all
<title><ph><xref href="part_1_designing_parts_and_drafting_01.dita"/>Pour aller plus loin</ph></title>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node()[not(empty(child::node()))]" mode="navtitle-remove-tms-indexes">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:next-match/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I'm not sure what to do.
Kind regards,
Dorian
You do not have the required permissions to view the files attached to this post.
Last edited by dorian_topsolid on Fri Oct 21, 2022 4:03 pm, edited 1 time in total.
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service