使用XSLT进行复杂的XML到XML转换



这对你们来说可能并不复杂,但对我来说非常困难。这是我的第二次尝试。我已经更改了我的数据,以包含更多的信息,从而减少转换所需的时间。

基本上,我试图获取由三个假期计划(VA、SS和WR)组成的数据,并预测出每个计划在每个工资期、每个工人一整年的累计时间。我只在我的数据中包括了三个支付期,以保持它的简短性(呃)。我需要每个员工/生效日期组合的单独记录。因此,如果一名员工有三个假期计划,并且每两周(26次/年)获得工资,那么该员工可能有78项记录。

以下是我开始使用的XML(请记住,在我的示例中,我只使用前3个付款期日期,而不是全部26个):

 <?xml version='1.0' encoding='UTF-8'?>
<bb:Report_Data xmlns:bb="urn:com.workday.report/Projected_Balances_Outbound">
   <bb:Report_Entry>
      <bb:projectedBalanceTotal.principalId>1238974569</bb:projectedBalanceTotal.principalId>
      <bb:All_Eligible_Time_Off_Plans_for_Worker>
         <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
         <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
         <bb:projected_balance_accrual_amount_for_the_pay_period>3.323</bb:projected_balance_accrual_amount_for_the_pay_period>
         <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
         <bb:projectedBalanceTotal.effectiveDate2>07252012</bb:projectedBalanceTotal.effectiveDate2>
         <bb:projectedBalanceTotal.effectiveDate3>08082012</bb:projectedBalanceTotal.effectiveDate3>
      </bb:All_Eligible_Time_Off_Plans_for_Worker>
      <bb:All_Eligible_Time_Off_Plans_for_Worker>
         <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
         <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
         <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
         <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
         <bb:projectedBalanceTotal.effectiveDate2>07252012</bb:projectedBalanceTotal.effectiveDate2>
         <bb:projectedBalanceTotal.effectiveDate3>08082012</bb:projectedBalanceTotal.effectiveDate3>
      </bb:All_Eligible_Time_Off_Plans_for_Worker>
      <bb:All_Eligible_Time_Off_Plans_for_Worker>
         <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
         <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
         <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
         <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
         <bb:projectedBalanceTotal.effectiveDate2>07252012</bb:projectedBalanceTotal.effectiveDate2>
         <bb:projectedBalanceTotal.effectiveDate3>08082012</bb:projectedBalanceTotal.effectiveDate3>
      </bb:All_Eligible_Time_Off_Plans_for_Worker>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </bb:Report_Entry>
   <bb:Report_Entry>
      <bb:projectedBalanceTotal.principalId>4545645878</bb:projectedBalanceTotal.principalId>
      <bb:All_Eligible_Time_Off_Plans_for_Worker>
         <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
         <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
         <bb:projected_balance_accrual_amount_for_the_pay_period>3.692</bb:projected_balance_accrual_amount_for_the_pay_period>
         <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
         <bb:projectedBalanceTotal.effectiveDate2>07252012</bb:projectedBalanceTotal.effectiveDate2>
         <bb:projectedBalanceTotal.effectiveDate3>08082012</bb:projectedBalanceTotal.effectiveDate3>
      </bb:All_Eligible_Time_Off_Plans_for_Worker>
      <bb:All_Eligible_Time_Off_Plans_for_Worker>
         <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
         <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
         <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
         <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
         <bb:projectedBalanceTotal.effectiveDate2>07252012</bb:projectedBalanceTotal.effectiveDate2>
         <bb:projectedBalanceTotal.effectiveDate3>08082012</bb:projectedBalanceTotal.effectiveDate3>
      </bb:All_Eligible_Time_Off_Plans_for_Worker>
      <bb:All_Eligible_Time_Off_Plans_for_Worker>
         <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
         <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
         <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
         <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
         <bb:projectedBalanceTotal.effectiveDate2>07252012</bb:projectedBalanceTotal.effectiveDate2>
         <bb:projectedBalanceTotal.effectiveDate3>08082012</bb:projectedBalanceTotal.effectiveDate3>
      </bb:All_Eligible_Time_Off_Plans_for_Worker>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </bb:Report_Entry>
</bb:Report_Data>

这就是我需要的输出在转换后的样子:

<?xml version='1.0' encoding='UTF-8'?>
<bb:Report_Data xmlns:bb="urn:com.workday.report/Projected_Balances_Outbound">
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569</bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>3.323</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>3.323</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07252012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>3.323</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>08082012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07252012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>08082012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07252012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>1238974569/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>08082012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>123454</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>

   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>3.692</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>3.692</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07252012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>SS</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>SS</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>3.692</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>08082012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07252012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>WR</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>WR</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>08082012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07112012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>07252012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
   <projectedBalanceTotal>
      <bb:projectedBalanceTotal.principalId>4545645878/bb:projectedBalanceTotal.principalId>
      <bb:projectedBalanceTotal.planCodeId>VA</bb:projectedBalanceTotal.planCodeId>
      <bb:projectedBalanceTotal.leaveCodeId>VA</bb:projectedBalanceTotal.leaveCodeId>
      <bb:projected_balance_accrual_amount_for_the_pay_period>0</bb:projected_balance_accrual_amount_for_the_pay_period>
      <bb:projectedBalanceTotal.effectiveDate1>08082012</bb:projectedBalanceTotal.effectiveDate1>
      <bb:projectedBalanceTotal.employeeid>445241</bb:projectedBalanceTotal.employeeid>
   </projectedBalanceTotal>
