Syntax for InsertFragmentOperation

Post here questions and problems related to oXygen frameworks/document types.
mboudreau
Posts: 68
Joined: Sat Jan 07, 2017 1:23 am

Syntax for InsertFragmentOperation

Post by mboudreau »

Hello!

I'm trying to create an action that will insert an XML fragment into a document, and some of the fragment's element content must be selected by the user.

This version of my fragment works:

Code: Select all

<article-categories>
  <subj-group subj-group-type="badges">
    <compound-subject>
        <compound-subject-part content-type="code">${ask('Choose badge:', 
          combobox, ('001':'Badge 001'; '002':'Badge 002'), '001', @code)}</compound-subject-part>
        <compound-subject-part content-type="label">You chose: ${answer(@code)}</compound-subject-part>
    </compound-subject>
</subj-group>
</article-categories>
However, this version does not:

Code: Select all

<article-categories>
  <subj-group subj-group-type="badges">
    <compound-subject>
        <compound-subject-part content-type="code">${ask('Choose badge:', 
          combobox, (string(doc('${framework}/resources/badges.xml'))), '001', @code)}</compound-subject-part>
        <compound-subject-part content-type="label">You chose: ${answer(@code)}</compound-subject-part>
    </compound-subject>
</subj-group>
</article-categories>
The file which is the parameter of the 'doc' function looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<badges>
   '001':'Badge 1';
   '002':'Badge 2'
</badges>
What am I doing wrong?
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Syntax for InsertFragmentOperation

Post by Radu »

Hi,

You should use the xpath_eval editor variable to run the XPath, also normalize the text value of the "bagdes" element before returning it, this seemed to work for me:

Code: Select all

<article-categories>
  <subj-group subj-group-type="badges">
    <compound-subject>
        ${ask('Choose badge:', combobox, (${xpath_eval(doc('${framework}/resources/badges.xml')/badges/normalize-space(text()))}), '001', @code)}
        <compound-subject-part content-type="label">You chose: ${answer(@code)}</compound-subject-part>
    </compound-subject>
</subj-group>
</article-categories>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mboudreau
Posts: 68
Joined: Sat Jan 07, 2017 1:23 am

Re: Syntax for InsertFragmentOperation

Post by mboudreau »

Thanks, Radu. That works for me as well.
Post Reply