2013-02-14 5 views
0

XSLT에 클래스 크레딧 합계를 만들려고하지만 sum 문의 위치를 ​​파악할 수 없습니다. 데이터는 세 번 그룹화XSLT를 사용하여 그룹화 된 XML 워크 플로의 데이터 합계

<credit-sum><xsl:value-of select='format-number(sum(CRSMINCRED1),"##")'/></credit-sum> 

:

1. by Area of Study 
2. By Degree 
3. By Requirement or Elective status 

나는 "필수"클래스 만 학점 합계를 여기

은 내가 만든 합 문이다. 그러나 sum 문을 넣을 때 클래스 그룹 대신 개별적으로 각 클래스의 총계가 표시됩니다. 최종 출력은 어도비 인디자인으로 가져옵니다과 같이 나타납니다

<?xml version="1.0"?><!-- DWXMLSource="STX049-2-8-13-parsed.xml" --> 
<!DOCTYPE xsl:stylesheet> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="xml" indent="no"/> 
<xsl:variable name="allSections" select="/CrystalReport/Group/Group/Group/Details/Section" /> 

<xsl:key name="kArea" match="Section" use="ACPGAREAOFSTUDY1"/> 
<xsl:key name="kDegree" match="Section" use="concat(ACPGAREAOFSTUDY1, '+', ACPGDEGREE1)" /> 
<xsl:key name="kDepartment" match="Section" use="concat(ACPGAREAOFSTUDY1, '+', ACPGDEGREE1, '+', ICCB1)" /> 

<xsl:variable name="degreeFirsts" select="$allSections[generate-id() = generate-id(key('kDegree', concat(ACPGAREAOFSTUDY1, '+', ACPGDEGREE1))[1])]" /> 
<xsl:variable name="deptFirsts" select="$allSections[generate-id() = generate-id(key('kDepartment', concat(ACPGAREAOFSTUDY1, '+', ACPGDEGREE1, '+', ICCB1))[1])]" /> 


<xsl:template match="/"> 
<CrystalReport> 
<Degrees> 
<xsl:apply-templates select="$allSections[generate-id() = generate-id(key('kArea', ACPGAREAOFSTUDY1)[1])]" mode="group"/> 
</Degrees> 
</CrystalReport> 
</xsl:template> 

<xsl:template match="Section" mode="group"> 
<xsl:variable name="area" select="ACPGAREAOFSTUDY1" /> 
<xsl:text>&#xA;</xsl:text> 
<areaofstudy><xsl:value-of select="$area"/></areaofstudy> 
<xsl:apply-templates select="$degreeFirsts[ACPGAREAOFSTUDY1 = $area]" mode="degree"/> 
</xsl:template> 

<xsl:template match="Section" mode="degree"> 
<xsl:variable name="area" select="ACPGAREAOFSTUDY1" /> 
<xsl:variable name="degree" select="ACPGDEGREE1" /> 
<Degree> 
<xsl:apply-templates select="$deptFirsts[ACPGAREAOFSTUDY1 = $area and ACPGDEGREE1 = $degree]" mode="department"> 
<xsl:sort select="ACADPROGRAMSID1" /> 
</xsl:apply-templates> 
</Degree> 
</xsl:template> 

<xsl:template match="Section" mode="department"> 
<department><xsl:text>&#xA;</xsl:text><Degreetitle><xsl:apply-templates select="ACPGDEGREE1" /></Degreetitle> 
<Certtitle><xsl:apply-templates select="CCD11" /></Certtitle><xsl:text>&#xA;</xsl:text> 
<DegreeDesc><xsl:apply-templates select="ACPGCOMMENTS1" /></DegreeDesc> 
<xsl:text>&#xA;ICCB Code </xsl:text><ICCBcode><xsl:apply-templates select="ICCB1" /></ICCBcode> 
<xsl:text> | Field of Study Code: </xsl:text><ProgramID><xsl:apply-templates select="ACADPROGRAMSID1" /></ProgramID> 

<xsl:variable name="courses" select="key('kDepartment', concat(ACPGAREAOFSTUDY1, '+', ACPGDEGREE1, '+', ICCB1))" /> 

<xsl:call-template name="CourseGroup"> 
<xsl:with-param name="courses" select="$courses[FlagElectives1 = 'N']" /> 
<xsl:with-param name="title" select="'Program Requirements'" /> 
</xsl:call-template> 

