Chain $ask, $answer and combobox
Oxygen general issues.
-
- Posts: 15
- Joined: Fri Mar 29, 2019 12:25 am
Chain $ask, $answer and combobox
Hello everybody!
(sorry if the question is already dealt with elsewhere, I was not able to find it)
Working on TEI xml files, I am trying to create a function that will prompt the user to give an input and then use the latter to look up for references in an external file. I am not sure if I am concerned with the bug on xpath_eval and ${answer(@id)} (post51917.html)
In this case, the following operations may be chained? I guess one could use insertFragment (e.g. <bibl xmlns="http://www.tei-c.org/ns/1.0">${caret}</bibl>), then ChangeAttribute (and give an input into @sameAs), then base a query based on this intermediary attribute with another ChangeAttribute operation (e.g.
but I am failing with addressing the current element and deal with the necessary quotes and concatenation of value and labels
Is there a way to use ${answer(@id)} in a single function?
As a comparison, in the associated CSS, it is possible to have
(1) the display of the full reference from the attribute
(2) a combobox with a list of all references to choose from:
With the latter, one get the full list, which I would like to reduce by prompting the user to input a string.
Thanks for any help you can offer!
Dominique
(sorry if the question is already dealt with elsewhere, I was not able to find it)
Working on TEI xml files, I am trying to create a function that will prompt the user to give an input and then use the latter to look up for references in an external file. I am not sure if I am concerned with the bug on xpath_eval and ${answer(@id)} (post51917.html)
In this case, the following operations may be chained? I guess one could use insertFragment (e.g. <bibl xmlns="http://www.tei-c.org/ns/1.0">${caret}</bibl>), then ChangeAttribute (and give an input into @sameAs), then base a query based on this intermediary attribute with another ChangeAttribute operation (e.g.
Code: Select all
${ask(
'Choose reference',
combobox,
(
'${xpath_eval(doc('${cfdu}/biblio.xml')//biblStruct[contains(., current-node()/@sameAs)][1]/@xml:id)}':'${xpath_eval(doc('${cfdu}/biblio.xml')//biblStruct[contains(., current-node()/@sameAs)][1]/@xml:id)}';
'${xpath_eval(doc('${cfdu}/biblio.xml')//biblStruct[contains(., current-node()/@sameAs)][2]/@xml:id)}':'${xpath_eval(doc('${cfdu}/biblio.xml')//biblStruct[contains(., current-node()/@sameAs)][2]/@xml:id)}';
'${xpath_eval(doc('${cfdu}/biblio.xml')//biblStruct[contains(., current-node()/@sameAs)][3]/@xml:id)}':'${xpath_eval(doc('${cfdu}/biblio.xml')//biblStruct[contains(., current-node()/@sameAs)][3]/@xml:id)}'
),
'Three first references')}
Is there a way to use ${answer(@id)} in a single function?
As a comparison, in the associated CSS, it is possible to have
(1) the display of the full reference from the attribute
Code: Select all
bibl[sameAs]{
content:oxy_xpath(
oxy_concat(
"doc('${cfdu}/biblio.xml')//listBibl/biblStruct[@xml:id='", attr(sameAs),"']/normalize-space(string())"
)
);
}
Code: Select all
bibl:after{
content:"Reference"
oxy_popup(edit, '@sameAs',
values,
oxy_xpath(oxy_concat('string-join(doc("', oxy_url('${cfdu}/biblio.xml'), '")//listBibl/biblStruct/@xml:id, ",")')),
selectionMode, single,
labels,
oxy_xpath(oxy_concat('string-join(doc("', oxy_url('${cfdu}/biblio.xml'), '")//listBibl/biblStruct[@xml:id]/replace(normalize-space(*[1]), ",", "|"), ",")'))
)
}
Thanks for any help you can offer!
Dominique
-
- Posts: 417
- Joined: Mon May 09, 2016 9:37 am
Re: Chain $ask, $answer and combobox
Post by sorin_carbunaru »
Dear Dominique,
I don't have a solution for getting the current node inside an XPath expression, though. I will add an issue to offer a custom function for that.
Best wishes!
According to your description, I would say that the aforementioned bug will indeed affect you. What happens is that xpath_eval functions are evaluated before $ask functions so if your xpath_eval uses an $ask or an $answer it will give incorrect results.Working on TEI xml files, I am trying to create a function that will prompt the user to give an input and then use the latter to look up for references in an external file. I am not sure if I am concerned with the bug on xpath_eval and ${answer(@id)} (post51917.html)
In this case, the $ask is inside the "value" parameter of an ChangeAttributeOperation, right? To solve the quotes/apostrophe issue, you can use apostrophes on the outside and quotes for the doc function.but I am failing with addressing the current element and deal with the necessary quotes and concatenation of value and labels
Code: Select all
'${xpath_eval(doc("${cfdu}/biblio.xml")//biblStruct[contains(., current-node()/@sameAs)][1]/@xml:id)}'
Perhaps I can offer an alternative. What if you keep using a form control but this time an editable combo box that present just 3 entries, like this:With the latter, one get the full list, which I would like to reduce by prompting the user to input a string.
Code: Select all
bibl:after {
content: "Reference"
oxy_combobox(edit, '@sameAs',
values,
oxy_xpath(oxy_concat('string-join(doc("', oxy_url('${cfdu}/biblio.xml'), '")//listBibl/biblStruct/@xml:id, ",")[position() >= 1 and position() <= 3]')),
editable, true,
labels,
oxy_xpath(oxy_concat('string-join(doc("', oxy_url('${cfdu}/biblio.xml'), '")//listBibl/biblStruct[@xml:id]/replace(normalize-space(*[1]), ",", "|"), ",")[position() >= 1 and position() <= 3]'))
)
}
-
- Posts: 15
- Joined: Fri Mar 29, 2019 12:25 am
Re: Chain $ask, $answer and combobox
Dear Sorin,
thank you so much for your answer which has really helped me forward in the last few days.
From your comments on CSS, I have some more question, but I will open an new topic.
For this one, if we try to go around $answer, I wonder if one can integrate $ask within $ask.
Indeed the following works fine, with a combobox generated from an external file with a condition (here, contains a string)
but apparently one cannot integrate $ask as part of the condition, or not as follows
Is there here a way forward?
Thanks again, so much!
thank you so much for your answer which has really helped me forward in the last few days.
From your comments on CSS, I have some more question, but I will open an new topic.
For this one, if we try to go around $answer, I wonder if one can integrate $ask within $ask.
Indeed the following works fine, with a combobox generated from an external file with a condition (here, contains a string)
Code: Select all
${ask(
'Choose reference',
combobox,
('${xpath_eval(string-join(doc("${cfdu}/biblio.xml")//listBibl/biblStruct[contains(@xml:id, "1958")]/concat(@xml:id, "':'", normalize-space(string-join(descendant::*, ", "))), "';'"))}'),
'List of references')
}
Code: Select all
${ask(
'Choose reference',
combobox,
('${xpath_eval(string-join(doc("${cfdu}/biblio.xml")//listBibl/biblStruct[contains(., ${ask('search', generic, 'input')})]/concat(@xml:id, "':'", normalize-space(string-join(descendant::*, ", "))), "';'"))}'),
'List of references')
}
Thanks again, so much!
-
- Posts: 417
- Joined: Mon May 09, 2016 9:37 am
Re: Chain $ask, $answer and combobox
Post by sorin_carbunaru »
Hi again, Dominique,
Unfortunately there is no way forward on this path... There should be in the future, after we take care of some things, among which is the bug from the post you mentioned in the beginning.
Another approach you could take is to create your own AuthorOperation (see http://ctalau.github.io/userguide/tasks ... HowTo.html), if it sounds appealing to you...
Sorin C.
Unfortunately there is no way forward on this path... There should be in the future, after we take care of some things, among which is the bug from the post you mentioned in the beginning.
Another approach you could take is to create your own AuthorOperation (see http://ctalau.github.io/userguide/tasks ... HowTo.html), if it sounds appealing to you...
Sorin C.
-
- Posts: 15
- Joined: Fri Mar 29, 2019 12:25 am
Re: Chain $ask, $answer and combobox
Thank you for the answer and for pointing me to a possible solution. I am looking forward to the future improvements. Will you then consider to integrate conditions with other Oxygen editor variables such as ${selection} as well ?
-
- Posts: 417
- Joined: Mon May 09, 2016 9:37 am
Re: Chain $ask, $answer and combobox
Post by sorin_carbunaru »
Yes, we want so support all kinds of meaningful combinations of editor variables.
-
- Posts: 417
- Joined: Mon May 09, 2016 9:37 am
Re: Chain $ask, $answer and combobox
Post by sorin_carbunaru »
Hello,
Just wanted to announce that oXygen 21.1 has just been released a few hours ago, and it has an improved way of dealing with editor variables.
Best wishes,
Sorin Carbunaru
oXygen XML
Just wanted to announce that oXygen 21.1 has just been released a few hours ago, and it has an improved way of dealing with editor variables.
Best wishes,
Sorin Carbunaru
oXygen XML
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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