user2142815
user2142815

Reputation: 1

XSLT - match doesn't seem to work

I have this line in my transform:

<xsl:template match="simplesect[@kind='since']">

When I apply it to the following:

    <detaileddescription>
    <para><simplesect kind="since">
    <para>yesterday</para>
    </simplesect></para></detaileddescription>

I expect it to work.

However, I noticed that a space needs to exist between and tags.

So the following matches where the above doesn't

    <detaileddescription>
    <para> <simplesect kind="since">
    <para>yesterday</para>
    </simplesect></para></detaileddescription>

I'm stumped. Any ideas why or is here a call I make? Right now, the only solution I have is to find every instance of <para><simplesect @kind="since">and changing it to <para> <simplesect @kind=since. Notice the space between <para> and <simplesect>

Upvotes: 0

Views: 101

Answers (1)

Joel M. Lamsen
Joel M. Lamsen

Reputation: 7173

This stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="simplesect[@kind='since']">
        <modified><xsl:apply-templates/></modified>
    </xsl:template>

</xsl:stylesheet>

when applied to the first input, produces:

<?xml version="1.0" encoding="utf-8"?>
<detaileddescription>
    <para>
        <modified>
            <para>yesterday</para>
        </modified>
    </para>
</detaileddescription>

Upvotes: 1

Related Questions