Structural variation while inserting fragment based on user input
Post here questions and problems related to oXygen frameworks/document types.
Structural variation while inserting fragment based on user input
Hello,
In a framework operation, I am trying to let the user determine the number of children a fragment would have.
For example, take the following fragment:
I am inserting user input by replacing "Name" and "Title" with ${ask('...',generic,'')}.
Now I want to split the input for artist along the commas so that user input "Robert Plant, Jimmy Page, Eric Clapton" would translate into three separate <artist> elements:
I tried using xpath_eval with a for loop on tokenize of the ${ask()}, but it brought no output:
I may have made some mistakes in the code, but I may also have misunderstood some limitation.
Is there a way to do what I an trying to do?
Thank you in advance,
Alexey
In a framework operation, I am trying to let the user determine the number of children a fragment would have.
For example, take the following fragment:
Code: Select all
<cd>
<artist>Name</artist>
<title>Title</title>
</cd>
Now I want to split the input for artist along the commas so that user input "Robert Plant, Jimmy Page, Eric Clapton" would translate into three separate <artist> elements:
Code: Select all
<cd>
<artist>Robert Plant</artist>
<artist>Jimmy Page</artist>
<artist>Eric Clapton</artist>
<title>Title</title>
</cd>
Code: Select all
${xpath_eval(for $i in tokenize(${ask('Artists:',generic,'')}) return <artist>$i</artist>)}
Is there a way to do what I an trying to do?
Thank you in advance,
Alexey
Re: Structural variation while inserting fragment based on user input
HI Alexey,
I managed to make things work with something like this:
I added quotes in the tokenize function value and I also returned the XML tags as plain text instead of XML nodes.
The xpath_eval was never intended to do such heavy lifting, maybe for more complex actions you can orient yourself towards implementing them in Java or in Javascript like these sample operations:
https://github.com/oxygenxml/javascript ... operations
Regards,
Radu
I managed to make things work with something like this:
Code: Select all
${xpath_eval(for $i in tokenize("${ask('Artists:',generic,'')}") return concat("<artist>", $i, "</artist>"))}
The xpath_eval was never intended to do such heavy lifting, maybe for more complex actions you can orient yourself towards implementing them in Java or in Javascript like these sample operations:
https://github.com/oxygenxml/javascript ... operations
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Structural variation while inserting fragment based on user input
Hi Radu,
Thank you, that worked for me (after I added the token (comma) for tokenize, which I had forgotten to include in the code snippet)!
And thank you for the nudge towards JS and J.
Thank you, that worked for me (after I added the token (comma) for tokenize, which I had forgotten to include in the code snippet)!
And thank you for the nudge towards JS and J.
Return to “SDK-API, Frameworks - Document Types”
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