Link to an href
-
- Posts: 4
- Joined: Fri Jan 13, 2017 7:35 pm
Link to an href
Post by frodos_pants »
Is there a way to generate an id, and populate the href through an action? And if so, is there a way to differentiate cases where you have multiple section with the same class as with "topic" in the example below?
My tagging fragment looks like this:
When I run this, the id generates, but the xpath doesn't populate the href, below is what the action places:
I'm using the xhtml framework. Any thoughts? Please let me know if you need more information to answer this question.
Thanks,
Tom
My tagging fragment looks like this:
Code: Select all
<section class="topic" id="${id}" xmlns="http://www.w3.org/1999/xhtml">
<header>
<h1 class="title"><a href="#${xpath_eval(//section[@class='topic']/div[@class='toggleable']/@id)}" class="toggle">Searching for answers</a></h1>
</header>
<div class="toggleable" id="${id}">
<p><a href="#${xpath_eval(//section[@class='topic']/div[@class='toggleable']/@id)}" class="toggle-close">close</a></p>
</div>
</section>
Code: Select all
<section class="topic" id="ops_ddd_py">
<header>
<h1 class="title"><a href="#" class="toggle">Searching for answers</a></h1>
</header>
<div class="toggleable" id="pps_ddd_py">
<p><a href="#" class="toggle-close">close</a></p>
</div>
</section>
Thanks,
Tom
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Link to an href
Hi Tom,
Unfortunately your approach does not work, the entire XML fragment is inserted at once so the xpath_eval is not evaluated over the content with the fragment inserted.
I think that you first need to define 2 Author actions:
1) The first action uses the InsertFragmentOperation to insert an XML like this:
so it inserts some kind of pattern in the @href value, pattern which will later be replaced by:
2) The second action uses the ChangeAttributeOperation which can locate the proper element using the xpath location and change its value to a value computed using xpath_eval.
So if all goes well. if you invoke both actions one after the other you would get your expected result.
Then:
3) You create a third action using the ExecuteMultipleActionsOperation exemplified here:
https://www.oxygenxml.com/doc/versions/ ... tions.html
So your third action should call the first 2 actions one after the other.
Then on the toolbar/menus you can mount only the third action.
Regards,
Radu
Unfortunately your approach does not work, the entire XML fragment is inserted at once so the xpath_eval is not evaluated over the content with the fragment inserted.
I think that you first need to define 2 Author actions:
1) The first action uses the InsertFragmentOperation to insert an XML like this:
Code: Select all
<section class="topic" id="${id}" xmlns="http://www.w3.org/1999/xhtml">
<header>
<h1 class="title"><a href="#${xpath_eval(//section[@class='topic']/div[@class='toggleable']/@id)}" class="toggle">Searching for answers</a></h1>
</header>
<div class="toggleable" id="${id}">
<p><a href="#PLACE_HOLDER_ID_HERE" class="toggle-close">close</a></p>
</div>
</section>
2) The second action uses the ChangeAttributeOperation which can locate the proper element using the xpath location and change its value to a value computed using xpath_eval.
So if all goes well. if you invoke both actions one after the other you would get your expected result.
Then:
3) You create a third action using the ExecuteMultipleActionsOperation exemplified here:
https://www.oxygenxml.com/doc/versions/ ... tions.html
So your third action should call the first 2 actions one after the other.
Then on the toolbar/menus you can mount only the third action.
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)
- ↳ 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