Be able to sort DITA Simple List Items

Are you missing a feature? Request its implementation here.
lief.erickson
Posts: 17
Joined: Sun Mar 01, 2015 8:26 am

Be able to sort DITA Simple List Items

Post by lief.erickson »

Hello--

oXygen has to capability to sort ordered and unordered lists, but the <sl> / <sli> elements cannot be sorted. Can this functionality be added?

-Lief
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Be able to sort DITA Simple List Items

Post by alex_jitianu »

Hello Lief,

I've added a feature request to offer the sort action for simple lists too. Until then, you could implement a sort author action based on an XSLT script, like this:

1. Create an Author action that uses the XSLTTransformOperation
2. Configuration details:
- when this XPath expression is true : ancestor-or-self::sl[1
- sourceLocation : ancestor-or-self::sl[1]
- targetLocation : ancestor-or-self::sl[1]
- invoke the operation : ro.sync.ecss.extensions.commons.operations.XSLTOperation
- script (you should change the xsl:sort from the script as needed):

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="sl">
<xsl:copy>
<xsl:for-each select="sli">
<xsl:sort select="text()"></xsl:sort>

<xsl:copy-of select="."></xsl:copy-of>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
3. Add this action on the toolbar.

Best regards,
Alex
lief.erickson
Posts: 17
Joined: Sun Mar 01, 2015 8:26 am

Re: Be able to sort DITA Simple List Items

Post by lief.erickson »

Thanks for filing the feature request and, more immediately, the workaround, Alex. I've added an Author action as you've suggested, but when I select an <sl> element the action is not available. The action is grayed out on the toolbar (or not visible on the context menu). I've never created an Author action before. Can you confirm that I have configured the author action correctly?

Image

-Lief
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Be able to sort DITA Simple List Items

Post by alex_jitianu »

Hello Lief,

When you fully select an sl element the caret is positioned after it and the activation XPath doesn't work anymore. You can cover this situation with this activation XPath:

When this XPath expression is true:

Code: Select all

oxy:current-selected-element()[contains(@class," topic/sl ")] or ancestor-or-self::sl[1]
Best regards,
Alex
lief.erickson
Posts: 17
Joined: Sun Mar 01, 2015 8:26 am

Re: Be able to sort DITA Simple List Items

Post by lief.erickson »

That change did it. Thank you!
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Be able to sort DITA Simple List Items

Post by Radu »

Hi,

Just to update this thread, with Oxygen 17 you can now use the default sort operation to sort simple list items.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply