[kdewebdev-site] FAQ (in text)
Philipp Wendisch
phwen at media-division.net
Wed Feb 23 14:39:42 EST 2005
Andras Mantia schrieb:
> Hi,
>
> Or
> do we need only an XSL stylesheet?
> I'd like to have simple XML format:
> <faqs>
> <faq>
> <question>the question</question>
> <answer>the answer</answer>
> <maintainer name="name" email="email" />
> <category name="category" /> (?)
> <product name="product" />
> </faq>
> </faqs>
>
in addition to the simpleXML-usage from Chris
here's a XSL-Stylesheet based on the xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="yes"/>
<xsl:template match="/faqs">
<dl>
<xsl:apply-templates/>
</dl>
</xsl:template>
<xsl:template match="faq">
<xsl:variable name="Question" select="question" />
<xsl:variable name="Answer" select="answer" />
<xsl:variable name="Category" select="category/@name" />
<xsl:variable name="Product" select="product/@name" />
<xsl:variable name="MaintainerName" select="maintainer/@name" />
<xsl:variable name="MaintainerEMail" select="maintainer/@email" />
<dt><xsl:value-of select="$Question" /></dt>
<dd>
<p><xsl:value-of select="$Answer" /></p>
<p>
Product: <xsl:value-of select="$Product" />
<br />
Category: <xsl:value-of select="$Category" />
</p>
<p>Maintainer: <a href="mailto:{$MaintainerEMail}"><xsl:value-of
select="$MaintainerName" /></a></p>
</dd>
</xsl:template>
</xsl:stylesheet>
and a corresponding php-script may be:
<?php
//using sablot
$xslt = xslt_create();
echo xslt_process($xslt,"faq.xml","faq.xsl");
?>
--
phwen at media-division.net
Hosting - Linux - Internet - Programming
Trojan UK
-Media Division-
Martin-Luther-Strasse 18
D - 91207 Lauf
More information about the kdewebdev-site
mailing list