AnsweredAssumed Answered

Using core:include in Gel Scripts

Question asked by gcubed Champion on Mar 3, 2014
Latest reply on Mar 4, 2014 by Dave


Is anyone using core:include for reusable gel script components?

I have been looking over our scripts and I see a lot of code snippets (login, logout, read,…) that are the same.

I have played around with core:include and found it works as advertised with the benefit of reducing the script verbiage.  Has anyone stubbed their toes using core:include or see any issue with it in a production environment?

Here is the test script I was using to test-out core:include for Login/Logout/ReadProjects.

<?xml version="1.0" encoding="utf-8"?>
    <gel:out>Starting Test Include</gel:out>
    <!-- Setup our script exception catch -->
    <core:catch var="exception">
        <gel:parameter var="XogUserName" />
        <gel:parameter var="XogPassword" />
        <!-- Wrap our script in a loop so we can use break to exit cleanly -->
        <core:set var="scriptBreak" value="[1]" />
        <core:forEach var="dummy" items="${scriptBreak}">
            <!-- Login -->
            <core:include file="gel/Login_Include.xml" />
            <core:if test="${XogSessionId == null}">
                <core:break />
            <!-- Get our xogReadProjects soap:message query -->
            <core:include file="gel/XogReadProjects_Include.xml" />
            <!-- Add a filter to our read -->
            <gel:parse var="readProjectFilter">
                <Filter name="projectID" criteria="OR">PRJ00000539,PRJ00000645,PRJ00000728</Filter>
            <gel:set value="${readProjectFilter}" select="$xogReadProjects//Query" insert="true" />
            <!-- Save our results into a file just to see what we get -->
            <gel:serialize fileName="xogReadProjects1.xml" var="${xogReadProjects}" />
            <!-- Invoke our soap endpoint -->
            <soap:invoke endpoint="${XogUrl}" var="projectResults">
                    <gel:include select="$xogReadProjects" />
            <!-- Save our results into a file just to see what we get -->
            <gel:serialize fileName="projectResults1.xml" var="${projectResults}" />
            <!-- Logout -->
            <core:include file="gel/Logout_Include.xml" />
        <gel:out>Finish Test Include</gel:out>
    <core:if test="${exception != null}">
        <gel:log level="FATAL" message="    ${exception}" />