Xslt 移动元素并按子元素进行限制

Xslt 移动元素并按子元素进行限制,xslt,Xslt,我正在尝试仅移动子记录中的元素。当我对一名员工运行xsl时,结果符合预期。但是,对两个或多个雇员运行xsl的结果并不理想 xml 2. 0000000 AA 位置1 bad1 古德1 a001 aa1 aa2 aa3 0000000bb 位置2 bad2 古德2 b001 bb1 bb2 bb3 xsl: 输出: <?xml version="1.0" encoding="UTF-8"?> <xx:Payroll_Extract_Employees xm

我正在尝试仅移动子记录中的元素。当我对一名员工运行xsl时,结果符合预期。但是,对两个或多个雇员运行xsl的结果并不理想

xml


2.
0000000 AA
位置1
bad1
古德1
a001
aa1
aa2
aa3
0000000bb
位置2
bad2
古德2
b001
bb1
bb2
bb3
xsl:


输出:

    <?xml version="1.0" encoding="UTF-8"?>
    <xx:Payroll_Extract_Employees xmlns:xx="urn:com.me/a">
    <xx:PayGroup>
    <xx:Header>
    <xx:recs>2</xx:recs>
    </xx:Header>
    <xx:Employee>
    <xx:Summary>
    <xx:Employee_ID>0000000aa</xx:Employee_ID>
    <xx:Payroll_ID xx:PriorValue="">a001</xx:Payroll_ID>
    <xx:Payroll_ID xx:PriorValue="">b001</xx:Payroll_ID>
    </xx:Summary>
    <xx:Position>
    <xx:Position_ID xx:PriorValue="">Pos1</xx:Position_ID>
    <xx:Organization_One xx:PriorValue="a">aa1</xx:Organization_One>
    <xx:Organization_One xx:PriorValue="b">bb1</xx:Organization_One>
    <xx:Organization_Two xx:PriorValue="a">aa2</xx:Organization_Two>
    <xx:Organization_Two xx:PriorValue="b">bb2</xx:Organization_Two>
    <xx:Organization_Four xx:PriorValue="a">aa3</xx:Organization_Four>
    <xx:Organization_Four xx:PriorValue="b">bb3</xx:Organization_Four>
    <xx:Organization_Three xx:PriorValue="">good1</xx:Organization_Three>
    </xx:Position>
    <xx:Additional_Information>
    <xx:Payroll_ID xx:PriorValue="">a001</xx:Payroll_ID>
    <xx:Organization_One xx:PriorValue="a">aa1</xx:Organization_One>
    <xx:Organization_Two xx:PriorValue="a">aa2</xx:Organization_Two>
    <xx:Organization_Four xx:PriorValue="a">aa3</xx:Organization_Four>
    </xx:Additional_Information>
    </xx:Employee>
    <xx:Employee>
    <xx:Summary>
    <xx:Employee_ID>0000000bb</xx:Employee_ID>
    <xx:Payroll_ID xx:PriorValue="">a001</xx:Payroll_ID>
    <xx:Payroll_ID xx:PriorValue="">b001</xx:Payroll_ID>
    </xx:Summary>
    <xx:Position>
    <xx:Position_ID xx:PriorValue="">Pos2</xx:Position_ID>
    <xx:Organization_One xx:PriorValue="a">aa1</xx:Organization_One>
    <xx:Organization_One xx:PriorValue="b">bb1</xx:Organization_One>
    <xx:Organization_Two xx:PriorValue="a">aa2</xx:Organization_Two>
    <xx:Organization_Two xx:PriorValue="b">bb2</xx:Organization_Two>
    <xx:Organization_Four xx:PriorValue="a">aa3</xx:Organization_Four>
    <xx:Organization_Four xx:PriorValue="b">bb3</xx:Organization_Four>
    <xx:Organization_Three xx:PriorValue="">good2</xx:Organization_Three>
    </xx:Position>
    <xx:Additional_Information>
    <xx:Payroll_ID xx:PriorValue="">b001</xx:Payroll_ID>
    <xx:Organization_One xx:PriorValue="b">bb1</xx:Organization_One>
    <xx:Organization_Two xx:PriorValue="b">bb2</xx:Organization_Two>
    <xx:Organization_Four xx:PriorValue="b">bb3</xx:Organization_Four>
    </xx:Additional_Information>
    </xx:Employee>
    </xx:PayGroup>
    </xx:Payroll_Extract_Employees>

2.
0000000 AA
a001
b001
位置1
aa1
bb1
aa2
bb2
aa3
bb3
古德1
a001
aa1
aa2
aa3
0000000bb
a001
b001
位置2
aa1
bb1
aa2
bb2
aa3
bb3
古德2
b001
bb1
bb2
bb3
对于员工1,我不想要任何以“b”开头的值,对于员工2,我不想要任何以“a”开头的值


是否可以添加一个简单的参数来限制每个员工对模板的应用?

问题在于表达式

<xsl:copy-of select="/xx:Payroll_Extract_Employees/xx:PayGroup/xx:Employee/xx:Additional_Information/xx:Payroll_ID"/>
类似地,对于
组织机构\
选择

<xsl:copy-of select="//xx:Additional_Information/xx:Organization_One"/>

这应该变成这个

<xsl:copy-of select="ancestor::xx:Employee/xx:Additional_Information/xx:Organization_One"/>


oops,忘记了XSL。请编辑问题并添加XML、XSL和输出,而不是图像。这有助于其他人复制内容以找到问题的根本原因。感谢Tim的快速响应。布莱恩特:如果有帮助,请回答这个问题。谢谢
<xsl:copy-of select="ancestor::xx:Employee/xx:Additional_Information/xx:Payroll_ID"/>
<xsl:copy-of select="//xx:Additional_Information/xx:Organization_One"/>
<xsl:copy-of select="ancestor::xx:Employee/xx:Additional_Information/xx:Organization_One"/>