XML to XML Filtering using XSL Problem

Discussion in 'XML' started by generalr, Apr 20, 2010.

  1. generalr


    Apr 20, 2010
    Likes Received:

    I know this is a XML NG, but I figured XSL would be allowed here as they are closely related.

    I am trying to filter out XML flows based on using an if statement for an attribute of the root element of the file. For some reason, when I use the following XSLT code with the following XML File, it seems the if statement is never seen, and the XML file is always sent through.

    Do you guys have any ideas on why this is? I have scoured the internet reading how-to's and examples, but still cannot get this to work. 7 hours later, I am still not sure what I am doing wrong.

    The following XML File is simplified for simplicity here.


    Code (Text):
    XML File:

    <CarModel Year=2009>

    XSL File:

    <?xml version='1.0' encoding="ISO-8859-1"?>
                     xmlns:xsl="http: ww w3 org 1999 XSL Transform"

    <xsl:template match="/CarModel">
      <xsl:if test="@Year=2009"> <xsl:apply-templates select="A"/> </xsl:if>


    <xsl:template match="A">
        <xsl:apply-templates select="@*|node()"/>
    PS - the namespace for the XSL is accurate, I had to remove it here as it is considered a link.

    Again, what I am trying to do is only pass through XML Files that have a Year attribute equal to 2009. Once it finds one with 2009, it should copy over the XML file exactly as it was input. Otherwise, I want nothing to pass through.

    Many many thanks to whomever can spare a few minutes to tell me what I'm doing wrong. It has to be something trivial.
    generalr, Apr 20, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.