On 11/21/2011 06:17 PM, Fabián Mandelbaum wrote:
>
> On our custom extension, we'd need to preprocess text pasted onto the
> clipboard before "pasting after as" that text in the document.
> Specifically, we have this in the 0docbook5.xxe file of our extension:
>
> <button toolTip="PasteItemizedList" icon="icons/pasteAfterAsItemizedList.png">
> <command name="pasteAfterAs"
> parameter="#template({http://docbook.org/ns/docbook}itemizedlist,PAA.itemizedlist)"
> />
> </button>
>
> and I'd like to remove the bullets left over in the pasted text on the
> clipboard before executing the pasteAfterAs command when that button
> is clicked.
>
> Is there an already built command I can use to get rid of the bullets
> (string manipulation of the text pasted on the clipboard)
No, there is no such facility. We'll try to add it in next release.
> or should I
> write one and insert it in the command chain somehow?
>
For now, a macro-command like this one should solve your problem:
---
<command name="pasteAsList">
<macro>
<sequence>
<command name="formatTextAs"
parameter="#template({http://docbook.org/ns/docbook}itemizedlist,PAA.itemizedlist)"
/>
<transform source="%_">
<xsl:stylesheet version="1.0"
xmlns:db="http://docbook.org/ns/docbook"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="db:listitem/db:para/text()[1]">
<xsl:choose>
<xsl:when test="starts-with(., '*') or
starts-with(., '#')">
<xsl:value-of select="substring(., 2)"/>
</xsl:when>
<xsl:otherwise><xsl:copy/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
</transform>
<command name="paste"
parameter="after[implicitElement] %_" />
</sequence>
</macro>
</command>
<binding>
<keyPressed code="F5" />
<command name="pasteAsList" />
</binding>
---
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support