<xsl:call-template name="CourseGroup"> 
<xsl:with-param name="courses" select="$courses[FlagElectives1 = 'Y']" /> 
<xsl:with-param name="title" select="'Program Electives'" /> 
</xsl:call-template> 
<xsl:apply-templates select="ACPGHOMELANGNOTREQDRSN1" /> 
</department> 
</xsl:template> 

<xsl:template name="CourseGroup"> 
<xsl:param name="courses" /> 
<xsl:param name="title" /> 

<xsl:if test="$courses"><xsl:text>&#xA;</xsl:text> 
<req-electitle><xsl:value-of select="$title" /></req-electitle> 
<xsl:apply-templates select="$courses"> 
<xsl:sort select="FlagElectives1" order="ascending" /> 
<xsl:sort select="CRSSUBJECT1" /> 
<xsl:sort select="CRSNO1" /> 
</xsl:apply-templates> 
</xsl:if> 
</xsl:template> 

<xsl:template match="Section"> 
<xsl:text>&#xA;</xsl:text> 
<Details> 
<class><deptname><xsl:apply-templates select="CRSSUBJECT1" /></deptname><xsl:text> </xsl:text> 
<courseno><xsl:apply-templates select="CRSNO1" /></courseno><xsl:text> </xsl:text> 
<classname><xsl:apply-templates select="CRSTITLE1" /></classname><xsl:text> </xsl:text> 
<classcredit><xsl:apply-templates select="CRSMINCRED1" /></classcredit> 
<xsl:apply-templates select="CRSMAXCRED1" /> 
</class> 
</Details> 
</xsl:template> 

<xsl:template match="ACPGHOMELANGNOTREQDRSN1[string-length() != 0]"> 
<xsl:text>&#xA;</xsl:text><totalcredits><xsl:value-of select="normalize-space(.)" /></totalcredits> 
</xsl:template> 

<xsl:template match="CRSMAXCRED1[string-length() != 0]"> 
<xsl:text> to </xsl:text><maxcredits><xsl:value-of select="normalize-space(.)" /></maxcredits> 
</xsl:template> 

<xsl:template match="ACPGDEGREE1/text()"> 
<xsl:value-of select="concat(., ' DEGREE')"/> 
</xsl:template> 

<xsl:template match="CCD11/text()"> 
<xsl:value-of select="('CERTIFICATE')" /> 
</xsl:template> 

</xsl:stylesheet> 

: ...

ICCB Code 4903 | Field of Study Code: AIRC.CER.ENERG 
Program Requirements 
AIRC 2232 Energy Audits/Economics      2 
AIRC 2240 Load Calculations and Duct Design   5 
AIRC 2260 Heating and Air Conditioning Contracting 3 
Total Credits            10 

답변

0

그것은 CourseCroup 템플릿이 보인다처럼 여기

는 XSLT이다 이 변경을위한 장소 :

<xsl:template name="CourseGroup"> 
    <xsl:param name="courses" /> 
    <xsl:param name="title" /> 
    <xsl:param name="requiredCourses" select="false()" /> 

    <xsl:if test="$courses"> 
     <xsl:text>&#xA;</xsl:text> 
     <req-electitle> 
     <xsl:value-of select="$title" /> 
     </req-electitle> 
     <xsl:apply-templates select="$courses"> 
     <xsl:sort select="FlagElectives1" order="ascending" /> 
     <xsl:sort select="CRSSUBJECT1" /> 
     <xsl:sort select="CRSNO1" /> 
     </xsl:apply-templates> 
     <xsl:if test="$requiredCourses"> 
     <credit-sum> 
      <xsl:value-of select='format-number(sum($courses/CRSMINCRED1),"##")'/> 
     </credit-sum> 
     </xsl:if> 
    </xsl:if> 
    </xsl:template> 

그리고 첫 번째 을 수정하여 추가 매개 변수를 추가합니다.

<xsl:call-template name="CourseGroup"> 
    <xsl:with-param name="courses" select="$courses[FlagElectives1 = 'N']" /> 
    <xsl:with-param name="title" select="'Program Requirements'" /> 
    <xsl:with-param name="requiredCourses" select="true()" /> 
    </xsl:call-template>