Sort glossary in alphabetical order
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 33
- Joined: Tue Feb 20, 2018 2:51 pm
Sort glossary in alphabetical order
Post by anna_craneo »
I have created ditamap for my glossterms
Now I would like to sort refs in alphabetical order. I have found this post, but I do not use bookmap.
I'm not very strong in XSLT, so I would really appreciate any help.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map id="glossary">
<title>A Glossary of Terms used in <ph keyref="product"/></title>
<topicmeta>
<shortdesc>Definitions for terms used in <ph keyref="product"/></shortdesc>
<data name="wh-menu">
<data name="hide" value="no"/>
</data>
</topicmeta>
<glossref href="../glossary/risk-score.dita" print="yes" toc="no" product="platform"
keys="glossentry-risk-score"/>
<glossref href="../glossary/case.dita" keys="glossentry-case" print="yes" toc="no"
product="platform"/>
<glossref href="../glossary/ME-group.dita" print="yes" toc="no" product="platform"
keys="glossentry-me-group"/>
<glossref href="../glossary/owner.dita" print="yes" toc="no" product="platform"
keys="glossentry-owner"/>
</map>
I'm not very strong in XSLT, so I would really appreciate any help.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Sort glossary in alphabetical order
Hi,
Maybe in order to use the XSLT stylesheet I proposed on that blog post you could add a <topicgroup> with a certain "id='glossarylistgroup'" attribute to surround all your topicrefs to glossary entries (this will not change how the publishing looks like).
And then in the XSLT stylesheet instead of having the XSLT template match the "glossarylist" have it match that topicgroup like:
Regards,
Radu
Maybe in order to use the XSLT stylesheet I proposed on that blog post you could add a <topicgroup> with a certain "id='glossarylistgroup'" attribute to surround all your topicrefs to glossary entries (this will not change how the publishing looks like).
And then in the XSLT stylesheet instead of having the XSLT template match the "glossarylist" have it match that topicgroup like:
Code: Select all
<xsl:template match="topicgroup[@id='glossarylistgroup']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each select="*" >
<xsl:sort select="document(@href, .)/*/glossterm/text()"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Sort glossary in alphabetical order
Post by Anonymous1 »
I am also trying to sort glossary terms in alphabetical order in our numerous target languages.
We are using ditamaps instead of bookmaps so the initial code from the blog post obviously doesn't work.
I've added the <topicgroup> element then and used your code provided in this thread. Without success.
Is this supposed to work with our glossary term structure?
This is how our glossary term topics look like:
When I apply the refactoring method you've explained it does not have any effect on the ditamap. Do I have to make a special selection or change the code somewhere?
I am using the XSL you've provided in this thread.
We are using ditamaps instead of bookmaps so the initial code from the blog post obviously doesn't work.
I've added the <topicgroup> element then and used your code provided in this thread. Without success.
Is this supposed to work with our glossary term structure?
This is how our glossary term topics look like:
Code: Select all
<glossentry xml:lang="de-DE" id="example_g">
<glossterm>Beispiel</glossterm>
<glossdef>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
</glossdef>
<prolog>
<author>b-e-n</author>
<critdates>
<created date="2018-07-03"/>
<revised modified="2019-11-08"/>
</critdates>
</prolog>
</glossentry>
I am using the XSL you've provided in this thread.
Code: Select all
<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() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="glossarylist">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each select="*" >
<xsl:sort select="document(@href, .)/*/glossterm/text()"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Sort glossary in alphabetical order
Hi,
If the DITA Map has a structure like this:
then an XSLT refactoring operation looking like this should sort it:
Regards,
Radu
If the DITA Map has a structure like this:
Code: Select all
<topicgroup id='glossarylistgroup'>
<topicref href="concepts/glossaryGenus.dita"
keys="genus" print="yes"/>
<topicref href="concepts/glossaryPollination.dita"
keys="pollination" print="yes"/>
</topicgroup>
Code: Select all
<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() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="topicgroup[@id='glossarylistgroup']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each select="*" >
<xsl:sort select="document(@href, .)/*/glossterm/text()"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Sort glossary in alphabetical order
Post by Anonymous1 »
One addition:
The sorting was case sensitive. So the resulting order was like this:
A
B
a
Instead of:
A
a
B
I've then added <xsl:choose> to your code to add the "lang" attribute when needed. This sorts the languages as required.
This seems to work now as intended. Thanks again.
The sorting was case sensitive. So the resulting order was like this:
A
B
a
Instead of:
A
a
B
I've then added <xsl:choose> to your code to add the "lang" attribute when needed. This sorts the languages as required.
Code: Select all
<xsl:when test="/map/@xml:lang='de-DE'">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each select="*" >
<xsl:sort select="document(@href, .)/*/glossterm/text()" lang="de"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:when>
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Sort glossary in alphabetical order
Hi,
Thanks, I will also try to update the code sample on the blog post to reflect your idea of taking the xml:lang into account.
Regards,
Radu
Thanks, I will also try to update the code sample on the blog post to reflect your idea of taking the xml:lang into account.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Sort glossary in alphabetical order
Post by Anonymous1 »
Icing on the cake would be if I could integrate the refactoring into a transformation scenario.
To automatize the WebHelp glossary term sorting. This way the authors would not have to memorize another step before publishing.
To automatize the WebHelp glossary term sorting. This way the authors would not have to memorize another step before publishing.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Sort glossary in alphabetical order
Hi,
Right, handling this at publishing time would be more interesting although it may also help at editing time to have the glossentries sorted in the map.
We have an internal issue to add sorting for glossary entries in our WebHelp Responsive output, if we manage to implement it I will update this forum thread.
We already have plugin extension points which can get called when various parts of our WebHelp responsive output is built:
https://www.oxygenxml.com/doc/versions/ ... mport.html
For example one of those extension points allows adding a custom XSLT stylesheet when the WebHelp table of contents is build com.oxygenxml.webhelp.xsl.createTocXML.
So doing something like this in the publishing output is not impossible, maybe you can also ask around on the DITA Users List, see if maybe others have already done this.
Regards,
Radu
Right, handling this at publishing time would be more interesting although it may also help at editing time to have the glossentries sorted in the map.
We have an internal issue to add sorting for glossary entries in our WebHelp Responsive output, if we manage to implement it I will update this forum thread.
We already have plugin extension points which can get called when various parts of our WebHelp responsive output is built:
https://www.oxygenxml.com/doc/versions/ ... mport.html
For example one of those extension points allows adding a custom XSLT stylesheet when the WebHelp table of contents is build com.oxygenxml.webhelp.xsl.createTocXML.
So doing something like this in the publishing output is not impossible, maybe you can also ask around on the DITA Users List, see if maybe others have already done this.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 1
- Joined: Tue Dec 31, 2019 8:13 pm
- Location: Riyadh
- Contact:
Re: Sort glossary in alphabetical order
We are using ditamaps instead of bookmaps so the initial code from the blog post obviously doesn't work.




-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Sort glossary in alphabetical order
Hi,
An update of the blog post can be found on our new Oxygen XML Blog platform hosted by Netlify:
https://oxygenxmlblog.netlify.com/topic ... tries.html
In that updated XSLT the template matches:
meaning that you can have a <topicgroup> with the outputclass='glossarylist' attribute set on it which in turn would contain inside all the topicrefs pointing to the glossentries.
Regards,
Radu
An update of the blog post can be found on our new Oxygen XML Blog platform hosted by Netlify:
https://oxygenxmlblog.netlify.com/topic ... tries.html
In that updated XSLT the template matches:
Code: Select all
<xsl:template match="glossarylist | topicgroup[@outputclass='glossarylist']">
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
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