Subject: Re: [xsl] RSS feed with custom additional values - how best to transform? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 24 Apr 2009 15:58:59 -0400 |
<rss version="2.0" xmlns:customns="http://www.helpyoulist.com/customns"> <channel> ... <item> <title>2008 Acme Floor Sander</title> <guid>http://www.acmeinc.com/ACL1.html</guid> ... Here would be my XSL file:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:customns="http://www.helpyoulist.com/customns">
... <xsl:template match="item"> <xsl:if test="customns:guid='http://www.acmeinc.com/ACL1.html'"> <!-- WILL REPLACE WITH VAR LATER -->
<xsl:value-of select="title" /><br /> <!-- WORKS FINE! -->
<xsl:value-of select="customns:model" />|<br /> <!-- IT'A NO LIKA! -->
What am I missing? I've tried aliases and such to no avail.
T:\ftemp>type kent.xml <rss version="2.0" xmlns:customns="http://www.helpyoulist.com/customns"> <channel> <title>Daily listings for Acme Inc</title> <link>http://www.acmeinc.com/</link> <description>Daily listings for Acme Inc</description> <language>en-us</language> <copyright>Copyright 2009</copyright> <customns:companyName>Acme Incorporated</customns:companyName> <customns:address1>123 Main Street</customns:address1> <customns:city>Anytown</customns:city> <customns:state>NJ</customns:state> <customns:zip>12345</customns:zip> <customns:phone>(123) 555-1212</customns:phone> <customns:fax>(123) 555-1213</customns:fax> <customns:email>info@xxxxxxxxxxx</customns:email> <item> <title>2008 Acme Floor Sander</title> <guid>http://www.acmeinc.com/ACL1.html</guid> <description>What a great floor sander!</description> <customns:listingID>ACL1</customns:listingID> <customns:manufacturer>Acme</customns:manufacturer> <customns:model>FS1</customns:model> <customns:year>2008</customns:year> <customns:serial>5207</customns:serial> <customns:condition>New</customns:condition> <customns:askingPrice>519.00</customns:askingPrice> <customns:contact customns:sortOrder="1"> <customns:firstName>Raul</customns:firstName> <customns:lastName>Jones</customns:lastName> <customns:email>rjones@xxxxxxxxxxx</customns:email> <customns:phone>(123) 555-1213</customns:phone> </customns:contact> <customns:contact customns:sortOrder="2"> <customns:firstName>Brandon</customns:firstName> <customns:lastName>Boyd</customns:lastName> <customns:email>bboyd@xxxxxxxxxxx</customns:email> <customns:phone>(123) 555-1214</customns:phone> </customns:contact> </item> <item> <title>2007 Acme Belt Sander</title> <guid>http://www.acmeinc.com/ACL2556.html</guid> <description>This belt sander rules!</description> <customns:listingID>ACL2556</customns:listingID> <customns:manufacturer>Acme</customns:manufacturer> <customns:model>BS1</customns:model> <customns:year>2004</customns:year> <customns:serial>4006</customns:serial> <customns:condition>Used</customns:condition> <customns:askingPrice>299.00</customns:askingPrice> <customns:contact customns:sortOrder="1"> <customns:firstName>Brandon</customns:firstName> <customns:lastName>Boyd</customns:lastName> <customns:email>bboyd@xxxxxxxxxxx</customns:email> <customns:phone>(123) 555-1214</customns:phone> </customns:contact> <customns:contact customns:sortOrder="2"> <customns:firstName>Raul</customns:firstName> <customns:lastName>Jones</customns:lastName> <customns:email>rjones@xxxxxxxxxxx</customns:email> <customns:phone>(123) 555-1213</customns:phone> </customns:contact> </item> </channel> </rss>
T:\ftemp>type kent.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" exclude-result-prefixes="customns" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:customns="http://www.helpyoulist.com/customns">
<xsl:template match="rss/channel"> <xsl:apply-templates select="item"/> </xsl:template>
<xsl:template match="item"> <xsl:if test="guid='http://www.acmeinc.com/ACL1.html'"> <!-- WILL REPLACE WITH VAR LATER --> <xsl:value-of select="title" /><br /> <!-- WORKS FINE! --> <xsl:value-of select="customns:model" />|<br /> <!-- IT'A NO LIKA! --> </xsl:if> </xsl:template> </xsl:stylesheet>
-- XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RSS feed with custom addition, Kent Nielsen | Thread | [xsl] [xslt performance for big xml, Aditya Sakhuja |
[xsl] RSS feed with custom addition, Kent Nielsen | Date | Re: [xsl] How to sort by elements o, Leo Studer |
Month |