这是我第一次使用XSLT文件。我必须使用XSL文件更改报告,我有以下问题:
要选择正确的属性,我使用以下XSL代码:
<xsl:for-each select="MSMResults/MSMVarContribs/Contrib">
<xsl:variable name="PrtAsmType"><xsl:value-of select="@PrtAsmType"/></xsl:variable>
<xsl:variable name="CadName"><xsl:value-of select="@PrtAsmCadName"/></xsl:variable>
<xsl:variable name="ContribType"><xsl:value-of select="@Type"/></xsl:variable>
<xsl:variable name="ID"><xsl:value-of select="@ID"/></xsl:variable>
<xsl:value-of select="/CETOLReport/PrtAsm[@Type=$PrtAsmType and @CadName=$CadName and /Feature/SizeDimension/Variable/@ID=$ID]//SizeDimension/@Note"/>
这是XML文件(缩写):
<CETOLReport>
<PrtAsm Type="PART" CadName="PRT0001" Name="PRT0001">
<VariationRule>
<Alerts Count="0"/>
<Feature>
...
</Feature>
...
<Feature Note="">
<Alerts Count="0"/>
<SizeDimension Note="PRT001
dim.# 01">
<Tolerance Lower="0.1" Upper="0.2"/>
<VariationRule ControlSkew="TRUE"/>
...
<Variable Note="" Nominal="9" ID="12">
<Distribution Mean="9.149999999999999"/>
<Alerts Count="0"/>
</Variable>
</SizeDimension>
<Dimension>
...
</Dimension>
<Dimension>
...
</Dimension>
</Feature>
<Feature>
...
</Feature>
</PrtAsm>
</CETOLReport>
总结:
我必须匹配
Type
<PrtAsm>
CadName
<PrtAsm>
ID
<PrtAsm/Feature/SizeDimension/Variable>
并作为我想要的输出
Note
<PrtAsm/Feature/SizeDimension>
我需要改变什么
<xsl:value-of select="/CETOLReport/PrtAsm[@Type=$PrtAsmType and @CadName=$CadName and /Feature/SizeDimension/Variable/@ID=$ID]//SizeDimension/@Note"/>
能得到正确的答案吗?
答案 0 :(得分:0)
我会尝试:
<xsl:value-of select="/CETOLReport/PrtAsm[@Type=$PrtAsmType and @CadName=$CadName and Feature/SizeDimension/Variable/@ID=$ID]/Feature/SizeDimension[1]/@Note"/>
答案 1 :(得分:0)
试试这个......
awk -F'|' '{printf "%s%s", (NF==4&&NR>1?RS:""),$0}END{print ""}' file