M
Malcolm Dew-Jones
I have a test= that works but I would like to figure out how to move it
into a match=. (Ok, that's unclear but pls keep reading.)
Part of my XSLT file looks like this.
<xsl:template match="@*|node()">
<xsl:choose>
<xsl:when test="
count(.//w:fldSimple/@w:instr[contains(.,'FOP')=true()])=1
and
count(.//w:fldSimple/@w:instr[contains(.,'FOP ')=true()])=1
and
count(..//w:fldSimple/@w:instr[contains(.,'FOP')=true()])=2
">
... do something here ...
</xsl:when>
<xsltherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsltherwise>
</xsl:choose>
</xsl:template>
As you can see, what I have is a single template that matches every node,
and then an xsl:choose with a test= expression to handle certain nodes
seperately. I did it this way because I could not figure out how to write
that long test= expression as a match= expression in its own template.
What I want would look like the following, except that this doesn't work
of course.
<xsl:template match="
count(.//w:fldSimple/@w:instr[contains(.,'LOOP')=true()])=1
and
count(.//w:fldSimple/@w:instr[contains(.,'LOOP ')=true()])=1
and
count(..//w:fldSimple/@w:instr[contains(.,'LOOP')=true()])=2
">
... do something here ...
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
My problem is that I dont understand the syntax I need to use for the
match expression to make this work this way. The match has to select a
set of nodes where for each node that test is true - but I don't know how
to write that, and hence this post.
Feedback welcome, thanks.
Malcolm
into a match=. (Ok, that's unclear but pls keep reading.)
Part of my XSLT file looks like this.
<xsl:template match="@*|node()">
<xsl:choose>
<xsl:when test="
count(.//w:fldSimple/@w:instr[contains(.,'FOP')=true()])=1
and
count(.//w:fldSimple/@w:instr[contains(.,'FOP ')=true()])=1
and
count(..//w:fldSimple/@w:instr[contains(.,'FOP')=true()])=2
">
... do something here ...
</xsl:when>
<xsltherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsltherwise>
</xsl:choose>
</xsl:template>
As you can see, what I have is a single template that matches every node,
and then an xsl:choose with a test= expression to handle certain nodes
seperately. I did it this way because I could not figure out how to write
that long test= expression as a match= expression in its own template.
What I want would look like the following, except that this doesn't work
of course.
<xsl:template match="
count(.//w:fldSimple/@w:instr[contains(.,'LOOP')=true()])=1
and
count(.//w:fldSimple/@w:instr[contains(.,'LOOP ')=true()])=1
and
count(..//w:fldSimple/@w:instr[contains(.,'LOOP')=true()])=2
">
... do something here ...
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
My problem is that I dont understand the syntax I need to use for the
match expression to make this work this way. The match has to select a
set of nodes where for each node that test is true - but I don't know how
to write that, and hence this post.
Feedback welcome, thanks.
Malcolm