</bb:Report_Data>

还有几件事需要注意。。。除了格式更改外,我还将完全删除元素标记"All_Eligible_Time_Off_Plans_for_Worker",并将"bb:Report_Entry"替换为"projectedBalanceTotal"。

我几乎没有起点,只是我编写了XSL代码,成功地删除了"All_Eligible_Time_Off_Plans_for_Worker"并用"projectedBalanceTotal"替换了"bb:Report_Entry"。可以在这里找到:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:wd="urn:com.workday.report/CR-INT486-Kuali_Trojan_Time-Absence_Balances__Hospital_Bi-Weekly_-Outbound" 
    exclude-result-prefixes="wd">
    <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="wd:All_Eligible_Time_Off_Plans_for_Worker">
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="wd:Report_Data">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="wd:Report_Entry">
        <projectedleaveBalanceTotal>
            <xsl:apply-templates select="node()|@*"/>
        </projectedleaveBalanceTotal>
    </xsl:template>
</xsl:stylesheet>

任何帮助都会很棒!提前非常感谢。

试试这个。。。

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:bb="urn:com.workday.report/Projected_Balances_Outbound">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
 <bb:Report_Data>
   <xsl:apply-templates select="*/*/*/*[starts-with(local-name(),'projectedBalanceTotal.effectiveDate')]"/>
 </bb:Report_Data>
</xsl:template>
<xsl:template match="*">
<!-- Add predicate [starts-with(local-name(),'projectedBalanceTotal.effectiveDate')]
     to the match pattern if you feel like it. -->
   <projectedBalanceTotal>
     <xsl:copy-of select="
       ../../bb:projectedBalanceTotal.principalId  |
       ../bb:projectedBalanceTotal.planCodeId      |
       ../bb:projectedBalanceTotal.leaveCodeId     |
       ../bb:projected_balance_accrual_amount_for_the_pay_period |
       .                                           |
       ../../bb:projectedBalanceTotal.employeeid"   />
   </projectedBalanceTotal>
</xsl:template>
</xsl:stylesheet>

洞穴

这输出<bb:projectedBalanceTotal.effectDate\d>节点,其中"\d"表示某个整数。在您的示例输入中,您有生效日期1、生效日期2等。但是在您的预期输出中只有生效日期1。我没有费心将所有有效日期节点重命名为有效日期1,因为这很可能只是您的一个笔误。因此,如果您要求所有effectiveDate\d节点都精确地调用effectiveDate1,那么请相应地进行调整。

学习笔记

如果你想在未来自行解决类似的问题,试试这种技术:

  1. 删除所有名称空间,除非名称空间是要解决的问题的固有部分
  2. 将所有长节点名称替换为短的、令人难忘的名称,如(香蕉、苹果、梨)
  3. 简化和消除节点,直至问题的真正核心。如果有两种节点类型banana和apple按照相同的规则处理,那么只需在示例数据中使用banana即可
  4. 生成与转换规则的复杂性成比例的多个用例,并尝试使用例覆盖边缘条件,并且范围广泛
  5. 对待XSLT要像对待任何其他编程语言一样。如果你必须用Java编写一个程序,但你一开始对该语言一无所知,你会买一本书或参加培训课程,对吧?就像任何其他语言一样,你不能仅仅通过看SO上的例子来学习它

更新

OP要求对样式表进行修改,使effectiveDate元素成为其本地名称中没有嵌入数字的输出。以下是变化。。。

  1. 将大xsl:copy-of分解为三部分。一个在点(.)前面,一个在点号(.)后面,一个用于点号(即employeeid)。所以前面的部分看起来是这样的。。。

     <xsl:copy-of select="
       ../../bb:projectedBalanceTotal.principalId  |
       ../bb:projectedBalanceTotal.planCodeId      |
       ../bb:projectedBalanceTotal.leaveCodeId     |
       ../bb:projected_balance_accrual_amount_for_the_pay_period" />
    
  2. 对于中间位(在esse中,xsl:copy-of-select="."),我们不能使用的副本,因为我们想更改名称。所以我们用这样的文字元素来代替。。。

     <bb:projectedBalanceTotal.effectiveDate>
      <xsl:value-of select="." />
     </bb:projectedBalanceTotal.effectiveDate>
    
  3. 第三位也是最后一位与第一位类似,但仅针对employeeid元素。

总之,我们得到了我们的模板。。。

<xsl:template match="*">
   <projectedBalanceTotal>
     <xsl:copy-of select="
       ../../bb:projectedBalanceTotal.principalId  |
       ../bb:projectedBalanceTotal.planCodeId      |
       ../bb:projectedBalanceTotal.leaveCodeId     |
       ../bb:projected_balance_accrual_amount_for_the_pay_period" />
     <bb:projectedBalanceTotal.effectiveDate>
      <xsl:value-of select="." />
     </bb:projectedBalanceTotal.effectiveDate>
     <xsl:copy-of select="../../bb:projectedBalanceTotal.employeeid" />
   </projectedBalanceTotal>
</xsl:template>

相关内容

  • 没有找到相关文章

最新更新