Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Dynamic RSS [Thread Next] Re: Dynamic RSSTo: NULL Date: 4/13/2009 6:32:00 PM You need to enable XSLT in yout php.ini and restart apache. When the extension is enabled, you'll see it listed in the phpinfo() output, as described on this page : www.---.com Avoid any documentation referring to sablotron, which was the default XSL processor available for PHP4 : PHP5 xsl is based on libxml2 and is much faster (and more standardised) HTH Cheers - Neil On Fri, 10 Apr 2009 14:24:12 -0700, Kass <Kass@d...> wrote: >Neil, > >Thanks for hanging in there with me on this. I appreciate the code help. > >I used your code for the .xsl and .php pages. I made sure the .xsl and .xml >are UTF-8 encoded. I have an option to save as encoding types in my editor. >This is what they both say in the top tag. >xls = <?xml version="1.0" encoding="utf-8"?> >xml = <?xml version="1.0" encoding="utf-8" ?> > >When I run the .php page I get this error. Do you think something isn't set >up right on the server? Here is the error: > >Fatal error: Class 'XSLTProcessor' not found in.... > >Thanks again! > >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 | |||
|
