M
Michael Reiche
Question on XSL expression
Got this XML:
<Body>
<Page>
<Line no="9" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
<Line no="10" detail="true">
<onefield>onefieldstext</onefield>
<fgman9>fgmanfieldstext</fgman9>
<twofield>twofieldstext</twofield>
</Line>
<Line no="11" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
<Line no="12" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
<Line no="13" detail="true">
<onefield>onefieldstext</onefield>
<fgman5>fgmanfieldstext</fgman5>
<twofield>twofieldstext</twofield>
</Line>
<Line no="14" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
</Page>
</Body>
I would select the <Line/> nodes without text-node children whose names
is starting with "fgman" - in this example it is all <Line/> _except_
<fgman9/> and <fgman5/> in <Line/> with @no of 10 and 13.
I know that this works:
<xsl:for-each select="Body/Page/Line[@detail]">
<xsl:if test="count(fgman9|fgman5) = 0">
L<xsl:value-of select="@no"/>:<xsl:value-of select="onefield"/>
</xsl:if>
<xsl:if test="fgman9">
<xsl:value-of select="@no"/> Ouuch</xsl:if>
<xsl:if test="fgman5">
<xsl:value-of select="@no"/> Whoops</xsl:if>
</xsl:foreach>
But as the <fgmanXXX/> nodes could be named fgman0 to fgman1000 I would
prefer not to list everyone as arguments to the count() expression.
/Reiche
Got this XML:
<Body>
<Page>
<Line no="9" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
<Line no="10" detail="true">
<onefield>onefieldstext</onefield>
<fgman9>fgmanfieldstext</fgman9>
<twofield>twofieldstext</twofield>
</Line>
<Line no="11" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
<Line no="12" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
<Line no="13" detail="true">
<onefield>onefieldstext</onefield>
<fgman5>fgmanfieldstext</fgman5>
<twofield>twofieldstext</twofield>
</Line>
<Line no="14" detail="true">
<onefield>onefieldstext</onefield>
<twofield>twofieldstext</twofield>
</Line>
</Page>
</Body>
I would select the <Line/> nodes without text-node children whose names
is starting with "fgman" - in this example it is all <Line/> _except_
<fgman9/> and <fgman5/> in <Line/> with @no of 10 and 13.
I know that this works:
<xsl:for-each select="Body/Page/Line[@detail]">
<xsl:if test="count(fgman9|fgman5) = 0">
L<xsl:value-of select="@no"/>:<xsl:value-of select="onefield"/>
</xsl:if>
<xsl:if test="fgman9">
<xsl:value-of select="@no"/> Ouuch</xsl:if>
<xsl:if test="fgman5">
<xsl:value-of select="@no"/> Whoops</xsl:if>
</xsl:foreach>
But as the <fgmanXXX/> nodes could be named fgman0 to fgman1000 I would
prefer not to list everyone as arguments to the count() expression.
/Reiche