I am very new to XML and XSL and am having trouble. I have scoured the internet and tried nearly everything I saw and I just couldn't get it to work. What I need is to output the name of all the people whose address is a shipping address.
Here is the XML:
<?xml version="1.0"?> <PurchaseOrders> <PurchaseOrder PurchaseOrderNumber="99503" OrderDate="1999-10-20"> <Address Type="Shipping"> <Name>Ellen Adams</Name> <Street>123 Maple Street</Street> </Address> <Address Type="Billing"> <Name>Tai Yee</Name> <Street>8 Oak Avenue</Street> </Address> </PurchaseOrder> <PurchaseOrder PurchaseOrderNumber="99505" OrderDate="1999-10-22"> <Address Type="Shipping"> <Name>Cristian Osorio</Name> <Street>456 Main Street</Street> </Address> <Address Type="Billing"> <Name>Cristian Osorio</Name> <Street>456 Main Street</Street> </Address> </PurchaseOrder> and here is my xml so far - keep in mind I have no idea what I'm doing! :) :
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <html> <head> <title>Customer Info</title> </head> <body> <table border="1"> <thead> <tr bgcolor="yellow"> <th>Customer</th> </tr> </thead> <tbody> <xsl:apply-templates /> </tbody> </table> </body> </html> </xsl:template> <xsl:template match="PurchaseOrder"> <tr> <xsl:for-each select="Address"> <xsl:value-of select=" .[@Type="Shipping"> <td> <xsl:value-of select="Name" /> </td> </xsl:if> </xsl:for-each> </tr> </xsl:template> </xsl:stylesheet> I've tried everything from including an if statement to changing the code around but nothing seems to work.
Thanks for your help!
No comments:
Post a Comment