CSS background color based on text matches

Hi, We've had a request from an author to make the formatting in the Author view indicate when the text of a certain element type does not match the text of something else found inside the same topic. I can do this via Oxygen CSS, but I am concerned that the processing slows down the opening of large documents. I'm not convinced that CSS is a good way to address the underlying requirement about helping authors detect when something does not have a textual match as expected (e.g., maybe Schematron or a build warning would be more appropriate). Before I give up, though, I wanted to see if anyone had specific ideas or techniques I might have overlooked. Here's an example of variations I tried that work too slowly in large documents, just to give you the flavor. /* true => 255*1 => white * false => 255*0 => yellow */ refentry[role="function"] literal { background-color: oxy_xpath( "concat('rgb(255,255,', 255 * number(. = ancestor::refentry//term or .='') , ')')", evaluate,dynamic-once); } Alternate: refentry[role="function"] literal { background-color: oxy_xpath( "if (exists(text()) and not(some $n in ancestor::refentry/refsect1[@role=('inputs','outputs')]//term satisfies string($n)=.)) then ('yellow') else ('')", evaluate,dynamic-once); } Thanks, Amanda

Hi Amanda Can you use XSD1.1 instead of Schematron? Thank you. Bob Robert C. Leif, Ph.D. rleif@rleif.com From: oXygen-user <oxygen-user-bounces@oxygenxml.com> On Behalf Of Amanda Galtman Sent: Friday, March 9, 2018 10:47 AM To: oxygen-user@oxygenxml.com Subject: [oXygen-user] CSS background color based on text matches Hi, We've had a request from an author to make the formatting in the Author view indicate when the text of a certain element type does not match the text of something else found inside the same topic. I can do this via Oxygen CSS, but I am concerned that the processing slows down the opening of large documents. I'm not convinced that CSS is a good way to address the underlying requirement about helping authors detect when something does not have a textual match as expected (e.g., maybe Schematron or a build warning would be more appropriate). Before I give up, though, I wanted to see if anyone had specific ideas or techniques I might have overlooked. Here's an example of variations I tried that work too slowly in large documents, just to give you the flavor. /* true => 255*1 => white * false => 255*0 => yellow */ refentry[role="function"] literal { background-color: oxy_xpath( "concat('rgb(255,255,', 255 * number(. = ancestor::refentry//term or .='') , ')')", evaluate,dynamic-once); } Alternate: refentry[role="function"] literal { background-color: oxy_xpath( "if (exists(text()) and not(some $n in ancestor::refentry/refsect1[@role=('inputs','outputs')]//term satisfies string($n)=.)) then ('yellow') else ('')", evaluate,dynamic-once); } Thanks, Amanda

Bob, Thanks for the idea. Our schema uses RelaxNG, though, so it would be a big change to switch to XSD. The text matching enhancement that was requested would not, by itself, be enough motivation. Regards, Amanda From: Robert Leif [mailto:rleif@rleif.com] Sent: Friday, March 09, 2018 11:45 PM To: Amanda Galtman <Amanda.Galtman@mathworks.com>; oxygen-user@oxygenxml.com Subject: RE: [oXygen-user] CSS background color based on text matches Hi Amanda Can you use XSD1.1 instead of Schematron? Thank you. Bob Robert C. Leif, Ph.D. rleif@rleif.com<mailto:rleif@rleif.com> From: oXygen-user <oxygen-user-bounces@oxygenxml.com<mailto:oxygen-user-bounces@oxygenxml.com>> On Behalf Of Amanda Galtman Sent: Friday, March 9, 2018 10:47 AM To: oxygen-user@oxygenxml.com<mailto:oxygen-user@oxygenxml.com> Subject: [oXygen-user] CSS background color based on text matches Hi, We've had a request from an author to make the formatting in the Author view indicate when the text of a certain element type does not match the text of something else found inside the same topic. I can do this via Oxygen CSS, but I am concerned that the processing slows down the opening of large documents. I'm not convinced that CSS is a good way to address the underlying requirement about helping authors detect when something does not have a textual match as expected (e.g., maybe Schematron or a build warning would be more appropriate). Before I give up, though, I wanted to see if anyone had specific ideas or techniques I might have overlooked. Here's an example of variations I tried that work too slowly in large documents, just to give you the flavor. /* true => 255*1 => white * false => 255*0 => yellow */ refentry[role="function"] literal { background-color: oxy_xpath( "concat('rgb(255,255,', 255 * number(. = ancestor::refentry//term or .='') , ')')", evaluate,dynamic-once); } Alternate: refentry[role="function"] literal { background-color: oxy_xpath( "if (exists(text()) and not(some $n in ancestor::refentry/refsect1[@role=('inputs','outputs')]//term satisfies string($n)=.)) then ('yellow') else ('')", evaluate,dynamic-once); } Thanks, Amanda

