[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Xpath Syntax Issue

Subject: [xsl] Xpath Syntax Issue
From: Nathan Tallman <ntallman@xxxxxxxxx>
Date: Sat, 23 Jun 2012 15:48:46 -0400

I'm trying to remove an entire element, if the value of one of its
child elements equals x.

XML Input example:


XSLT Goal: Remove all animal elements if species=fish

XML Output desired:

Here's my current XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="xsl ead xlink xsi" version="1.0">

    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:strip-space elements="*"/>

    <!-- Standard copy -->
    <xsl:template match="*">
            <xsl:copy-of select="@*"/>

    <xsl:template match="pets/animal/species[text()='fish']"/>


But all my outputs still have fish. I'm using XSLT 1.0 and I'm having
a problem with the xpath, I think. My XML reference book is at work,
and I can't quite get the xpath syntax right, can someone point out my

Many thanks,

Current Thread