InsertFragmentOperation from css button

Oxygen general issues.
Doug
Posts: 28
Joined: Sat Jun 15, 2013 1:34 am

InsertFragmentOperation from css button

Post by Doug »

Hi All,

I'm having trouble with inserting a fragment into the correct location using oxy_action inside oxy_button from the content property of a css style. I can't get the fragment to be inserted in the desired location and it instead goes into a location that makes no sense to me. My document and style look approximately like below. I want to have a button that adds new <socm> element after the one already in the index so that it becomes the last child of the wrapping <seeie> element. The document is valid against a modified docbook relaxng schema. I can get the button to appear where I want: after the <socm> element that is the last-child of the <seeie> element, but I don't get the expected insert results from my arg-insertLocation and arg-insertPosition arguments, of '.' and 'After', respectively. Instead of going in where I want it, the <socm> element goes in after the </index> tag. I can't make sense of this from any interpretation of where my current node may be. I have tried insert my cursor in all sorts of specific locations and watching the path of my location but that doesn't make a difference, which raises the question of what controls my current node location when I click the button? I am thinking it is the location of the button.

I get a very similar pattern in other places where I have put similar buttons e.g. adding <para>s in articles go in after the </article> tag not after the current <para>. Some combos of arg-insertLocation and arg-insertPosition work the way that makes sense to me, e.g., "." and 'Inside as last child' or 'Inside as first child' put the new <socm> inside the current <socm>. I want it after the current <socm> inside the current <seeie>.

Funny thing is that I thought I had a slightly different version of this working properly before, but perhaps I was seeing things. I've tried every alternative and workaround I can think of this time around.

Thanks, Doug

Here's my approximate document:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<book xmlns="http://docbook.org/ns/docbook">
<title>Book<title>
<article>
<title>Article</title>
<para>Blah blah</para>
</article>
<index hrafid="a000-000-index" ocms="104">
<title>INDEXING NOTES </title>
<indexentry>
<primaryie>
<glossterm/>
<modifier/>
<termdef/>
</primaryie>
<seeie>
<termdef/>
<socm code="101"/><!-- Button appears here at the :after pseudo element of the <socm> -->
</seeie>
<!-- I want to insert an new <socm> element here-->
</indexentry>
</index>
<!-- Instead the new <socm> element goes here -->
<bibliography>
<bibliomixed>
Blah blah
</bibliomixed>
</bibliography>
</book>
And here is my style (I've tested that this style is being referenced by the <socm> element above :

Code: Select all


seeie>socm:last-child::after {
display: block;
content: oxy_button(color, 'blue',
action, oxy_action(
name, '+',
description, 'Add an OCM to this set',
icon, url('insert.png'),
operation, InsertFragmentOperation,
arg-fragment, '<socm xmlns="http://docbook.org/ns/docbook" code="000"/>',
arg-insertLocation, '.',
arg-insertPosition, 'After'
));
}
Radu
Posts: 8991
Joined: Fri Jul 09, 2004 5:18 pm

Re: InsertFragmentOperation from css button

Post by Radu »

Hi Doug,

This kind of behavior usually happens when Oxygen considers that the XML cannot be inserted at the place where you want it (it considers that the XML would become invalid according to the schema if the fragment is inserted there) so it proceeds to apply a strategy and move the fragment to the closest location where it would be allowed in the edited XML.
Could you also provide us the modified schema via email (support@oxygenxml.com)? It may be the key to understanding the behavior.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Doug
Posts: 28
Joined: Sat Jun 15, 2013 1:34 am

Re: InsertFragmentOperation from css button

Post by Doug »

Hi Radu, I've just got this working now. I don't think it was because the insertion place would have been invalid. I had considered that and I tried to make sure that wasn't what was happening. And I've made no changes in the schema before getting this working. I've also at times suspected the specificity of the styles but I think ruled that out too.

It was an odd sequence of events that led to me getting this to work so I don't have a solid idea of what made the difference. Oxygen froze on me, and I had to kill it with Window task manager. When I restarted Oxygen after killing it my styles worked. This is despite that thinking that there might be some sort of memory corruption I had previously tried both restarting Oxygen and even restarting my whole machine with no fix to my problem.

Could there be some sort of serialization of my document object that had been corrupted and was not deleted with my restarts but was with the crash? I answered yes to the prompt to load my documents from my previous session before the crash, when restarting after the crash.

Maybe I wasn't seeing things when I thought the styles were working earlier on.

I've lived more than long enough to know that the cause of some events will always remain a mystery to me and I'm just happy this is working now and willing to pretend that problem never happened (well I am still curious and a little apprehensive it will fail again in the future). :lol:

Thanks for your help,
Doug
Radu
Posts: 8991
Joined: Fri Jul 09, 2004 5:18 pm

Re: InsertFragmentOperation from css button

Post by Radu »

Hi Doug,

For most changes you make to a CSS, to an Author action or to a schema associated to an opened XML Oxygen does not need to be restarted, at most you can press the F5 keyboard shortcut to reload the XML and re-detect configuration changes. Maybe Oxygen had some old session-persistent cache in place related to the schema it used to test if the XML fragment could be inserted there, so restarting Oxygen solved the problem.
I also don't like the fact that Oxygen froze and had to be manually killed, if you happen to find a way to consistently reproduce this behavior I'm interested in knowing this.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply