Page 1 of 1

Be able to sort DITA Simple List Items

Posted: Fri Mar 13, 2015 6:14 am
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

Re: Be able to sort DITA Simple List Items

Posted: Fri Mar 13, 2015 12:44 pm
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

Re: Be able to sort DITA Simple List Items

Posted: Fri Mar 13, 2015 8:28 pm
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

Re: Be able to sort DITA Simple List Items

Posted: Mon Mar 16, 2015 9:54 am
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

Re: Be able to sort DITA Simple List Items

Posted: Mon Mar 16, 2015 6:08 pm
by lief.erickson
That change did it. Thank you!

Re: Be able to sort DITA Simple List Items

Posted: Mon May 18, 2015 3:02 pm
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