Copy paste strips xml:id
Oxygen general issues.
-
- Posts: 58
- Joined: Sat Aug 01, 2009 12:57 am
Re: Copy paste strips xml:id
I found the code responsible for this. I want to override it but still keep some of the behaviour. Basically, if I am copying from the same file I want ids to be stripped but if I copy from other file then I want to keep IDs. I got something working but its not quite what I want.
Code: Select all
@Override
public ClipboardFragmentProcessor getClipboardFragmentProcessor() {
final ClipboardFragmentProcessor originalImplementation = super.getClipboardFragmentProcessor();
return new Docbook5UniqueAttributesRecognizer()
{
/**
* @see ro.sync.ecss.extensions.api.content.ClipboardFragmentProcessor#process(ro.sync.ecss.extensions.api.content.ClipboardFragmentInformation)
*/
@Override
public void process(ClipboardFragmentInformation fragmentInformation) {
if(!fragmentInformation.getFragment().isEmpty() &&
fragmentInformation.getFragment().getContentNodes().size() > 0 &&
fragmentInformation.getFragment().getContentNodes().get(0).getName() == "table") {
// do not strip ids for tables
}
else
originalImplementation.process(fragmentInformation);
}
};
}
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Copy paste strips xml:id
Hi Mike,
You are on the right path.
Maybe you can look at the Java code (which is available in the SDK) for the:
ro/sync/ecss/extensions/commons/id/DefaultUniqueAttributesRecognizer.java
and see how the method:
public void process(ClipboardFragmentInformation fragmentInformation)
is implemented.
The code which decides the IDs will be stripped in the target file is this:
Regards,
Radu
You are on the right path.
Maybe you can look at the Java code (which is available in the SDK) for the:
ro/sync/ecss/extensions/commons/id/DefaultUniqueAttributesRecognizer.java
and see how the method:
public void process(ClipboardFragmentInformation fragmentInformation)
is implemented.
The code which decides the IDs will be stripped in the target file is this:
Code: Select all
.................
if(fragmentInformation.getFragmentOriginalLocation() != null
&& ! fragmentInformation.getFragmentOriginalLocation().equals(authorAccess.getEditorAccess().getEditorLocation().toString())) {
//Paste from another document. Remove the IDs
removeUniqueIDs = true;
}
................
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 58
- Joined: Sat Aug 01, 2009 12:57 am
Re: Copy paste strips xml:id
Thanks. Yes I saw that code. What I don't know is how do I change the condition
in such a way so it returns true when copying from the same file and false when copying from another file opened in the same Editor.
Code: Select all
fragmentInformation.getFragmentOriginalLocation().equals(authorAccess.getEditorAccess().getEditorLocation().toString())
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Copy paste strips xml:id
Hi Mike,
The fragmentInformation.getFragmentOriginalLocation() represents the URL from where the fragment was cut/copied or dragged.
And authorAccess.getEditorAccess().getEditorLocation() represents the URL of the current editor in which the fragment is pasted or dropped.
So just reverse the condition like:
Actually we've discussed and in the next version we'll also change the default implementation bundled with Oxygen not to remove IDs when pasting to other files.
Regards,
Radu
The fragmentInformation.getFragmentOriginalLocation() represents the URL from where the fragment was cut/copied or dragged.
And authorAccess.getEditorAccess().getEditorLocation() represents the URL of the current editor in which the fragment is pasted or dropped.
So just reverse the condition like:
Code: Select all
.................
if(fragmentInformation.getFragmentOriginalLocation() != null
&& ! fragmentInformation.getFragmentOriginalLocation().equals(authorAccess.getEditorAccess().getEditorLocation().toString())) {
//Paste from another document. Do not remove the IDs
removeUniqueIDs = false;
}
................
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service