我想在这里做3件事。我想:
1)删除/替换文字。 2)复制XML最多26次 3)将XML中的日期更改为14天26次。
以下是我的开始:
<?xml version='1.0' encoding='UTF-8'?>
<BB:Report_Data xmlns:BB="urn:com.playdate.report/Bi-Weekly_Outbound">
<BB:Report_Entry>
<BB:projectedBalanceTotal.employeeId>1234567</BB:projectedBalanceTotal.employeeId> <BB:projectedBalanceTotal.principalId>4573945975</BB:projectedBalanceTotal.principalId>
<BB:All_Eligible_Time_Off_Plans_for_Worker> <BB:projected_balance_accrual_amount_for_the_pay_period>0</BB:projected_balance_accrual_amount_for_the_pay_period>
<BB:projectedBalanceTotal.effectiveDate>07072012</BB:projectedBalanceTotal.effectiveDate>
<BB:projectedBalanceTotal.planCodeId>VA</BB:projectedBalanceTotal.planCodeId>
<BB:leaveBalanceTotal.leaveDescription>VA</BB:leaveBalanceTotal.leaveDescription>
</BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:All_Eligible_Time_Off_Plans_for_Worker> <BB:projected_balance_accrual_amount_for_the_pay_period>0</BB:projected_balance_accrual_amount_for_the_pay_period> <BB:projectedBalanceTotal.effectiveDate>07072012</BB:projectedBalanceTotal.effectiveDate>
<BB:projectedBalanceTotal.planCodeId>WR</BB:projectedBalanceTotal.planCodeId>
<BB:leaveBalanceTotal.leaveDescription>WR</BB:leaveBalanceTotal.leaveDescription>
</BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:projected_balance_accrual_amount_for_the_pay_period>3.323</BB:projected_balance_accrual_amount_for_the_pay_period> <BB:projectedBalanceTotal.effectiveDate>07072012</BB:projectedBalanceTotal.effectiveDate>
<BB:projectedBalanceTotal.planCodeId>SS</BB:projectedBalanceTotal.planCodeId>
<BB:leaveBalanceTotal.leaveDescription>SS</BB:leaveBalanceTotal.leaveDescription>
</BB:All_Eligible_Time_Off_Plans_for_Worker>
</BB:Report_Entry>
</BB:Report_Data>
这就是它需要结束的方式:
<BB:Report_Data xmlns:wd="urn:com.playdate.report/Bi-Weekly_Outbound">
<leaveBalanceTotal>
<projectedBalanceTotal.employeeId>1234567</projectedBalanceTotal.employeeId>
<projectedBalanceTotal.principalId>4573945975</projectedBalanceTotal.principalId>
<projected_balance_accrual_amount_for_the_pay_period>0</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>07072012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>VA</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>VA</leaveBalanceTotal.leaveDescription>
<projected_balance_accrual_amount_for_the_pay_period>0</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>07072012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>WR</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>WR</leaveBalanceTotal.leaveDescription>
<projected_balance_accrual_amount_for_the_pay_period>3.323</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>07072012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>SS</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>SS</leaveBalanceTotal.leaveDescription>
</leaveBalanceTotal>
<leaveBalanceTotal>
<projectedBalanceTotal.employeeId>1234567</projectedBalanceTotal.employeeId>
<projectedBalanceTotal.principalId>4573945975</projectedBalanceTotal.principalId>
<projected_balance_accrual_amount_for_the_pay_period>0</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>07212012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>VA</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>VA</leaveBalanceTotal.leaveDescription>
<projected_balance_accrual_amount_for_the_pay_period>0</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>07212012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>WR</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>WR</leaveBalanceTotal.leaveDescription>
<projected_balance_accrual_amount_for_the_pay_period>3.323</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>07212012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>SS</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>SS</leaveBalanceTotal.leaveDescription>
</leaveBalanceTotal>
<leaveBalanceTotal>
<projectedBalanceTotal.employeeId>1234567</projectedBalanceTotal.employeeId>
<projectedBalanceTotal.principalId>4573945975</projectedBalanceTotal.principalId>
<projected_balance_accrual_amount_for_the_pay_period>0</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>08042012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>VA</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>VA</leaveBalanceTotal.leaveDescription>
<projected_balance_accrual_amount_for_the_pay_period>0</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>08042012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>WR</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>WR</leaveBalanceTotal.leaveDescription>
<projected_balance_accrual_amount_for_the_pay_period>3.323</projected_balance_accrual_amount_for_the_pay_period>
<projectedBalanceTotal.effectiveDate>08042012</projectedBalanceTotal.effectiveDate>
<projectedBalanceTotal.planCodeId>SS</projectedBalanceTotal.planCodeId>
<leaveBalanceTotal.leaveDescription>SS</leaveBalanceTotal.leaveDescription>
</leaveBalanceTotal>
</BB:Report_Data>
.....等等,直到我们达到26
我已经有xslt成功处理我的删除/替换要求:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bb="urn:com.workday.report/CR-INT486-Kuali_Trojan_Time-Absence_Balances__University_Bi-Weekly_-Outbound"
exclude-result-prefixes="bb">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="comment()|processing-instruction()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="bb:All_Eligible_Time_Off_Plans_for_Worker">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="bb:Report_Data">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="bb:Report_Entry">
<leaveBalanceTotal>
<xsl:apply-templates select="node()|@*"/>
</leaveBalanceTotal>
</xsl:template>
</xsl:stylesheet>
我需要将该转换置于任何代码之上,将xml复制26次并将每个数据递增14天,如上所示。任何帮助将不胜感激!
答案 0 :(得分:0)
这是对评论主题的引用。如果你不知道你正在使用什么引擎,那么运行这个样式表并告诉我们结果。
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:output method = "text" />
<xsl:template match = "/" >
<xsl:text >
Version : </xsl:text>
<xsl:value-of select = "system-property('xsl:version')" />
<xsl:text >
Vendor : </xsl:text>
<xsl:value-of select = "system-property('xsl:vendor')" />
<xsl:text >
URL : </xsl:text>
<xsl:value-of select = "system-property('xsl:vendor-url')" />
</xsl:template>
</xsl:stylesheet>
答案 1 :(得分:0)
我正在关闭这个,因为我修改了生成xml的报告,希望简化我的任务。我在这里开了一个新问题:Complex XML to XML Transformation using XSLT