Guys,
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.
TIA,
David
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.
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.
TIA,
David
Code:
XML File:
<CarModel Year=2009>
<A>
<B>
<B>
</A>
</CarModel>
XSL File:
<?xml version='1.0' encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http: ww w3 org 1999 XSL Transform"
version="2.0">
<xsl:template match="/CarModel">
<xsl:if test="@Year=2009"> <xsl:apply-templates select="A"/> </xsl:if>
</xsl:template>
<xsl:template match="A">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
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.