Skip to main content
added 2 characters in body
Source Link
Vadim Gremyachev
  • 42.6k
  • 3
  • 87
  • 169

As you correctly noticed at least the repeating block could re-factoredbe refactored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <xsl:choose>
        <xsl:when test="$CostCenter = ''">
            <span>0</span>
            <br/>
            <span style="font-size:8px;color:red">No budget assigned!</span>
        </xsl:when>
        <xsl:otherwise>
            <span style="padding-left:20px;color:black;font-weight:bold;font-size:12px;">
             <xsl:value-of select="format-number($CostCenter,'0.0')"/>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>

Note:the code has not been tested

As you correctly noticed at least the repeating block could re-factored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <xsl:choose>
        <xsl:when test="$CostCenter = ''">
            <span>0</span>
            <br/>
            <span style="font-size:8px;color:red">No budget assigned!</span>
        </xsl:when>
        <xsl:otherwise>
            <span style="padding-left:20px;color:black;font-weight:bold;font-size:12px;">
             <xsl:value-of select="format-number($CostCenter,'0.0')"/>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>

Note:the code has not been tested

As you correctly noticed at least the repeating block could be refactored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <xsl:choose>
        <xsl:when test="$CostCenter = ''">
            <span>0</span>
            <br/>
            <span style="font-size:8px;color:red">No budget assigned!</span>
        </xsl:when>
        <xsl:otherwise>
            <span style="padding-left:20px;color:black;font-weight:bold;font-size:12px;">
             <xsl:value-of select="format-number($CostCenter,'0.0')"/>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>

Note:the code has not been tested

added 505 characters in body
Source Link
Vadim Gremyachev
  • 42.6k
  • 3
  • 87
  • 169

As you correctly noticed at least the repeating block could re-factored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <<xsl:choose>
        <xsl:when test="$CostCenter = ''">
            <span>0</span>
            <br/>
            <span style="font-size:8px;color:red">No budget assigned!</span>
        </xsl:when>
        <xsl:otherwise>
            <span style="padding-left:20px;color:black;font-weight:bold;font-size:12px;">
 Render budget value          <xsl:value-of select="format-number($CostCenter,'0.0')"/>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>

Note:the code has not been tested

As you correctly noticed at least the repeating block could re-factored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <!-- Render budget value -->
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>

As you correctly noticed at least the repeating block could re-factored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <xsl:choose>
        <xsl:when test="$CostCenter = ''">
            <span>0</span>
            <br/>
            <span style="font-size:8px;color:red">No budget assigned!</span>
        </xsl:when>
        <xsl:otherwise>
            <span style="padding-left:20px;color:black;font-weight:bold;font-size:12px;">
             <xsl:value-of select="format-number($CostCenter,'0.0')"/>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>

Note:the code has not been tested

Source Link
Vadim Gremyachev
  • 42.6k
  • 3
  • 87
  • 169

As you correctly noticed at least the repeating block could re-factored.

For example, declare the following Xsl template for rendering Budget:

<xsl:template name="RenderBudget">
    <xsl:param name="CostCenter"/>
    
    <!-- Render budget value -->
</xsl:template>

and then invoke it

<xsl:call-template name="RenderBudget">
    <xsl:with-param name="CostCenter" select="/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and substring-after(@Test_x0020_Cost_x0020_Center.,'#') = $jobvalue]/@Test_x0020_Cost_x0020_Center_x002"/>
</xsl:call-template>