This is my first time working with XSLT files. I have to change a report using a XSL file and I have the following problem:
- I have 3 variables which have to match to identify my right XML tag
- One of these variable is defined in a sub-sub-tag
- My result is located in the first sub-tag
To choose the right attribute, I use the following XSL code:
<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"/>
This is the XML file (shortened):
<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>
Summed up:
I have to match
- the attribute
Type
in<PrtAsm>
- the attribute
CadName
in<PrtAsm>
- the attribute
ID
in<PrtAsm/Feature/SizeDimension/Variable>
and as an output I want
- the attribute
Note
in<PrtAsm/Feature/SizeDimension>
What do I have to change in
<xsl:value-of select="/CETOLReport/PrtAsm[@Type=$PrtAsmType and @CadName=$CadName and /Feature/SizeDimension/Variable/@ID=$ID]//SizeDimension/@Note"/>
to get the right answer?