Hello,

We finally solve the problem by using a Java applet accessed through
javascript to copy the xml content to the clipboard with a mime type of
"text/xml". It works fine when using it under linux, but not under
windows and I can't figure out why. Here is the very simple code I use
for the applet:

public class ClipboardApplet extends Applet implements ClipboardOwner {
   
    private Clipboard clipboard;
   
    @Override
    public void init() {
        clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    }
   
    public boolean copy(final String mimeType, final String content) {
        clipboard.setContents(new DataHandler(content, mimeType), this);
        return true;
    }

    @Override
    public void lostOwnership(Clipboard clipboard, Transferable contents) {
        // Nothing
    }
   
}

The "copy" method is used by javascript:
ClipboardApplet.copy('text/xml', xmlCode);

xmlCode being for example:

<?xml version="1.0"?><ns:clipboard
ns2:inclusion="com.xmlmind.xml.xinclude.XInclude:href=&quot;http://localhost:9000/workspaces/GeneralElectric/content/en/fragments.xml&quot;
xpointer=&quot;lorem-ipsum&quot;" ns2:readOnly="true"
ns2:sourceURL="http://localhost:9000/workspaces/GeneralElectric/content/en/fragments.xml";
xmlns:ns2="http://www.xmlmind.com/xmleditor/namespace/property";
xmlns:ns="http://www.xmlmind.com/xmleditor/namespace/clipboard";><para
xmlns="http://docbook.org/ns/docbook"; xml:id="lorem-ipsum" vendor=""
role="check">Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.</para></ns:clipboard>

Am I doing something wrong here?

Thanks for your help.

Maxime Bégnis

On 04/05/2013 10:13, Hussein Shafie wrote:
> On 05/03/2013 04:57 PM, Fabián Mandelbaum wrote:
>> Hussein, thanks for your answers, my remarks between lines:
>>
>>     An external application copying some XML to the clipboard for use by
>>     XXE must now declare the copied data as being "application/xml" (or
>>     "text/xml").
>>
>>     In a nutshell, XXE 5.6.0 makes a difference between "text/plain" and
>>     "application/xml", while XXE 5.4.0 ignored "application/xml" and
>>     ``sniffed'' the "text/plain" in order the detect the case where this
>>     text was actually XML (starts with "<?xml ").
>>
>>
>> So, we're kind of stuck... because it's not easy (or even possible?)
>> from Javascript to copy stuff to the clipboard, much less being able to
>> specify the media type (text/xml, for example) of the copied object...
>>
>> I'm sure there's a very valid and well thought rationale behind this
>> change, but this is a feature breaker for us...
>>
>> We're currently investigating the possibility to implement a small java
>> applet that will perform this copy-to-clipboard function to replace the
>> JavaScript implemented feature on our UI, but having an applet (on an
>> otherwise html+css+javascript-ONLY UI) just for this is not a very
>> elegant solution.
>>
>> Will keep investigating about JavaScript and the clipboard (which seems
>> rather dead because, mainly, security constraints).
>>
>
> Don't worry, I'm sure we'll manage to solve this problem *cleanly*. So
> please forget about hacks, at least for the moment.
>
> I suggest to simply add a new scriptable method to the XXE applet.
>
> References:
>
> *
> http://www.xmlmind.com/xmleditor/_distrib/doc/configure/integrating_the_applet.html#applet_scripting
>
> *
> http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/applet/Applet.html
>
> This new scriptable method would allow to execute any command on the
> active document view by passing to the applet a command name and a
> command parameter. This mechanism can be used to copy an XML fragment
> to the clipboard or to directly paste something into the active
> document view.
>
> On your JavaScript side:
>
> 1) Do you currently use Scriptable methods?
>
> 2) If the answer is no, why no?
>
> 3) If the answer is yes, do you currently have any  problem (e.g.
> JavaScript security) with this?
>
>
>
>
>
>
>
> -- 
> XMLmind XML Editor Support List
> [email protected]
> http://www.xmlmind.com/mailman/listinfo/xmleditor-support
>
>

-- 
-- 
*NeoDoc*
*Maxime Bégnis*
[email protected]
Tél: +33 (0)4.42.52.24.20
5, rue de la Touloubre
13770 Venelles
France
http://www.neodoc.fr/
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to