-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Add XSLT support #1
Comments
An XSLT transformation is usually best applied to the XML feed directly, and not through a third party component or language. XSLT is Turing complete, and also a very good FP language, so I'd suggest digging that way first (by piping the XML directly through CLI XML tools). Originally posted by @Ocramius at zendframework/zend-feed#107 (comment) |
@Ocramius If I understand you correctly than what you are suggesting is not what I want to achieve. I want to make a RSS feed look good in the browser. It should be the feed generated through zend-feed itself without piping it through any extra tools. Originally posted by @podcasthosting at zendframework/zend-feed#107 (comment) |
I'd rather say that you take the RSS feed (input or output) and pass it to XSLT directly: XSLT is good and mature, use it 👍 Originally posted by @Ocramius at zendframework/zend-feed#107 (comment) |
Example: https://files.orf.at/podcast/oe1/oe1_imoe1journalzugast.xml |
@podcasthosting // Create feed
$feed = new Laminas\Feed\Writer\Feed;
$feed->setTitle("Paddy's Blog");
$feed->setDescription("Paddy's Blog");
$feed->setLink('http://www.example.com');
// Create entry
$entry = $feed->createEntry();
$entry->setTitle('All Your Base Are Belong To Us');
$entry->setLink('http://www.example.com/all-your-base-are-belong-to-us');
$entry->addAuthor([
'name' => 'Paddy',
'email' => '[email protected]',
'uri' => 'http://www.example.com',
]);
$entry->setDateModified(time());
$entry->setDateCreated(time());
$entry->setDescription('Exposing the difficulty of porting games to English.');
$entry->setContent(
'I am not writing the article. The example is long enough as is ;).'
);
$feed->addEntry($entry);
// Render feed (creates DOMDocument object)
$writer = new Laminas\Feed\Writer\Renderer\Feed\Rss($feed);
$writer->render();
// Add processing instruction
$writer->getElement()->parentNode->insertBefore(
$writer->getDomDocument()->createProcessingInstruction(
'xml-stylesheet',
'title="Demo" type="text/xsl" href="https://files.orf.at/podcast/oe1/podcast.xsl"'
),
$writer->getElement()
);
// Ouput XML
echo $writer->saveXml(); Ouput: <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet title="Demo" type="text/xsl" href="https://files.orf.at/podcast/oe1/podcast.xsl"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>Paddy's Blog</title>
<description>Paddy's Blog</description>
<generator>Laminas_Feed_Writer 2 (https://getlaminas.org)</generator>
<link>http://www.example.com</link>
<item>
<title>All Your Base Are Belong To Us</title>
<description><![CDATA[Exposing the difficulty of porting games to English.]]></description>
<pubDate>Thu, 24 Sep 2020 06:43:50 +0000</pubDate>
<link>http://www.example.com/all-your-base-are-belong-to-us</link>
<guid>http://www.example.com/all-your-base-are-belong-to-us</guid>
<author>[email protected] (Paddy)</author>
<dc:creator>Paddy</dc:creator>
<content:encoded><![CDATA[I am not writing the article. The example is long enough as is ;).]]></content:encoded>
<slash:comments>0</slash:comments>
</item>
</channel>
</rss> |
It would be nice to style generated feeds with a xsl:stylesheet. See the XSLT entry on Wikipedia for more general information about this.
I was thinking about adding a header to reference the stylesheet, e.g.
<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="podcast.xsl"?>
taken from an ORF podcast feed.
Originally posted by @podcasthosting at zendframework/zend-feed#107
The text was updated successfully, but these errors were encountered: