Issue using appendresult

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi mashers,

I have a problem using <appendresult> to achieve what I want. I know I can do this with a <constructor> in this particular case but I wanted to reduce the amout of code necessary to build up my final variable content.

I want to append a number of nodes to a variable by using appendresult but I get an error as follows:

  XPST0003: XQuery syntax error in #...e variable $out external ; {$#: Unexpected token "{" in path expression

I am trying to append a set of nodes to the end of  a variable before using that variable in a <constructor> further on. The <appendresult> is defined as:

                  <appendresult outputvariable="$mapNodeCore">
                      {$childrenNodes/xml//node}
                  </appendresult>

Say for example $mapNodeCore was:

 <richcontent>

      <html> ...

      </html>

</richcontent>

and $childrenNodes was:

<xml><childNode>
      <node CREATED="1259552952926" ID="ID_1876945138" MODIFIED="1259730106020"
            TEXT="Herd_Id">
         <richcontent TYPE="NOTE">
            <html>
               <head/>
               <body>
                  <p>Herd Identifier</p>
                  <p>Herd_Id</p>
               </body>
            </html>
         </richcontent>
      </node>
   </childNode>
   <childNode>
      <node CREATED="1259552952926" ID="ID_1876945138" MODIFIED="1259730106020"
            TEXT="Herd_Dtl">
         <richcontent TYPE="NOTE">
            <html>
               <head/>
               <body>
                  <p>Additional Details about the herd</p>
                  <p>Herd_Dtl</p>
               </body>
            </html>
         </richcontent>
      </node>
   </childNode></xml>

then what I want to do is add all of the <node> children of $childrenNodes to what is already in $mapNodeCore. Essentially, concatenate those nodes at the end of $mapNodeCore.

What is the easiest or most elegant way to achieve this?

Many thanks, Innes

 

 

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 15 hours 30 min ago. Offline
Joined: 08/29/2008
Points: 34

I didn't try this, so it may need a few tweaks to get exactly what you want. You need to start with a <foreach> that iterates through the <node>s you want to append. Then use <appendresult> inside that. Something like this should get you closer:

<foreach items="$childrenNodes/xml//node" variable="thisNode">
<appendresult outputvariable="$mapNodeCore">
  <node>{$thisNode}</node>
</appendresult>

 

Sara, technical writer/jackbe