Clarity PPM1

Expand all | Collapse all

Project XOG error , when project name has "&" in it

Jump to Best Answer
  • 1.  Project XOG error , when project name has "&" in it

    Posted 05-05-2017 09:19 AM

    Hi,

      I am a getting an error while doing Project xog.

     

      purpose of project xog I am doing is  changing the financial status of project . anyone has this issue before .

    what is the workaround , as we have serveral projects with & in the name .

    clarity version is 14.3

     any possible solutions other than changing project name ?

     

    sample xog I am using .below ..

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
            <Header action="write" externalSource="NIKU" objectType="project" version="14.3.0.298"/>
            <Projects>
              <Project financialStatus="C" name="Project1 ****** Phase 2 A&D" projectID="PRJ59731"/>
            </Projects>
    </NikuDataBus>



  • 2.  Re: Project XOG error , when project name has "&" in it
    Best Answer

    Posted 05-05-2017 09:53 AM

    & is an XML reserved thing - you just need to replace it in the XML you are trying to XOG in with &amp;

     

    i.e.

    <Project financialStatus="C" name="Project1 ****** Phase 2 A&amp;D" projectID="PRJ59731"/>



  • 3.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 02:16 AM

    Hi David,

       i have some other problem in the same task .

      

      have to read project info (name,code) from DB  and need to change the financial status to close using xog from the same gel script .  what ever the actions I do  , finally it is coming to project name in xml as   xxxxx;&amp;amp;xxxx .

     

    I did the following actions .

    step - 1 :

     replace(inv.name,chr(38),chr(38)||'amp;') proj_name,inv.code proj_code
          from
          inv_investments inv
          where inv.id=555555

    step-2 :

      

    <core:forEach items="${prjdet.rowsByIndex}" var="rowinit">
        <core:set var="proj_name_t">${rowinit[0]}</core:set>
        <core:set var="proj_code">${rowinit[1]}</core:set>

    /*    below statements to replace ;&amp;amp;    as   ;&amp;      

      this I have used as  directly using proj_name also giving ;&amp;amp;     */


    <util:replace old=";amp;" new=";" var="proj_name" value="${proj_name_t}"/>>

     

       <gel:parse var="xogBody">
      
          <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
            <Header action="write" externalSource="NIKU" objectType="project" version="14.3.0.298"/>
            <Projects>
              <Project financialStatus="C" name="test" projectID="${proj_code}"/>
            </Projects>
          </NikuDataBus>
      
        </gel:parse>

    <gel:set select="$xogBody/NikuDataBus/Projects/Project/@name" value="${proj_name}" />

    /*   tried above get:set  if it gives correct text  .. still showing &amp;amp;   */

     

     

    after this also I am getting still   &amp;amp;    in the name ..

     

     

    Please suggetst any working way ..

     

    last option I have is first loading some other project name  , later with sql update script  giving its actual name .



  • 4.  Re: Project XOG error , when project name has "&" in it

    Posted 05-10-2017 04:43 AM

    Hello Ravinder,

     

    try replacing your code

    <core:forEach items="${prjdet.rowsByIndex}" var="rowinit">
        <core:set var="proj_name_t">${rowinit[0]}</core:set>
        <core:set var="proj_code">${rowinit[1]}</core:set>

    with:

    <core:forEach items="${prjdet.rowsByIndex}" var="prjdet_row">
          <core:set value="${prjdet_row.proj_name}" var="proj_name_t"/>
          <core:set value="${prjdet_row.proj_code}" var="proj_code"/>

     

    This works for me everytime.

     

    Hope this helps,

    Martin



  • 5.  Re: Project XOG error , when project name has "&" in it

    Posted 05-11-2017 03:59 AM

    Thanks Martin for the clue ,

     

    I got the problem fixed with small correction to your suggestion ...

     

    correct answer is .

     

    <core:forEach items="${prjdet.rows}" var="prjdet_row">
          <core:set value="${prjdet_row.proj_name}" var="proj_name_t"/>
          <core:set value="${prjdet_row.proj_code}" var="proj_code"/>


  • 6.  Re: Project XOG error , when project name has "&" in it

    Posted 05-11-2017 04:03 AM

    You are right, I missed to change it during copying it

     

    Great that it helped.



  • 7.  Re: Project XOG error , when project name has "&" in it

    Posted 05-05-2017 09:53 AM


  • 8.  Re: Project XOG error , when project name has "&" in it

    Posted 05-07-2017 07:34 PM

    Hi Ravinder,

     

    Came across few useful KB articles around the XOG and Special Characters. 

    Find below the KB articles:

     

    XML special characters causing XOG error

    Remove Special Characters from .xml files used with XOG

     

     

    Regards,

    Srikanth G



  • 9.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 03:43 AM

    Correct me if I am wrong, but those two KB articles just tell you that the reserved characters cause a problem and help in locating them. The suggested solution is to rename the items with names that do not have those reserved characters (ie create new items). That is not feasible if the system already has the names with the reserved characters as there is no restriction to create them in the GUI. and read them with XOG.

     

    A better solution IMHO is to fix the GUI so that it warns the user when trying to use a reserved character where it could cause a problem. That is to solve the problem before it occurs.

     

    Secondly it is already known what are the reserved characters and how they can be replaced with escape codes.

    A good KB article would list the reserved characters and their escape codes so that the items are not renamed in XOGing

     

    Further the good KB article would also list how to replace the reserved characters in gel script and in sql contained in gel scripts.



  • 10.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 04:09 AM

    Hi,

      thanks for the reply .

      I got to know the reserved characters , escape codes  .

     if it is by manual xog , I should  be able to replace the reserved with escape codes , so the xog will not give any problem .

     

    now my problem is ,

    • I have a automated process that will close the project financially using gel script .
    • recently we are getting error when we the process is running for the projects with reserved characters in the name .
    • the automated process will read the project name , code using sql in gel  and will update the financial status of the project in the same script using soap invoke .
    •    tried several ways to give only &amp; in place of &    for xog , whatever we do when put the name in the xml it is &amp;amp;     .  so project name is getting updated with &amp;amp;   in place of & .
    • currently doing sql:update to replace &amp;amp;  with &     after soap:invoke  , but this is not a good solution .  if the project has name 80 chars ( max length of project name ) .. when xoging it is trying for 88 chars project name , so xog is failing .

     

    as we have thousands of projects already created with & in the names , difficult to impose restriction for users .



  • 11.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 04:27 AM

    It sounds like something "else" (other than your code) is also doing the XML replace of & with &amp; that doesn't really make sense though as if it were then you should not ever be having the original problem with & that you were.

     

    Seems very strange - are you sure that you have not done the replace twice yourself in teh logic somehow - can you examine / dump out the XML that you are using to update the project at the point that you call XOG with it to check that the format is correct? If that XML "looks" correct (with just &amp; in it) and then the update to the application is getting "corrputed" I it would be even more confusing - I would perhaps try to apply that XML in a different XOG client (eg the command line client) to see what happens. 



  • 12.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 04:47 AM

    Seems that you have taken the problem to the next level ;-)

     

    Just wondering again...

    One of the things in my previous post was that the reserved characters should be replaces with different things in normal xml for XOG and in gel script.

    Could that be your issue now?

    See

    Using >= or <= in query of GEL part 2 

    for examples with comparison signs.



  • 13.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 05:10 AM

    I am doing log of the xml before xoging in the gel scripts ..  you will get clear idea with below script and followed output ..

    tried util:replace  as well .. still same type of xml I am getting ...

    not sure If I have to correct my code .. it will work like this only

     

       <core:set var="proj_name_t">${rowinit[0]}</core:set>
        <core:set var="proj_code">${rowinit[1]}</core:set>

     

      <util:replace old=";amp;" new=";" var="proj_name" value="${proj_name_t}"/>>

     <gel:log category="XOG" level="DEBUG">${proj_name_t}</gel:log>
      <gel:log category="XOG" level="DEBUG">${proj_name}</gel:log>


        <gel:parse var="xogBody">
      
          <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
            <Header action="write" externalSource="NIKU" objectType="project" version="14.3.0.298"/>
            <Projects>
              <Project financialStatus="C" name="${proj_name}" projectID="${proj_code}"/>
            </Projects>
          </NikuDataBus>
      
        </gel:parse>

     

    <gel:set var="xogRootNodeAsString" select="$xogBody" asString="true"/>
    <gel:log category="XOG" level="DEBUG">${xogRootNodeAsString}</gel:log>

     

    output log



  • 14.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 05:50 AM

    OK I think you are confusing yourself a little here.

     

    Your debug is telling me that your 'proj_name_t' contains the xxxx&amp;xxxx at the start of your code (we can see this in the debug output)

     

    The <util:replace does not do anything because the  'proj_name_t' does not contain ';amp;' (it only contains &amp; as we see in the debug) 

     

    I'm not sure why the log of the XOG message contains &amp;&amp; though - might just be a function of you manipulating 'xogBody' into 'xogRootNodeAsString' though. I'd perhaps dump out (serialize) the xogBody variable (just write it raw to a file) rather than try to look at its contents via the application as I have no idea what the application's "debug viewer" is doing to my code when it tries to display it.

     



  • 15.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 06:18 AM

    Hi David,

     I can write to a raw file . but the thing my next statement in the code to xog it to application using soap:invoke...

    it is writing  &amp;amp;    to the project name  .

    so I don't think it is a debug viewer problem ..

    still I will try to write to file and will see , if it writes anything different .

    I am wondering if any other way of preparing xml doc in gel will help to get rid of extra amp;

     

     

    <gel:set var="prj_xml" select="$xogBody" asString="true"/>
    <gel:log category="XOG" level="DEBUG">${prj_xml}</gel:log>

        <core:catch var="XOGOP">

          <soap:invoke endpoint="internal" var="firstLoadresult">
            <soap:message>
              <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                <soapenv:Header>
                  <xog:Auth>
                    <xog:SessionID>${sessionID}</xog:SessionID>
                  </xog:Auth>
                </soapenv:Header>
                <soapenv:Body>
                  <gel:include select="$xogBody"/>
                </soapenv:Body>
              </soapenv:Envelope>
            </soap:message>
          </soap:invoke>

        </core:catch>
        <core:if test="${XOGOP != Null}">
          <gel:log level="ERROR">XOG ERROR = ${XOGOP}</gel:log>
        </core:if>



  • 16.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 06:36 AM

    Sorry ; I just don't think that your "debugging" is proving to me (or to yourself) where the problem is. For example your GEL script is handling "xogBody" differently in your debug ( handling it with a gel:set ) as when it is applied to the XOG call ( handling it with gel:include ).

     

    I think (but I am GUESSing here of course) that if you serialised out xogBody you should see that the data just contains ***&amp;*** and if it does not then you need to go back in your logic to look at what exactly you are pulling from the database and when exactly you attempt to do the "replace". ( this is what I am getting at by saying that you are confusing yourself with your debugging - I don't think you are looking at the source of your problem). 



  • 17.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 07:41 AM

    Hi Dave,

        you are correct , i see correct xml when use serialize and write to file ..

       i was struck there by just using these debug statements .

     

    could you please help me in finding the source of the problem , here i am copying the script . 

      

     

    <gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:core="jelly:core"
     xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
      xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sql="jelly:sql"
    xmlns:util="jelly:util"
      xmlns:xog="http://www.niku.com/xog"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <gel:parameter default="admin" var="XOGUSER"/>
      <!--  get the Project Code and Name from the DB  -->
     

    <gel:setDataSource dbId="Niku"/>
      <core:catch var="v_queryerrorf">

        <sql:query var="prjdet"> <![CDATA[select
                            inv.name proj_name
       ,inv.code proj_code
       from
       inv_investments inv
       where inv.id=6195025 ]]>
       
     
        </sql:query>

      </core:catch>
      <core:if test="${v_queryerrorf != Null}">
        <gel:log level="ERROR">SQL ERROR = ${v_queryerrorf} </gel:log>
      </core:if>
      <!-- get session id for the user -->
      <core:catch var="v_queryError">
        <sql:query var="version">
        SELECT MAX(INSTALLED_VERSION) INSTALLED_VERSION
        FROM CMN_INSTALL_HISTORY
        WHERE INSTALL_ID = 'release_version'
       </sql:query>
      </core:catch>
      <core:if test="${v_queryError != Null}">
        <gel:log level="ERROR">SQL ERROR = ${v_queryError} </gel:log>
      </core:if>
      <core:set value="${version.rows[0].INSTALLED_VERSION}" var="clarity_version"/>
      <core:catch var="xogerr">
        <!-- Retrieve Session ID -->
        <core:new className="com.niku.union.security.DefaultSecurityIdentifier" var="secId"/>
        <core:invokeStatic className="com.niku.union.security.UserSessionControllerFactory" method="getInstance" var="userSessionCtrl"/>
        <core:set value="${userSessionCtrl.init(XOGUSER, secId)}" var="secId"/>
        <core:set value="${secId.getUserName()}" var="XOGUsername"/>
        <core:set value="${secId.getSessionId()}" var="sessionID"/>
      </core:catch>

     


      <!-- create xml to do XOG -->
      <core:forEach items="${prjdet.rowsByIndex}" var="rowinit">
        <core:set var="proj_name">${rowinit[0]}</core:set>
        <core:set var="proj_code">${rowinit[1]}</core:set>

     


     <gel:log category="INFO">${proj_name}</gel:log>


        <gel:parse var="xogBody">
      
          <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
            <Header action="write" externalSource="NIKU" objectType="project" version="14.3.0.298"/>
            <Projects>
              <Project financialStatus="C" name="${proj_name}" projectID="${proj_code}"/>
            </Projects>
          </NikuDataBus>
      
        </gel:parse>

    <gel:serialize fileName="E:\CA\clarity\ravi_test.xml" var="${xogBody}"/>


        <core:catch var="XOGOP">

          <soap:invoke endpoint="internal" var="firstLoadresult">
            <soap:message>
              <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                <soapenv:Header>
                  <xog:Auth>
                    <xog:SessionID>${sessionID}</xog:SessionID>
                  </xog:Auth>
                </soapenv:Header>
                <soapenv:Body>
                  <gel:include select="$xogBody"/>
                </soapenv:Body>
              </soapenv:Envelope>
            </soap:message>
          </soap:invoke>

        </core:catch>
        <core:if test="${XOGOP != Null}">
          <gel:log level="ERROR">XOG ERROR = ${XOGOP}</gel:log>
        </core:if>

    <gel:set var="prj_xml" select="$xogBody" asString="true"/>
    <gel:log category="XOG" level="DEBUG">${prj_xml}</gel:log>


    <gel:set var="xog2" select="$firstLoadresult" asString="true"/>
    <gel:log category="XOG" level="DEBUG">${xog2}</gel:log>

     

      </core:forEach>


    </gel:script>



  • 18.  Re: Project XOG error , when project name has "&" in it

    Posted 05-09-2017 08:39 AM

    Well if your xogBody looks OK in the serialized file, then I think it should work OK in the XOG call as well (you are "include"ing it exactly the way I would).

     

    You could use the serialized file in a command-line XOG client call to see if you get the same results as in your GEL call? (I've lost the plot about where the problem really is now though as, unlike you, I can't see the before/after in the application)



  • 19.  Re: Project XOG error , when project name has "&" in it

    Posted 05-10-2017 03:01 AM

    Try <sql:query escapeText="false" var="prjdet"> <![CDATA[select
                            inv.name proj_name
       ,inv.code proj_code
       from
       inv_investments inv
       where inv.id=6195025 ]]>

    I have experienced this before, but can't recall if this is the exact solution or not.



  • 20.  Re: Project XOG error , when project name has "&" in it

    Posted 05-11-2017 04:03 AM

    Thanks .

       problem solved by using..

     

    <core:forEach items="${prjdet.rows}" var="prjdet_row">

          <core:set value="${prjdet_row.proj_name}" var="proj_name"/>
          <core:set value="${prjdet_row.proj_code}" var="proj_code"/>

     

    instead of below

     

      <core:forEach items="${prjdet.rowsByIndex}" var="rowinit">
        <core:set var="proj_name">${rowinit[0]}</core:set>
        <core:set var="proj_code">${rowinit[1]}</core:set>

     

    not sure why rowsByIndex is adding additional amp;