Custom formatting of XREF output
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 2
- Joined: Thu Apr 03, 2025 11:46 am
Custom formatting of XREF output
I'm using Oxygen 27.1 to create PDF documentation in DITA. When I use an XREF, the PDF output will be something like "Topic title (on page X)".
Normally this is fine, but there are some cases where I would like to put XREFs in a table, and because of space restrictions I don't want the entire topic title and page number as a link. Instead I would like to only have the chapter number of the referenced topic as link text, so the links should look like "X.Y.Z".
Is there a way I could create an outputclass for these XREFs that will change the text used in the output? I've been successfull in creating an outputclass to change the formatting of the link, but not the text.
Normally this is fine, but there are some cases where I would like to put XREFs in a table, and because of space restrictions I don't want the entire topic title and page number as a link. Instead I would like to only have the chapter number of the referenced topic as link text, so the links should look like "X.Y.Z".
Is there a way I could create an outputclass for these XREFs that will change the text used in the output? I've been successfull in creating an outputclass to change the formatting of the link, but not the text.
-
- Posts: 679
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Custom formatting of XREF output
Post by julien_lacour »
Hello,
You can use outputclass but you could also match directly xrefs inside tables:
The rule above override the default content showing the target title and only displays the target chapter number.
If you want to remove the "(on page X)" label too, you can add this rule to the previous one:
Regards,
Julien
You can use outputclass but you could also match directly xrefs inside tables:
Code: Select all
*[class ~= "topic/table"] *[class ~= "topic/xref"][type = "topic"][href] {
content: target-counters(attr(href), chapter-and-sections, ".");
}
If you want to remove the "(on page X)" label too, you can add this rule to the previous one:
Code: Select all
*[class ~= "topic/table"] *[class ~= "topic/xref"][href]:after {
content: none;
}
Julien
-
- Posts: 2
- Joined: Thu Apr 03, 2025 11:46 am
Re: Custom formatting of XREF output
This works beautifully! I had to expand it a bit to also match concept, task and reference topics, but once that was done the solution worked as desired.
Thank you for the help!
Thank you for the help!
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Custom formatting of XREF output
Post by chrispitude »
Hi Julien,
That is a clever automatic solution!
That is a clever automatic solution!
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)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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