Dear Amanda, Using Schematron for validating these requirements is indeed a better approach because the validation is done on a separate execution thread and doesn't affect the layout.When a rule is broken, the visual indicator is a squiggly yellow line (or red, if you want to mark it as an error) which is pretty close to the way you are currently marking the element in the CSS rule (a yellow background). A CSS rule will give you more options on how to mark the error: colors, borders etc. Do you find the Schematron error marking (the yellow squiggly underline) enough or you would prefer to be able to change it to something else? Another option would be to use our Java based API and set a StylesFilter [1] and change the background color from there. In such an extension point you can directly navigate the author node model which is faster than executing an XPath. [1] https://www.oxygenxml.com/doc/versions/19.1/ug-editor/topics/dg-author-css-s... Best regards, Alex -- Alex Jitianu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 3/9/2018 8:47 PM, Amanda Galtman wrote:
Hi,
We’ve had a request from an author to make the formatting in the Author view indicate when the text of a certain element type does not match the text of something else found inside the same topic. I can do this via Oxygen CSS, but I am concerned that the processing slows down the opening of large documents. I’m not convinced that CSS is a good way to address the underlying requirement about helping authors detect when something does not have a textual match as expected (e.g., maybe Schematron or a build warning would be more appropriate).
Before I give up, though, I wanted to see if anyone had specific ideas or techniques I might have overlooked.
Here’s an example of variations I tried that work too slowly in large documents, just to give you the flavor.
/* true => 255*1 => white * false => 255*0 => yellow */ refentry[role="function"]literal{ background-color:oxy_xpath( "concat('rgb(255,255,', 255 * number(. = ancestor::refentry//term or .='') , ')')", evaluate,dynamic-once); }
Alternate:
refentry[role="function"]literal{ background-color:oxy_xpath( "if (exists(text()) and not(some $n in ancestor::refentry/refsect1[@role=('inputs','outputs')]//term satisfies string($n)=.)) then ('yellow') else ('')", evaluate,dynamic-once); }
Thanks,
Amanda
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user

Thanks, Alex, for the suggestions. The part about validation being a separate execution thread is useful to know. I think the format of Schematron errors/warnings is close enough for this purpose. The main reason for starting with CSS was to try matching an earlier (pre-Oxygen) authoring environment behavior. I'll keep the StylesFilter idea in mind in case Schematron does not work out for some reason - and also for future tasks where StylesFilter might provide a good solution. Regards, Amanda From: oXygen-user [mailto:oxygen-user-bounces@oxygenxml.com] On Behalf Of Alex Jitianu Sent: Monday, March 12, 2018 4:33 AM To: oxygen-user@oxygenxml.com Subject: Re: [oXygen-user] CSS background color based on text matches Dear Amanda, Using Schematron for validating these requirements is indeed a better approach because the validation is done on a separate execution thread and doesn't affect the layout.When a rule is broken, the visual indicator is a squiggly yellow line (or red, if you want to mark it as an error) which is pretty close to the way you are currently marking the element in the CSS rule (a yellow background). [cid:image001.png@01D3BA9C.90F387E0] A CSS rule will give you more options on how to mark the error: colors, borders etc. Do you find the Schematron error marking (the yellow squiggly underline) enough or you would prefer to be able to change it to something else? Another option would be to use our Java based API and set a StylesFilter [1] and change the background color from there. In such an extension point you can directly navigate the author node model which is faster than executing an XPath. [1] https://www.oxygenxml.com/doc/versions/19.1/ug-editor/topics/dg-author-css-styles-filter.html<https://www.oxygenxml.com/doc/versions/19.1/ug-editor/topics/dg-author-css-styles-filter.html> Best regards, Alex -- Alex Jitianu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com<http://www.oxygenxml.com> On 3/9/2018 8:47 PM, Amanda Galtman wrote: Hi, We've had a request from an author to make the formatting in the Author view indicate when the text of a certain element type does not match the text of something else found inside the same topic. I can do this via Oxygen CSS, but I am concerned that the processing slows down the opening of large documents. I'm not convinced that CSS is a good way to address the underlying requirement about helping authors detect when something does not have a textual match as expected (e.g., maybe Schematron or a build warning would be more appropriate). Before I give up, though, I wanted to see if anyone had specific ideas or techniques I might have overlooked. Here's an example of variations I tried that work too slowly in large documents, just to give you the flavor. /* true => 255*1 => white * false => 255*0 => yellow */ refentry[role="function"] literal { background-color: oxy_xpath( "concat('rgb(255,255,', 255 * number(. = ancestor::refentry//term or .='') , ')')", evaluate,dynamic-once); } Alternate: refentry[role="function"] literal { background-color: oxy_xpath( "if (exists(text()) and not(some $n in ancestor::refentry/refsect1[@role=('inputs','outputs')]//term satisfies string($n)=.)) then ('yellow') else ('')", evaluate,dynamic-once); } Thanks, Amanda _______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com<mailto:oXygen-user@oxygenxml.com> https://www.oxygenxml.com/mailman/listinfo/oxygen-user<https://www.oxygenxml.com/mailman/listinfo/oxygen-user>
participants (3)
-
Alex Jitianu
-
Amanda Galtman
-
Robert Leif