[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RSS feed with custom additional values - how best

Subject: Re: 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
Re:  RSS feed with custom additional values - how best
At 2009-04-24 14:22 -0500, Kent Nielsen wrote:
<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">

You probably want to add the following to clean up your HTML:


exclude-result-prefixes="customns"

...
<xsl:template match="item">
<xsl:if test="customns:guid='http://www.acmeinc.com/ACL1.html'"> <!--
WILL REPLACE WITH VAR LATER -->

I think that should be:


test="guid='.....'"

... and then both items appear for me.

<xsl:value-of select="title" /><br /> <!-- WORKS FINE! -->

That didn't work for me until I changed the xsl:if test.


<xsl:value-of select="customns:model" />|<br /> <!-- IT'A NO LIKA! -->

No problem once I changed the xsl:if tset.


What am I missing? I've tried aliases and such to no avail.

Just getting carried away with your prefixes is all.


I hope the running example below helps.

. . . . . . . . . Ken


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>call xslt2 kent.xml kent.xsl
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


2008 Acme Floor Sander<br>FS1|<br>

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:output method="html" version="4.01" />
<xsl:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />


<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>

T:\ftemp>rem Done!



--
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.