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/13/2009 10:09:00 PM There's no such thing as an XML page - and there's no facility to run
code inside those pieces of text.
You'll want to look at mod_rewrite if you're looking for translating
one URI path into an entirely different one. That takes us outside the
scope of this newsgroup.
It's enough to say you can take a URL such as /my_feed_{datetime}.xml
and rewrite it on the server (rather than in the browser) to a path
like /feedgen/feed-processor.php?feed_date={datetime}
The browser or feed reader never knows that's not a real file ending
in XML but is generated on the fly or by using passthru() on a
pre-generated snippet.
Cheers - Neil
On Mon, 13 Apr 2009 11:28:45 -0700, Kass
<Kass@d...> wrote:
>Neil,
>
>I took a different approach. I found some php class code on the net that I
>could use as a basis and amend so that I have my master page in which to make
>weekly changes. Then I made the regular 25+ feeds in php so they can pull
>the weekly updated info from the master page, but leave their unique info
>alone. This is working great!
>
>I'd still like to leave my 25+ feed names alone because of our subscriber
>system via feedburner. This means keeping the .xml extension.
>
>Do you know a successful way to do a redirect inside the .xml pages so they
>could just redirect to the php pages? Like a meta redirect in html, etc.
>I've tried a couple of ideas off the net to no avail.
>
>Thanks for hanging in there with me on the project.
>
>Kass
>
>
>
>"Neil Smith [MVP Digital Media]" wrote:
>
>> On Tue, 7 Apr 2009 22:38:01 -0700, Kass
>> <Kass@d...> wrote:
>>
>> >Neil,
>> >
>> >I'm back. I did my homework and looked into the publications you suggested.
>> > All very informative... there is much to know! Here are my findings. I'm
>> >going to include code again.
>>
>> >rssFeed.xml code:
>> >
>> ><?xml version="1.0" encoding="utf-8" ?>
>> ><?xml-stylesheet href="getRSS.xsl" type="text/xsl"?>
>> ><rss version="2.0"
>> >xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"
>> >xmlns:media="http://search.yahoo.com/mrss"
>> >xmlns:admin="http://webns.net/mvcb/"
>> >xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>> >xmlns:content="http://purl.org/rss/1.0/modules/content/"
>> >xmlns:dc="http://purl.org/dc/elements/1.1/">
>>
>>
>> So it looks like your XSL is matching text nodes (which are in no
>> namespace) but not the XML nodes in the rssFeed.xml, which are in all
>> of the above namespaces (or rather, the root node is, which is why it
>> doesn't match).
>>
>> Supposing you now add all the xmlns:bla="bla" above to your
>> <xsl:stylesheet />, that should eliminate namespace issues from the
>> transform.
>>
>> To avoid doubt, I've modified the stylesheet to add the required
>> namespaces. I also changed the identity template at the bottom to
>> match the one I suggested in the article (otherwise you *do* only get
>> text nodes)
>>
>> Finally, I changed the output method from <xsl:output method="text" />
>> to <xsl:output method="xml" /> since it seems obvious you need XML
>> back.
>>
>>
>>
>>
>> <?xml version="1.0" encoding="iso-8859-1"?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"
>> xmlns:media="http://search.yahoo.com/mrss"
>> xmlns:admin="http://webns.net/mvcb/"
>> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>> xmlns:content="http://purl.org/rss/1.0/modules/content/"
>> xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0">
>>
>> <xsl:output method="xml"/>
>>
>>
>> <!-- Find and Replace Text Template -->
>>
>> <xsl:template name="ReplaceAll">
>> <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="ReplaceAll">
>> <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="ReplaceAll">
>> <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="@*|node()">
>> <xsl:copy>
>> <xsl:apply-templates select="@*|node()"/>
>> </xsl:copy>
>> </xsl:template>
>>
>>
>> </xsl:stylesheet>
>>
>>
>> Accompanying PHP code :
>>
>>
>> <?php
>>
>> $oDOM = new DOMDocument('1.0', 'UTF-8');
>> $oDOM->load("rssFeed.xml");
>>
>> $oXSL = new DOMDocument('1.0', 'UTF-8');
>> $oXSL->load('getRSS.xsl');
>>
>> $oProc = new XSLTProcessor;
>> $oProc->importStyleSheet($oXSL);
>>
>> $oResultDoc = $oProc->transformToDoc($oDOM);
>>
>> ?>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>
>> <html>
>> <head>
>> <title>Untitled</title>
>> </head>
>>
>> <body>
>>
>> <textarea rows="40" cols="90" wrap="virtual">
>> <?php print($oResultDoc->saveXML()); ?>
>> </textarea>
>>
>> </body>
>> </html>
>>
>>
>>
>>
>> ** Note you'll need to check somewhat carefully that yout text editor
>> is set to use UTF-8 encoding when (re-)saving the XSL and XML as you
>> can easily get a character set mismatch if you save as ASCII or
>> ISO-8859-1 (European) by mistake.
>>
>>
>> HTH
>> Cheers - Neil
>> ------------------------------------------------
>> Digital Media MVP : 2004-2009
>> http://mvp.support.microsoft.com/mvpfaqs
>>
------------------------------------------------
Digital Media MVP : 2004-2009
http://mvp.support.microsoft.com/mvpfaqs
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
