Clarity

 View Only
  • 1.  GEL: Use XML-node in new XML to use in XOG

    Posted Nov 21, 2014 10:24 AM

    We are trying to use a GEL script to copy the allocations from an idea to a project.

     

    Via XOG the allocations of an idea retrieved in a variable called XOGoutcome, after which a new XML is formed using the script below:

     

          <gel:parse escapeText="false" var="XOGBody2">
            <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
              <Header version="6.0.11" action="write" objectType="project" externalSource="NIKU"/>
              <Projects>
                <Project name="ProjName" projectID="ProjID">
                  <Resources>

                   <gel:forEach select="$runresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/Ideas/Idea/InvestmentResources/Resource" var="outputnode">
                      <gel:set asString="true" escapeText="true" select="$outputnode" var="v_resource"/>
                      ${v_resource}
                   </gel:forEach>

                  </Resources>
                </Project>
              </Projects>
            </NikuDataBus>
          </gel:parse>

     

    After invoking this XML via soap a call, the call returns a failure, stating : "[Error] :0:0: unexpected character literal"

    When writing the XML (XOGBody2) to the log, the result is:

    <?xml version="1.0" encoding="UTF-8"?>

    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">

      <Header action="write" externalSource="NIKU" objectType="project" version="6.0.11" />

      <Projects>

        <Project name="ProjName" projectID="ProjID">

          &lt;Resources&gt;

            &lt;Resource availFrom="2014-11-01T00:00:00" availTo="2015-01-01T00:00:00" bookingStatus="5" capitalPercentage="0" defaultAllocation="1" isProjectManager="false" lastUpdatedBy="1" lastUpdatedDate="2014-11-18T14:43:02" openForTimeEntry="true" projectRoleID="csk.businessAnalyst" resourceID="csk.businessAnalyst" teamId="csk.businessAnalyst"&gt;

              &lt;AllocCurve /&gt;

              &lt;CustomInformation&gt;

                &lt;ColumnValue name="partition_code"&gt;NIKU.ROOT&lt;/ColumnValue&gt;

              &lt;/CustomInformation&gt;

            &lt;/Resource&gt;

          </Resources>

        </Project>

      </Projects>

    </NikuDataBus>

     

    So the node we paste from the original XML in the new XML has &lt; in stead of < and &gt; in stead of >.

    How can I paste the node form the original XML in a new XML correctly so that the new XML works?

     

    Thanks in advance for your advice.



  • 2.  Re: GEL: Use XML-node in new XML to use in XOG

    Posted Nov 21, 2014 11:07 AM

    Have you tried escapeText="false" ?  (bit of a quick GUESS)



  • 3.  Re: GEL: Use XML-node in new XML to use in XOG
    Best Answer

    Posted Nov 21, 2014 12:27 PM

    Just leave everything as xml nodes.

     

    <?xml version="1.0" encoding="utf-8"?>
    <gel:script
        xmlns:core="jelly:core"
        xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
        <gel:parse var="runresult">
            <SOAP-ENV:Envelope xmlns:obj="http://www.niku.com/xog/Object" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
                <SOAP-ENV:Body>
                    <NikuDataBus>
                        <Ideas>
                            <Idea>
                                <InvestmentResources>
                                    <Resource>One</Resource>
                                    <Resource>Two</Resource>
                                    <Resource>Three</Resource>
                                    <Resource>Four</Resource>
                                </InvestmentResources>
                            </Idea>
                        </Ideas>
                    </NikuDataBus>
                </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
        </gel:parse>
    
        <gel:parse escapeText="false" var="XOGBody2">
            <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
                <Header version="6.0.11" action="write" objectType="project" externalSource="NIKU"/>
                <Projects>
                    <Project name="ProjName" projectID="ProjID">
                        <Resources>
                        </Resources>
                    </Project>
                </Projects>
            </NikuDataBus>
        </gel:parse>
    
        <gel:forEach select="$runresult//InvestmentResources/Resource" var="goo">
            <gel:set select="$XOGBody2//Resources" value="${goo}" insert="true" />
        </gel:forEach>
    
        <gel:log><gel:expr select="$XOGBody2"/></gel:log>
    
          
    </gel:script>
    
    

     

    Log output of XOGBody2:

    ScreenHunter_94 Nov. 21 09.32.png

     

    V/r,

    Gene



  • 4.  Re: GEL: Use XML-node in new XML to use in XOG

    Posted Nov 23, 2014 11:29 PM

    Thanks for sharing this, Gene

     

    NJ



  • 5.  Re: GEL: Use XML-node in new XML to use in XOG

    Posted Nov 25, 2014 07:36 AM

    Yeah, that did the trick!

     

    Thanks very much for your reply.

     

    Michiel Meijler