On 12/05/2012 01:18 PM, Manuel Collado wrote:
El 05/12/2012 9:57, Hussein Shafie escribió:
On 12/05/2012 12:35 AM, Jens Roever wrote:
Is there an easy way in the editor to convert a sequence of selected
paragraphs into an itemized or ordered list? Both this and the reverse
operation seem to be a fairly frequently needed tasks
All word processors excel at this task. However, may be it is just a
habit you (and everyone used to word processors) got. May be with an XML
editor you need to think differently: in terms of inserting structures,
rather in term of ``styling paragraphs''.
but I fail to find a simple way to do this in XMLmind.
That's right. There is no simple way to do this. XMLmind XML Editor
currently works by inserting structures and only supports converting
between similar structures (e.g. convert an itemized list to an ordered
list).
Of course, as always, it is probably possible to write or record a macro
command which does this (to a certain extent) and then binding this
macro to a keystroke.
See
http://www.xmlmind.com/xmleditor/_distrib/doc/help/recordMacroMenu.html
See
http://www.xmlmind.com/xmleditor/_distrib/doc/help/com.xmlmind.xmleditapp.kit.part.AddKeyboardShortcutDialog.html
I have a macro command that converts <p> to <li> for XHTML, by running
an XSLT transformation on the selection. It uses an external XSLT
processor, but perhaps can be adapted to use the bundled one.
My command looks as this:
---------------------------
<command name="xslt">
<macro>
<sequence>
<command name="wrap" parameter="{http://www.w3.org/1999/xhtml}div" />
<command name="run" parameter='"%C\libro" xslt "%0" "%F"' />
<command name="paste" parameter="to %_" />
</sequence>
</macro>
</command>
---------------------------
It wraps the multiple selection into a <div>, applies the required XSLT,
and pastes the result over the just created <div>.
The XSLT that converts a series of <p> into a <ul> is:
---------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" encoding="ISO-8859-1"/>
<!-- .......... identity template .......... -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- .......... div template .......... -->
<xsl:template match="/*">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<!-- .......... p template .......... -->
<xsl:template match="/*/ns:p">
<li>
<xsl:apply-templates />
</li>
</xsl:template>
<!-- .......... pre/ul/ol... template .......... -->
<xsl:template match="/*/*">
<li>
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</li>
</xsl:template>
</xsl:stylesheet>
----------------------------------------------------
This XSLT code understands the markup of the internal clipboard.
Could you suggest the skeleton of a command that applies a XSLT to the
selection by using the internal XSLT processor? I could eventually
contribute XSLTs for some logically simple but structurally complex
tranformations, like paragraph vs. list items transformations.
Thanks in advance.
Thank you for this contribution.
There are two ways to invoke an XSLT transformation from a macro command.
Method 1) the macro command may invoke a helper process command. See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/process.html
Method 2) the macro command may directly contain a <transform> child
element. See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro.html
In both cases, there is a simple way to pass the selection to the XSLT
transform. These methods are shown in the following examples:
With above method 1) See "2.1. Convert explicitly or implicitly selected
para to a formalpara" in
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/paraToFormalpara_example2.html
With above method 2) See "Example 4.8. Convert a DocBook 5 para to a
formalpara" in
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_examples.html
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support