Nasko26 0 Newbie Poster

Hello,

I need some help here, please.
I want to implement a custom XSLT function to filter a list of people. It is supposed to make a simple comparison and output the ones matching the filter but it is not working properly.

Thanks in advance!

Here are my files:
----------
person.xml
----------

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="person.xsl"?>
<!DOCTYPE person_list SYSTEM "validator.dtd">

<person_list>
	<person id="1" name="John Smith">
		<age>35</age>
		<height units="cm">173</height>
		<weight units="kg">75</weight>
	</person>
	<person id="2" name="Tom Stone">
		<age>26</age>
		<height units="cm">177</height>
		<weight units="kg">65</weight>
	</person>
	<person id="3" name="Mark Glennford">
		<age>17</age>
		<height units="cm">181</height>
		<weight units="kg">61</weight>
	</person>
</person_list>

----------
person.xsl
----------

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:my="http://www.mysite.com/my">

  <xsl:function name="my:age">
    <xsl:param name="age"/>

	<xsl:for-each select="person_list/person">
      <xsl:if test="age &gt; $age">
        <!-- code to display data: age, height, weight-->
      </xsl:if>
    </xsl:for-each>
  </xsl:function>

<xsl:template match="/">
	<xsl:value-of select="my:age(18)"/><!-- isn't it supposed to output the data for person with ids "1" and "2"? -->
</xsl:template>

</xsl:stylesheet>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.