鉴于XML:
<expdur-entry><itemno id="exp-item1">1</itemno><maintenance lvl="f"/>
<nsn><fsc>1130</fsc><niin>00-2X3-1</niin></nsn><name>Beeswax</name><desc></desc><partno>Pure Beeswax</partno><cageno>X1148</cageno><ui>LB</ui></expdur-entry>
<expdur-entry><itemno id="exp-item2">2</itemno><maintenance lvl="f"/><nsn><fsc>X3X0</fsc>
<niin>00-221-082</niin></nsn><name>Cloth, Abrasive</name><desc></desc><partno>L9-C-4X8</partno><cageno>81348</cageno>
<ui>EA</ui></expdur-entry>
<expdur-entry><itemno id="exp-item6">3</itemno>
<maintenance lvl="f"/><nsn><fsc>130</fsc><niin>00-13-1802</niin></nsn>
<name>Cloth, Duck</name><desc></desc><partno>L9-C-433XCL 2 FGX04</partno><cageno></cageno><ui>YD</ui></expdur-entry>
<expdur-entry><itemno id="exp-item49">4</itemno><maintenance lvl="f"/>
<nsn><fsc>2X81</fsc><niin>01-331-2212</niin></nsn><name>Tape, Textile,
Nylon</name><desc></desc><partno>123-T-X38</partno>
<cageno></cageno><ui>YD</ui></expdur-entry>
<expdur-entry>
<itemno id="exp-item46">5</itemno><maintenance lvl="f"/><nsn><fsc></fsc><niin></niin></nsn><name>Cloth, Nylon Diamond Weave</name><desc></desc><partno>11-1-13</partno>
<cageno></cageno><ui></ui></expdur-entry>
<expdur-entry><itemno id="exp-item45">6</itemno><maintenance lvl="f"/><nsn><fsc></fsc><niin></niin></nsn>
<name>Cloth, Parachute, Nylon</name><desc></desc>
<partno>L9-C-4438, TY V</partno><cageno></cageno><ui></ui>
</expdur-entry>
<expdur-entry><itemno id="exp-item117">7</itemno>
<maintenance lvl="f"/><nsn><fsc>TBD</fsc><niin></niin></nsn><name>Cord, Nylon, Type X1</name><desc></desc><partno>L9-C-X1X</partno>
<cageno></cageno><ui>YD</ui></expdur-entry>
和
<bulk_itemswp>
<pi.item><qty>.08 YD</qty><common_part_ref idref="exp-item49"/>
</pi.item></bulk_itemswp>
我在pi.item
上,我希望<fsc>
与<niin>
的{{1}}同为<expdur-entry>
<itemno>
与@id
的{{1}}相匹配。在这种情况下,它是@idref
我以为我可以在<common_part_ref>
模板中执行以下操作:
<itemno id="exp-item49">
但那并没有奏效。下面的XSL-FO可行,但我怀疑它是最好的方法。如果可能的话,我宁愿纠正上面的select子句的语法。
这是我的XSLFO。
<pi.item>
答案 0 :(得分:1)
current()
XSLT函数正好解决了这个问题:
<xsl:template match="pi.item">
<fo:table-row>
<xsl:apply-templates select="//expdur-entry/itemno[
@id = current()/common_part_ref/@idref
]" mode="bulk" />
</fo:table-row>
</xsl:template>
<xsl:template match="expdur-entry/itemno" mode="bulk">
<fo:table-cell>
<fo:block>
<xsl:value-of select="concat(../nsn/fsc, '-', normalize-space(../nsn/niin))" />
</fo:block>
</fo:table-cell>
</xsl:template>
答案 1 :(得分:0)
另一个选择是使用xsl:key
...
<xsl:key name="expdurByID" match="expdur-entry" use="itemno/@id"/>
<xsl:template match="pi.item">
<fo:table-row>
<xsl:apply-templates
select="key('expdurByID',common_part_ref/@idref)" mode="bulk"/>
</fo:table-row>
</xsl:template>
<xsl:template match="expdur-entry" mode="bulk">
<fo:table-cell>
<fo:block>
<xsl:value-of select="concat(normalize-space(nsn/fsc),
'-',normalize-space(nsn/niin))"/>
</fo:block>
</fo:table-cell>
</xsl:template>