XSLT 模板循环记录
XSLT Template Looping Records
我正在努力构建一个 xsl 模板,其中包含一个循环职位记录,根据每条记录中可用的空缺职位编号打印多次。
我对这段代码完全陌生,并创建了一个草稿模板来打印记录。但是我无法将循环添加到其中。
例如:当前文本输出:
PositionIdentifier,Position Name,Grade Name,Vacant Positions
1365,Data Processing Manager,M,2
预期的文本输出:
PositionIdentifier,Position Name,Grade Name,Vacant Positions
1365,Data Processing Manager,M,Vacant1
1365,Data Processing Manager,M,Vacant2
[在此处输入图片描述][1]
请求您的帮助以完成此代码。
如果您需要任何进一步的信息,请告诉我。
此致,
穆拉利
XML 代码如下:
<?xml version = '1.0' encoding = 'utf-8'?>
<!--Generated by Oracle BI Publisher -Dataengine, datamodel:_Custom_Human_Capital_Management_Payroll_Data_Models_STL_I_EPM_107_B___Vacant_Positions_Demographics_DM_xdm -->
<DATA_DS><P_DATE>2022-04-19T00:00:00.000+00:00</P_DATE>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1541</POSITIONID><POSITION_NAME>Test Benefits Clerk</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1541 Benefits Clerk</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1122</POSITIONID><POSITION_NAME>Test Clerk Typist </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1122 Clerk Typist</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1513</POSITIONID><POSITION_NAME>Test Human Resources Specialist I </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>2</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1513 Human Resources Specialist I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1514</POSITIONID><POSITION_NAME>Test Human Resources Specialist II </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1514 Human Resources Specialist II</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1332</POSITIONID><POSITION_NAME>Test Computer Programmer II</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1332 Computer Programmer II</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1352</POSITIONID><POSITION_NAME>Test Systems Project Leader </POSITION_NAME><GRADE_NAME>M</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>3</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1352 Systems Project Leader</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1371</POSITIONID><POSITION_NAME>Test Technical Support Specialist I</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>4</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>127 Technical Support Specialist I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>3518</POSITIONID><POSITION_NAME>Test Water Maintenance Technician</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>7</FILLED_FTE><VACANT_POSITIONS>73</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>WtrDist-DistC-3518 Water Maintenance Technician</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1116</POSITIONID><POSITION_NAME>Test Customer Service Rep I </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>14</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>Engnr-1116 Customer Service Representative I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1142</POSITIONID><POSITION_NAME>Test Account Clerk II </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>3</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>Account Clerk</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>4241</POSITIONID><POSITION_NAME>Test Civil Engineer I</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>2</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>WtrDist-Engnr-4241 Civil Engineer I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>3517</POSITIONID><POSITION_NAME>Test Water Maintenance Foreman</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>2</FILLED_FTE><VACANT_POSITIONS>20</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>WtrDist-Mtr Tap-3517 Water Maintenance Foreman</NAME>
</G_1>
</DATA_DS>
尝试 post 示例 XSL 代码,但在 post 此处时出现错误。
示例输出已在摘要顶部共享。
请查找 XSL 代码:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:functx="http://my/functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="csvDelimiter">,</xsl:variable>
<xsl:param name="br">
<xsl:text>
</xsl:text>
</xsl:param>
<xsl:template match="/">
<!-- ============================================================================== -->
<!-- Printing headers 1 -->
<!-- ============================================================================== -->
<xsl:text>PositionIdentifier</xsl:text>
<xsl:value-of select="$csvDelimiter"/>
<xsl:text>Position Name</xsl:text>
<xsl:value-of select="$csvDelimiter"/>
<xsl:text>Grade Name</xsl:text>
<xsl:value-of select="$csvDelimiter"/>
<xsl:text>Vacant Positions</xsl:text>
<!-- ======================================= -->
<!-- Printing rows. -->
<!-- ======================================= -->
<xsl:for-each select ="/DATA_DS/G_1">
<!-- Variables -->
<xsl:variable name="POSITIONID">
<xsl:value-of select="(POSITIONID)"/>
</xsl:variable>
<xsl:variable name="POSITION_NAME">
<xsl:value-of select="(POSITION_NAME)"/>
</xsl:variable>
<xsl:variable name="GRADE_NAME">
<xsl:value-of select="(GRADE_NAME)"/>
</xsl:variable>
<xsl:variable name="VACANT_POSITIONS">
<xsl:value-of select="(VACANT_POSITIONS)"/>
</xsl:variable>
<xsl:value-of select="$br" />
<!-- End Of Variables -->
<xsl:value-of select="POSITIONID"/>
<xsl:value-of select="$csvDelimiter"/>
<xsl:value-of select="$POSITION_NAME"/>
<xsl:value-of select="$csvDelimiter"/>
<xsl:value-of select="$GRADE_NAME"/>
<xsl:value-of select="$csvDelimiter"/>
<xsl:value-of select="$VACANT_POSITIONS"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
您的输出与您的输入不匹配。您输入的位置没有Data Processing Manager
。
假设给定输入示例所需的输出实际上是:
结果
PositionIdentifier,Position Name,Grade Name,Vacant Positions
1541,Test Benefits Clerk,G,VACANT1
1122,Test Clerk Typist,G,VACANT1
1122,Test Clerk Typist,G,VACANT2
1513,Test Human Resources Specialist I,G,VACANT1
1514,Test Human Resources Specialist II,G,VACANT1
1332,Test Computer Programmer II,G,VACANT1
1352,Test Systems Project Leader,M,VACANT1
1352,Test Systems Project Leader,M,VACANT2
1371,Test Technical Support Specialist I,G,VACANT1
1371,Test Technical Support Specialist I,G,VACANT2
3518,Test Water Maintenance Technician,G,VACANT1
3518,Test Water Maintenance Technician,G,VACANT2
3518,Test Water Maintenance Technician,G,VACANT3
3518,Test Water Maintenance Technician,G,VACANT4
3518,Test Water Maintenance Technician,G,VACANT5
3518,Test Water Maintenance Technician,G,VACANT6
3518,Test Water Maintenance Technician,G,VACANT7
3518,Test Water Maintenance Technician,G,VACANT8
3518,Test Water Maintenance Technician,G,VACANT9
3518,Test Water Maintenance Technician,G,VACANT10
3518,Test Water Maintenance Technician,G,VACANT11
3518,Test Water Maintenance Technician,G,VACANT12
3518,Test Water Maintenance Technician,G,VACANT13
3518,Test Water Maintenance Technician,G,VACANT14
3518,Test Water Maintenance Technician,G,VACANT15
3518,Test Water Maintenance Technician,G,VACANT16
3518,Test Water Maintenance Technician,G,VACANT17
3518,Test Water Maintenance Technician,G,VACANT18
3518,Test Water Maintenance Technician,G,VACANT19
3518,Test Water Maintenance Technician,G,VACANT20
3518,Test Water Maintenance Technician,G,VACANT21
3518,Test Water Maintenance Technician,G,VACANT22
3518,Test Water Maintenance Technician,G,VACANT23
3518,Test Water Maintenance Technician,G,VACANT24
3518,Test Water Maintenance Technician,G,VACANT25
3518,Test Water Maintenance Technician,G,VACANT26
3518,Test Water Maintenance Technician,G,VACANT27
3518,Test Water Maintenance Technician,G,VACANT28
3518,Test Water Maintenance Technician,G,VACANT29
3518,Test Water Maintenance Technician,G,VACANT30
3518,Test Water Maintenance Technician,G,VACANT31
3518,Test Water Maintenance Technician,G,VACANT32
3518,Test Water Maintenance Technician,G,VACANT33
3518,Test Water Maintenance Technician,G,VACANT34
3518,Test Water Maintenance Technician,G,VACANT35
3518,Test Water Maintenance Technician,G,VACANT36
3518,Test Water Maintenance Technician,G,VACANT37
3518,Test Water Maintenance Technician,G,VACANT38
3518,Test Water Maintenance Technician,G,VACANT39
3518,Test Water Maintenance Technician,G,VACANT40
3518,Test Water Maintenance Technician,G,VACANT41
3518,Test Water Maintenance Technician,G,VACANT42
3518,Test Water Maintenance Technician,G,VACANT43
3518,Test Water Maintenance Technician,G,VACANT44
3518,Test Water Maintenance Technician,G,VACANT45
3518,Test Water Maintenance Technician,G,VACANT46
3518,Test Water Maintenance Technician,G,VACANT47
3518,Test Water Maintenance Technician,G,VACANT48
3518,Test Water Maintenance Technician,G,VACANT49
3518,Test Water Maintenance Technician,G,VACANT50
3518,Test Water Maintenance Technician,G,VACANT51
3518,Test Water Maintenance Technician,G,VACANT52
3518,Test Water Maintenance Technician,G,VACANT53
3518,Test Water Maintenance Technician,G,VACANT54
3518,Test Water Maintenance Technician,G,VACANT55
3518,Test Water Maintenance Technician,G,VACANT56
3518,Test Water Maintenance Technician,G,VACANT57
3518,Test Water Maintenance Technician,G,VACANT58
3518,Test Water Maintenance Technician,G,VACANT59
3518,Test Water Maintenance Technician,G,VACANT60
3518,Test Water Maintenance Technician,G,VACANT61
3518,Test Water Maintenance Technician,G,VACANT62
3518,Test Water Maintenance Technician,G,VACANT63
3518,Test Water Maintenance Technician,G,VACANT64
3518,Test Water Maintenance Technician,G,VACANT65
3518,Test Water Maintenance Technician,G,VACANT66
3518,Test Water Maintenance Technician,G,VACANT67
3518,Test Water Maintenance Technician,G,VACANT68
3518,Test Water Maintenance Technician,G,VACANT69
3518,Test Water Maintenance Technician,G,VACANT70
3518,Test Water Maintenance Technician,G,VACANT71
3518,Test Water Maintenance Technician,G,VACANT72
3518,Test Water Maintenance Technician,G,VACANT73
1116,Test Customer Service Rep I,G,VACANT1
1116,Test Customer Service Rep I,G,VACANT2
1116,Test Customer Service Rep I,G,VACANT3
1116,Test Customer Service Rep I,G,VACANT4
1116,Test Customer Service Rep I,G,VACANT5
1116,Test Customer Service Rep I,G,VACANT6
1116,Test Customer Service Rep I,G,VACANT7
1116,Test Customer Service Rep I,G,VACANT8
1116,Test Customer Service Rep I,G,VACANT9
1116,Test Customer Service Rep I,G,VACANT10
1116,Test Customer Service Rep I,G,VACANT11
1116,Test Customer Service Rep I,G,VACANT12
1116,Test Customer Service Rep I,G,VACANT13
1116,Test Customer Service Rep I,G,VACANT14
1142,Test Account Clerk II,G,VACANT1
1142,Test Account Clerk II,G,VACANT2
4241,Test Civil Engineer I,G,VACANT1
3517,Test Water Maintenance Foreman,G,VACANT1
3517,Test Water Maintenance Foreman,G,VACANT2
3517,Test Water Maintenance Foreman,G,VACANT3
3517,Test Water Maintenance Foreman,G,VACANT4
3517,Test Water Maintenance Foreman,G,VACANT5
3517,Test Water Maintenance Foreman,G,VACANT6
3517,Test Water Maintenance Foreman,G,VACANT7
3517,Test Water Maintenance Foreman,G,VACANT8
3517,Test Water Maintenance Foreman,G,VACANT9
3517,Test Water Maintenance Foreman,G,VACANT10
3517,Test Water Maintenance Foreman,G,VACANT11
3517,Test Water Maintenance Foreman,G,VACANT12
3517,Test Water Maintenance Foreman,G,VACANT13
3517,Test Water Maintenance Foreman,G,VACANT14
3517,Test Water Maintenance Foreman,G,VACANT15
3517,Test Water Maintenance Foreman,G,VACANT16
3517,Test Water Maintenance Foreman,G,VACANT17
3517,Test Water Maintenance Foreman,G,VACANT18
3517,Test Water Maintenance Foreman,G,VACANT19
3517,Test Water Maintenance Foreman,G,VACANT20
它可以使用以下方法生产:
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/DATA_DS">
<!-- header -->
<xsl:text>PositionIdentifier,Position Name,Grade Name,Vacant Positions
</xsl:text>
<!-- data -->
<xsl:for-each select="G_1">
<xsl:variable name="common-data">
<xsl:value-of select="POSITIONID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="normalize-space(POSITION_NAME)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="GRADE_NAME"/>
<xsl:text>,</xsl:text>
</xsl:variable>
<xsl:for-each select="1 to VACANT_POSITIONS">
<xsl:copy-of select="$common-data"/>
<xsl:text>VACANT</xsl:text>
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
我正在努力构建一个 xsl 模板,其中包含一个循环职位记录,根据每条记录中可用的空缺职位编号打印多次。 我对这段代码完全陌生,并创建了一个草稿模板来打印记录。但是我无法将循环添加到其中。
例如:当前文本输出:
PositionIdentifier,Position Name,Grade Name,Vacant Positions
1365,Data Processing Manager,M,2
预期的文本输出:
PositionIdentifier,Position Name,Grade Name,Vacant Positions
1365,Data Processing Manager,M,Vacant1
1365,Data Processing Manager,M,Vacant2
[在此处输入图片描述][1]
请求您的帮助以完成此代码。 如果您需要任何进一步的信息,请告诉我。
此致, 穆拉利
XML 代码如下:
<?xml version = '1.0' encoding = 'utf-8'?>
<!--Generated by Oracle BI Publisher -Dataengine, datamodel:_Custom_Human_Capital_Management_Payroll_Data_Models_STL_I_EPM_107_B___Vacant_Positions_Demographics_DM_xdm -->
<DATA_DS><P_DATE>2022-04-19T00:00:00.000+00:00</P_DATE>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1541</POSITIONID><POSITION_NAME>Test Benefits Clerk</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1541 Benefits Clerk</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1122</POSITIONID><POSITION_NAME>Test Clerk Typist </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1122 Clerk Typist</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1513</POSITIONID><POSITION_NAME>Test Human Resources Specialist I </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>2</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1513 Human Resources Specialist I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1514</POSITIONID><POSITION_NAME>Test Human Resources Specialist II </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1514 Human Resources Specialist II</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1332</POSITIONID><POSITION_NAME>Test Computer Programmer II</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1332 Computer Programmer II</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1352</POSITIONID><POSITION_NAME>Test Systems Project Leader </POSITION_NAME><GRADE_NAME>M</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>3</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>1352 Systems Project Leader</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1371</POSITIONID><POSITION_NAME>Test Technical Support Specialist I</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>4</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>127 Technical Support Specialist I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>3518</POSITIONID><POSITION_NAME>Test Water Maintenance Technician</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>7</FILLED_FTE><VACANT_POSITIONS>73</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>WtrDist-DistC-3518 Water Maintenance Technician</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1116</POSITIONID><POSITION_NAME>Test Customer Service Rep I </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>1</FILLED_FTE><VACANT_POSITIONS>14</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>Engnr-1116 Customer Service Representative I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>1142</POSITIONID><POSITION_NAME>Test Account Clerk II </POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>3</FILLED_FTE><VACANT_POSITIONS>2</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>Account Clerk</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>4241</POSITIONID><POSITION_NAME>Test Civil Engineer I</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>2</FILLED_FTE><VACANT_POSITIONS>1</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>WtrDist-Engnr-4241 Civil Engineer I</NAME>
</G_1>
<G_1>
<FISCALYEAR>FY22</FISCALYEAR><POSITIONID>3517</POSITIONID><POSITION_NAME>Test Water Maintenance Foreman</POSITION_NAME><GRADE_NAME>G</GRADE_NAME><PAYPERIOD_END_DATE>04/23/2022</PAYPERIOD_END_DATE><PAY_PERIOD>22</PAY_PERIOD><MONTHS>APR</MONTHS><NO_OF_PAYS>26</NO_OF_PAYS><FILLED_FTE>2</FILLED_FTE><VACANT_POSITIONS>20</VACANT_POSITIONS><EMPLOYEE_ID>Vacant</EMPLOYEE_ID><NAME>WtrDist-Mtr Tap-3517 Water Maintenance Foreman</NAME>
</G_1>
</DATA_DS>
尝试 post 示例 XSL 代码,但在 post 此处时出现错误。 示例输出已在摘要顶部共享。
请查找 XSL 代码:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:functx="http://my/functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="csvDelimiter">,</xsl:variable>
<xsl:param name="br">
<xsl:text>
</xsl:text>
</xsl:param>
<xsl:template match="/">
<!-- ============================================================================== -->
<!-- Printing headers 1 -->
<!-- ============================================================================== -->
<xsl:text>PositionIdentifier</xsl:text>
<xsl:value-of select="$csvDelimiter"/>
<xsl:text>Position Name</xsl:text>
<xsl:value-of select="$csvDelimiter"/>
<xsl:text>Grade Name</xsl:text>
<xsl:value-of select="$csvDelimiter"/>
<xsl:text>Vacant Positions</xsl:text>
<!-- ======================================= -->
<!-- Printing rows. -->
<!-- ======================================= -->
<xsl:for-each select ="/DATA_DS/G_1">
<!-- Variables -->
<xsl:variable name="POSITIONID">
<xsl:value-of select="(POSITIONID)"/>
</xsl:variable>
<xsl:variable name="POSITION_NAME">
<xsl:value-of select="(POSITION_NAME)"/>
</xsl:variable>
<xsl:variable name="GRADE_NAME">
<xsl:value-of select="(GRADE_NAME)"/>
</xsl:variable>
<xsl:variable name="VACANT_POSITIONS">
<xsl:value-of select="(VACANT_POSITIONS)"/>
</xsl:variable>
<xsl:value-of select="$br" />
<!-- End Of Variables -->
<xsl:value-of select="POSITIONID"/>
<xsl:value-of select="$csvDelimiter"/>
<xsl:value-of select="$POSITION_NAME"/>
<xsl:value-of select="$csvDelimiter"/>
<xsl:value-of select="$GRADE_NAME"/>
<xsl:value-of select="$csvDelimiter"/>
<xsl:value-of select="$VACANT_POSITIONS"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
您的输出与您的输入不匹配。您输入的位置没有Data Processing Manager
。
假设给定输入示例所需的输出实际上是:
结果
PositionIdentifier,Position Name,Grade Name,Vacant Positions
1541,Test Benefits Clerk,G,VACANT1
1122,Test Clerk Typist,G,VACANT1
1122,Test Clerk Typist,G,VACANT2
1513,Test Human Resources Specialist I,G,VACANT1
1514,Test Human Resources Specialist II,G,VACANT1
1332,Test Computer Programmer II,G,VACANT1
1352,Test Systems Project Leader,M,VACANT1
1352,Test Systems Project Leader,M,VACANT2
1371,Test Technical Support Specialist I,G,VACANT1
1371,Test Technical Support Specialist I,G,VACANT2
3518,Test Water Maintenance Technician,G,VACANT1
3518,Test Water Maintenance Technician,G,VACANT2
3518,Test Water Maintenance Technician,G,VACANT3
3518,Test Water Maintenance Technician,G,VACANT4
3518,Test Water Maintenance Technician,G,VACANT5
3518,Test Water Maintenance Technician,G,VACANT6
3518,Test Water Maintenance Technician,G,VACANT7
3518,Test Water Maintenance Technician,G,VACANT8
3518,Test Water Maintenance Technician,G,VACANT9
3518,Test Water Maintenance Technician,G,VACANT10
3518,Test Water Maintenance Technician,G,VACANT11
3518,Test Water Maintenance Technician,G,VACANT12
3518,Test Water Maintenance Technician,G,VACANT13
3518,Test Water Maintenance Technician,G,VACANT14
3518,Test Water Maintenance Technician,G,VACANT15
3518,Test Water Maintenance Technician,G,VACANT16
3518,Test Water Maintenance Technician,G,VACANT17
3518,Test Water Maintenance Technician,G,VACANT18
3518,Test Water Maintenance Technician,G,VACANT19
3518,Test Water Maintenance Technician,G,VACANT20
3518,Test Water Maintenance Technician,G,VACANT21
3518,Test Water Maintenance Technician,G,VACANT22
3518,Test Water Maintenance Technician,G,VACANT23
3518,Test Water Maintenance Technician,G,VACANT24
3518,Test Water Maintenance Technician,G,VACANT25
3518,Test Water Maintenance Technician,G,VACANT26
3518,Test Water Maintenance Technician,G,VACANT27
3518,Test Water Maintenance Technician,G,VACANT28
3518,Test Water Maintenance Technician,G,VACANT29
3518,Test Water Maintenance Technician,G,VACANT30
3518,Test Water Maintenance Technician,G,VACANT31
3518,Test Water Maintenance Technician,G,VACANT32
3518,Test Water Maintenance Technician,G,VACANT33
3518,Test Water Maintenance Technician,G,VACANT34
3518,Test Water Maintenance Technician,G,VACANT35
3518,Test Water Maintenance Technician,G,VACANT36
3518,Test Water Maintenance Technician,G,VACANT37
3518,Test Water Maintenance Technician,G,VACANT38
3518,Test Water Maintenance Technician,G,VACANT39
3518,Test Water Maintenance Technician,G,VACANT40
3518,Test Water Maintenance Technician,G,VACANT41
3518,Test Water Maintenance Technician,G,VACANT42
3518,Test Water Maintenance Technician,G,VACANT43
3518,Test Water Maintenance Technician,G,VACANT44
3518,Test Water Maintenance Technician,G,VACANT45
3518,Test Water Maintenance Technician,G,VACANT46
3518,Test Water Maintenance Technician,G,VACANT47
3518,Test Water Maintenance Technician,G,VACANT48
3518,Test Water Maintenance Technician,G,VACANT49
3518,Test Water Maintenance Technician,G,VACANT50
3518,Test Water Maintenance Technician,G,VACANT51
3518,Test Water Maintenance Technician,G,VACANT52
3518,Test Water Maintenance Technician,G,VACANT53
3518,Test Water Maintenance Technician,G,VACANT54
3518,Test Water Maintenance Technician,G,VACANT55
3518,Test Water Maintenance Technician,G,VACANT56
3518,Test Water Maintenance Technician,G,VACANT57
3518,Test Water Maintenance Technician,G,VACANT58
3518,Test Water Maintenance Technician,G,VACANT59
3518,Test Water Maintenance Technician,G,VACANT60
3518,Test Water Maintenance Technician,G,VACANT61
3518,Test Water Maintenance Technician,G,VACANT62
3518,Test Water Maintenance Technician,G,VACANT63
3518,Test Water Maintenance Technician,G,VACANT64
3518,Test Water Maintenance Technician,G,VACANT65
3518,Test Water Maintenance Technician,G,VACANT66
3518,Test Water Maintenance Technician,G,VACANT67
3518,Test Water Maintenance Technician,G,VACANT68
3518,Test Water Maintenance Technician,G,VACANT69
3518,Test Water Maintenance Technician,G,VACANT70
3518,Test Water Maintenance Technician,G,VACANT71
3518,Test Water Maintenance Technician,G,VACANT72
3518,Test Water Maintenance Technician,G,VACANT73
1116,Test Customer Service Rep I,G,VACANT1
1116,Test Customer Service Rep I,G,VACANT2
1116,Test Customer Service Rep I,G,VACANT3
1116,Test Customer Service Rep I,G,VACANT4
1116,Test Customer Service Rep I,G,VACANT5
1116,Test Customer Service Rep I,G,VACANT6
1116,Test Customer Service Rep I,G,VACANT7
1116,Test Customer Service Rep I,G,VACANT8
1116,Test Customer Service Rep I,G,VACANT9
1116,Test Customer Service Rep I,G,VACANT10
1116,Test Customer Service Rep I,G,VACANT11
1116,Test Customer Service Rep I,G,VACANT12
1116,Test Customer Service Rep I,G,VACANT13
1116,Test Customer Service Rep I,G,VACANT14
1142,Test Account Clerk II,G,VACANT1
1142,Test Account Clerk II,G,VACANT2
4241,Test Civil Engineer I,G,VACANT1
3517,Test Water Maintenance Foreman,G,VACANT1
3517,Test Water Maintenance Foreman,G,VACANT2
3517,Test Water Maintenance Foreman,G,VACANT3
3517,Test Water Maintenance Foreman,G,VACANT4
3517,Test Water Maintenance Foreman,G,VACANT5
3517,Test Water Maintenance Foreman,G,VACANT6
3517,Test Water Maintenance Foreman,G,VACANT7
3517,Test Water Maintenance Foreman,G,VACANT8
3517,Test Water Maintenance Foreman,G,VACANT9
3517,Test Water Maintenance Foreman,G,VACANT10
3517,Test Water Maintenance Foreman,G,VACANT11
3517,Test Water Maintenance Foreman,G,VACANT12
3517,Test Water Maintenance Foreman,G,VACANT13
3517,Test Water Maintenance Foreman,G,VACANT14
3517,Test Water Maintenance Foreman,G,VACANT15
3517,Test Water Maintenance Foreman,G,VACANT16
3517,Test Water Maintenance Foreman,G,VACANT17
3517,Test Water Maintenance Foreman,G,VACANT18
3517,Test Water Maintenance Foreman,G,VACANT19
3517,Test Water Maintenance Foreman,G,VACANT20
它可以使用以下方法生产:
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/DATA_DS">
<!-- header -->
<xsl:text>PositionIdentifier,Position Name,Grade Name,Vacant Positions
</xsl:text>
<!-- data -->
<xsl:for-each select="G_1">
<xsl:variable name="common-data">
<xsl:value-of select="POSITIONID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="normalize-space(POSITION_NAME)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="GRADE_NAME"/>
<xsl:text>,</xsl:text>
</xsl:variable>
<xsl:for-each select="1 to VACANT_POSITIONS">
<xsl:copy-of select="$common-data"/>
<xsl:text>VACANT</xsl:text>
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>