1

我在这里尝试做 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 天的任何代码之上,如上所示。任何帮助,将不胜感激!

4

2 回答 2

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>
于 2012-07-23T16:15:11.950 回答
0

我正在关闭它,因为我修改了生成 xml 的报告,希望能简化我的任务。我在这里提出了一个新问题: Complex XML to XML Transformation using XSLT

于 2012-07-24T21:53:50.983 回答