[Xsltforms-support] injecting XML element(s) at cursor position in text area?
Brought to you by:
alain-couthures
From: C. M. Sperberg-M. <cm...@bl...> - 2016-09-03 15:06:10
|
When displaying nodes in input widgets or text widgets, is there a way to insert an XML element at the user's current cursor position, if they press a button? What I have in mind is similar to the buttons labeled 'ul', 'ol', 'li', 'b' in some in-browser HTML editors, which insert the indicated tag into a text box at the user's current cursor position in that box. I am not at the moment trying to allow the user to edit mixed content (so I don't think TinyMCE is what I want); what I want is to display an element which needs to be split in two and allow the user to tell me where to split it. For example, I might have a program that guesses where sentence boundaries occur in a text, and want to build an XForm to allow a user to correct the sentence tagging. The automatic sentence tagger can make two kinds of mistakes: 1) False positive: It can place a sentence boundary where it shouldn't. So in front of every sentence element except the first in a paragraph, I'll want a button saying "merge", meaning "merge this sentence element with the preceding sentence element", to correct this error. 2) False negative: it can fail to place a sentence boundary where it should. So I'd like to be able to allow the user to click within a single sentence element to place the cursor, then click a button which means "split this sentence element here." Ideally, I don't want them to be able to change the text, only to indicate a place and say "split here." As another example: if my project is marking boundaries between the morphemes in a word, I want to handle transcription of the document in one step, and in a second step ask the users to segment each word into morphemes. The same two operations are needed: split this element here, and (to undo mistakes) join these two elements. I am willing to accept the insertion of an empty element meaning 'segment-boundary-here' as a substitute for splitting the element, because I can always use XSLT to detect the empty boundary elements and perform the splits. Is there any way to do this with XForms (and more specifically with XSLTForms)? If I can't find a way to do this, I suppose I'll end up either (a) giving the user an input widget and saying "insert a * at each morpheme boundary", and rejecting input in which anything has changed other than insertion of *, or (b) displaying the word o n e l e t t e r a t a t i m e, with buttons between them saying "split here". (But doing a whole sentence at a time with that interface would be very awkward.) Thanks for any help anyone here can provide. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net **************************************************************** |