Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Dynamic RSS >Thread Next - Re: Dynamic RSS Re: Dynamic RSSTo: NULL Date: 4/7/2009 9:17:00 PM Yes I see.
The identity template you're using matching @* | * (any attribute, or
any node, including text nodes) isn't quite what I'd use. The one I'd
use is here : http://www.xmlplease.com/xsltidentity#s1 which matches
@* | node() (but excludes text nodes as far as I understand)
It's also possible that the <rss /> parent element is in a namespace
in your non-working documents.
This will typically be the case I think for RSS1 (the examples you've
shown indicate RSS2) or if you have media RSS extensions like <video
/> or podcast related content in the feed.
If the XSL template doesn't also know about that namespace, it will
probably not "see" any nodes which are in the namespace.
It's a tricky concept to follow and explain.
In your case, this article http://www.xml.com/pub/a/2003/01/02/tr.html
should indicate how to proceed. It's pretty much a case of declaring
the rss namspaces in the xsl:stylesheet, so instead of just
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
you would add the purl namespace
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0">
So if your RSS, when viewed in notepad, contains xmlns:dc, then add
that to the xsl:stylesheet, Same-as for mediaRSS extension (which is
quite common) xmlns:media="http://search.yahoo.com/mrss" - for details
see http://www.feedforall.com/mediarss.htm
HTH
Cheers - Neil
On Mon, 6 Apr 2009 20:39:01 -0700, Kass
<Kass@d...> wrote:
>Neil,
>
>Please excuse the double posting, but I've just found something that might
>help.
>
>I researched Identity Template as suggested and I get the concept, alto' am
>far from totally grasping. I tried the code below in the .xsl template. Does
>a global target and replace.
>
>At first it didn't look like it worked either, but after some pondering and
>trial and error with another .xml file, I realized it WORKED ****BUT not if
>the RSS tags are included in the .xml file***. If I remove the <rss
>version="2.0"> </rss> tags from around the <channel>.... </channel>
>information (so it is just like regular .xml) then the replace code finds the
>text and replaces it... but as you suggested, the whole thing is in one long
>paragraph... altho' this could also be due to the "<xsl:value-of select=
> "concat(substring-before($outputString,$target),
> $replacement)"/>" part of the globalReplace template.
>
>Here is the new code:
>
><?xml version="1.0" encoding="utf-8"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>
><!-- Find and Replace Text Template -->
>
><xsl:template name="globalReplace">
> <xsl:param name="outputString"/>
> <xsl:param name="target"/>
> <xsl:param name="replacement"/>
> <xsl:choose>
> <xsl:when test="contains($outputString,$target)">
>
> <xsl:value-of select=
> "concat(substring-before($outputString,$target),
> $replacement)"/>
> <xsl:call-template name="globalReplace">
> <xsl:with-param name="outputString"
> select="substring-after($outputString,$target)"/>
> <xsl:with-param name="target" select="$target"/>
> <xsl:with-param name="replacement"
> select="$replacement"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$outputString"/>
> </xsl:otherwise>
> </xsl:choose>
></xsl:template>
>
><xsl:template match="text()">
> <xsl:call-template name="globalReplace">
> <xsl:with-param name="outputString" select="."/>
> <xsl:with-param name="target" select="'Thu, 02 Apr 2009 13:00:00 CST'"/>
> <xsl:with-param name="replacement" select="'Thu, 09 Apr 2009 13:00:00
>CST'"/>
> </xsl:call-template>
></xsl:template>
>
><xsl:template match="@*|*">
> <xsl:copy>
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
></xsl:template>
>
></xsl:stylesheet>
>
>
>Well, at least I got some results... My 'ol brains are fried, scrambled and
>hard boiled... got any ideas?
>
>Thanks for your time one this one! You guys are awsome!
>
>Kass
>
>
>"Neil Smith [MVP Digital Media]" wrote:
>
>> You're approximately on the right track, as it seems you just want t6o
>> use XSL to replace the pubDate value in the feed XML.
>>
>> However you're missing something important there :
>>
>> The XSL processor moves through each rule in the stylesheet, trying to
>> match the template match to a node.
>>
>> If it doesn't find a match for any node, it'll likely end up
>> outputting the text of each node in the input XMP (RSS) - the default
>> for an XSL processor with no matches is to output only text nodes.
>>
>>
>> The result would look like all the text inside the RSS feed, run
>> together and I'm guessing thats what you mean by doesnt work, if
>> you've visually inspecteed the output.
>>
>>
>> You need to take a look on your favourite search engine for "Identity
>> Template". That copies all input XML nodes to the output.
>>
>> However - here's the kicker. You can use the additional template rules
>> you have below, to substitute matches (//pubDate) with the new value,
>> but leave all other input unchanged. You're doing a copy for nodes
>> with no xsl:template match, and a change, for ones with a rule (match)
>>
>> PS - Joe can back me up on this : "Pub-Date" has an entirely different
>> connotation in the UK (where we both are) and has happy associations
>> with Fridays and pinot grog (grigot), among other beverages <g>
>>
>> Cheers - Neil
>>
>>
>> On Mon, 6 Apr 2009 10:30:01 -0700, Kass
>> <Kass@d...> wrote:
>>
>> >Joe,
>> >
>> >Please excuse didn't reply properly.... but wanted this attached to your
>> >thread.
>> >
>> >I did some research on xslt. I think this is my answer, but I'm not getting
>> >desired results. Since my experience with xml lies solely with our RSS
>> >feeds, ignorance is probably the issue here.
>> >
>> >I'm excited tho' cuz once I get this problem solved, I'm going to tackle
>> >using xlst to render our feeds in html and "pretty" them up a bit. So thanks
>> >for this HUGH lead!
>> >I'm just starting with getting the pubDate changed. I'll tackle each
>> >problem as I get success.
>> >
>> >Okay, here is some code. Thanks again for your help!
>> >
>> >feed.xml:
>> >
>> ><?xml version="1.0" encoding="utf-8"?>
>> ><?xml-stylesheet href="getRSS.xsl" type="text/xsl"?>
>> ><rss version="2.0">
>> >
>> > <channel>
>> > <title>Movie Theater Example - Someplace, CA</title>
>> > <pubDate>Thursday, 02 April 2009 20:00:00 CST</pubDate>
>> > <lastBuildDate>Thursday, 02 April 2009 20:00:00 CST</lastBuildDate>
>> > <description>Starting April 3, 2009 … Features and showtimes for Movie
>> >Theater Example - Someplace, CA</description>
>> > <language>en-us</language>
>> > <link>https://example.tstickets.com/example.aspx?theatreid=3002</link>
>> > <copyright>Copyright 2008, Movie Theater LP</copyright>
>> ><webMaster></webMaster>
>> >
>> > <item>
>> > <title>Showing the Week of April 3rd - April 9th Someplace,
>> >CA</title>
>> >
>> > <link>https://example.tstickets.com/example.aspx?theatreid=3002</link>
>> > <pubDate>Thursday, 02 April 2009 20:00:00 CST</pubDate>
>> > <description>Features Starting April 3, 2009 for Movie Theater
>> >Example - Someplace, CA</description>
>> > </item>
>> >
>> > <item>
>> > <title>Top Hits Playing at Select Movie Theater Example April 3,
>> >2009!</title>
>> > <link>http://www.example.com/comingsoon/discount.asp</link>
>> > <pubDate>Thursday, 02 April 2009 20:00:00 CST</pubDate>
>> > <description>New arrivals on the discount theater line up this week are
>> >"The Reader", "Friday the 13th", "Push", "Street Fighter: The Legend of
>> >Chun-Li" and "Fired Up". Check your local Movie Theater Example for current
>> >movie listings!</description>
>> > </item>
>> >
>> >
>> > <item>
>> > <title>Tickets On Sale Now for Disney's Earth Starting April 22,
>> >2009!</title>
>> > <link>http://www.example.com</link>
>> > <pubDate>Thursday, 02 April 2009 20:00:00 CST</pubDate>
>> > <description>Disney's DISNEYNATURE series debuts this April. Among the
>> >first films to be released domestically under the new label will be Earth,
>> >showing at select theaters starting April 22, 2009. Book your group today
>> >for this amazing journey across our planet!</description>
>> > </item>
>> >
>> >
>> > <item>
>> > <title>Showing the Week of April 3rd - April 9th</title>
>> > <link>http://www.example.com</link>
>> > <pubDate>Thursday, 02 April 2009 20:00:00 CST</pubDate>
>> > <description>Movie Theater Example Features for the Week of April 3,
>> >2009</description>
>> > </item>
>> >
>> > <item>
>> > <title>Movie Theater Example Discount Theaters April 3, 2009
>> >Updates</title>
>> > <link>http://www.example.com/comingsoon/discount.asp</link>
>> > <pubDate>Thursday, 02 April 2009 20:00:00 CST</pubDate>
>> > <description>Check out the films available soon for release in discount
>> >theaters.</description>
>> > </item>
>> >
>> >
>> >
>> ></channel>
>> ></rss>
>> >
>> >
>> >Here is the style sheet code... I tried both templates to no avail.
>> >
>> >getRSS.xls:
>> >
>> ><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> > version="2.0">
>> >
>> ><!-- Template try 1 -->
>> ><xsl:template match="//pubDate">
>> > <xsl:value-of select="replace(.,'Thu, 02 Apr 2009 13:00:00 CST','Thu, 09
>> >Apr 2009 13:00:00 CST')"/>
>> ></xsl:template>
>> >
>> >
>> ><!-- Template try 2 -->
>> >
>> ><xsl:template match="pubDate">
>> > <xsl:if test=". = 'Thu, 02 Apr 2009 13:00:00 CST'">
>> > Thu, 09 Apr 2009 13:00:00 CST </xsl:if>
>> ></xsl:template>
>> >
>> ></xsl:stylesheet>
>> >
>> >
>> >
>> >"Joe Fawcett" wrote:
>> >
>> >> You can possibly use the document function to bring in external document to
>> >> an XSLT stylesheet and then extract data from each of them.
>> >> Without a small concrete example of what exactly you need it's hard to give
>> >> more specific advice.
>> >>
>> >> --
>> >>
>> >> Joe Fawcett (MVP - XML)
>> >> http://joe.fawcett.name
>> >> "Kass" <Kass@d...> wrote in message
>> >> news:8908EA26-D244-40B3-AFED-03EF5145DDC7@m......
>> >> > Martin,
>> >> >
>> >> > Thank you for your reply.
>> >> > Here is what I'm trying to do... hoping I can stay within the .xml format.
>> >> > That is why I'm in your forum, rather than PHP. I'm trying to figure out
>> >> > if
>> >> > it is possible to dynamically link parts of .xml nodes to a separate file
>> >> > in
>> >> > the same directory, without disturbing the rest of the nodes in the .xml
>> >> > format.
>> >> >
>> >> > We have feeds offered directly off the site, but also via subscription
>> >> > feed
>> >> > and subscription email feed via Feedburner (now with Google). We have
>> >> > hundreds of subscribers for the different venues, so I don't want to
>> >> > disturb
>> >> > the .xml extension that Feedburner is set to if possible.
>> >> >
>> >> > Every week I use a Find / Replace to replace the <pubDate>,
>> >> > <lastBuildDate>,
>> >> > the starting date (would be "April 3, 2009" below) and the week of date
>> >> > (would be "Week of April 3rd - April 9th" below).
>> >> >
>> >> > Then I also have some common feed <description> information that I have to
>> >> > open each feed and do a cut and paste and save.
>> >> >
>> >> > Not only is this redundant and time consuming, but more importantly,
>> >> > leaves
>> >> > me open for mistakes. So I'd like to do the common information mentioned
>> >> > above more dynamically.
>> >> > I've tried to figure out how to use dynamic linking in the parts of the
>> >> > .xml
>> >> > feed files that would change weekly.... linking to a master file where I'd
>> >> > make the weekly changes necessary, but I've not had much success.
>> >> >
>> >> > Here are some samples, and again I thank you for your time and knowledge.
>> >> >
>> >> > The unique information for each feed I've replaced with UNIQUE FEED INFO.
>> >> >
>> >> > The common information I've replaced with COMMON FEED and put
>> >> > between -------
>> >> >
>> >> > The actual feed that would be displayed would follow this format... I've
>> >> > reblocked and shortened the number of items for clarity.
>> >> >
>> >> > <?xml version="1.0" encoding="utf-8"?>
>> >> > <rss version="2.0">
>> >> >
>> >> > <channel>
>> >> > <title>Title Here</title>
>> >> > <pubDate>Thu, 02 Apr 2009 13:00:00 CST</pubDate>
>> >> > <lastBuildDate>Thu, 02 Apr 2009 13:00:00 CST</lastBuildDate>
>> >> > <description>Starting April 3, 2009 …UNIQUE FEED INFO...</description>
>> >> > <language>en-us</language>
>> >> > <link>https://domain.com/UNIQUE FEED INFO</link>
>> >> > <copyright>Copyright 2008, Company Name</copyright>
>> >> >
>> >> >
>> >> > <item>
>> >> > <title>Showing the Week of April 3rd - April 9th at....UNIQUE FEED
>> >> > INFO</title>
>> >> > <link>https://domain.com</link>
>> >> > <pubDate>Thu, 02 Apr 2009 13:00:00 CST</pubDate>
>> >> > <description>Features Starting April 3, 2009 for ..UNIQUE FEED
>> >> > INFO</description>
>> >> > </item>
>> >> >
>> >> > ---------------There would be several common items--------------
>> >> > <item>
>> >> > <title>COMMON FEED TITLE</title>
>> >> > <link>http://www.movietavern.com</link>
>> >> > <pubDate>Thu, 02 Apr 2009 13:00:00 CST</pubDate>
>> >> > <description>COMMON FEED DESCRIPTION</description>
>> >> > </item>
>> >> >
>> >> > ---------------There would be several common items--------------
>> >> > <item>
>> >> > <title>Showing the Week of April 3rd - April 9th</title>
>> >> > <link>http://www.domain.com/UNIQUE FEED INFO</link>
>> >> > <pubDate>Thu, 02 Apr 2009 13:00:00 CST</pubDate>
>> >> > <description>UNIQUE FEED INFO for the Week of April 3, 2009</description>
>> >> > </item>
>> >> >
>> >> > </channel>
>> >> > </rss>
>> >> >
>> >> > "Martin Honnen" wrote:
>> >> >
>> >> >> Kass wrote:
>> >> >>
>> >> >> > I have 25+ RSS feeds that have some unique information and some shared
>> >> >> > information. I'd like to have a "master.xml" (.rss or some sort of
>> >> >> > master)
>> >> >> > that is linked to a "feed.xml" whereby I can adjust the shared
>> >> >> > information in
>> >> >> > the "master.xml" file and it will dynamically change the appropriate
>> >> >> > nodes in
>> >> >> > the "feed.xml" file.
>> >> >> >
>> >> >> > I tried using php inside the feed.xml file to pull data from the
>> >> >> > master.php
>> >> >> > file ... no good. I tried using xpath in the feed.xml file to pull
>> >> >> > data
>> >> >> > from the master.xml file... still no luck. Perhaps I don't have the
>> >> >> > correct
>> >> >> > syntax. I'm not getting errors, just no data feed.
>> >> >>
>> >> >> I think you need to show samples of those feeds to allow us to
>> >> >> understand in what way data is shared and what data exactly you want to
>> >> >> update.
>> >> >> And if you are looking for a PHP solution then there are better places
>> >> >> than microsoft.public.xml to ask for help.
>> >> >>
------------------------------------------------
Digital Media MVP : 2004-2009
http://mvp.support.microsoft.com/mvpfaqs
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
