Hello All,
I make an education system, which has a lot of subjects. Each subjects has a
simple (max 20-30 questions) faq.
I wolud like to make it with source-writing. It is working well, but I
cannot generate id for questions:
My idea is: before I append a new question, I get number of questions of
faq, and increment it to serve new id.
I am using
<xsl:value-of select="count (document( concat ('cocoon:/', $file))//faq)"/>
but sometimes it serve a real number of record, and sometimes it doesn't
give a right value.
So, is it a right method to generate id, or is there any other better
method?
here is my xsl:
<?xml version="1.0" encoding="iso-8859-2"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:source="http://apache.org/cocoon/source/1.0"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<xsl:param name="file"/>
<xsl:param name="faq"/>
<xsl:variable name="fc">
<xsl:value-of select="count (document( concat ('cocoon:/',
$file))//faq)+1"/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="content">
<content>
<xsl:choose>
<xsl:when test="normalize-space ($faq) = ''">
<xsl:value-of select="empty"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="success"/>
<source:insert create="true">
<source:path>document/content/faqs</source:path>
<source:source><xsl:value-of
select="$file"/></source:source>
<source:fragment>
<faq id="{$fc}">
<question><xsl:value-of select="$faq"/></question>
<answer/>
</faq>
</source:fragment>
</source:insert>
</xsl:otherwise>
</xsl:choose>
</content>
</xsl:template>
</xsl:stylesheet>
and here is sitemap snippet:
<map:match pattern="faq-add">
<map:generate src="../common/faq-add.xml"/>
<map:transform src="../common/style/faq-add.xsl">
<map:parameter name="use-request-parameter" value="true"/>
<map:parameter name="faq" value="{request-param:faq}"/>
<map:parameter name="file" value="faq.xml"/>
</map:transform>
<map:transform type="write-source"/>
<map:redirect-to uri="faq.html"/>
</map:match>
and cocoon:/faq.xml is serving by
<map:pipeline internal-only="true" caching="off">
<map:match pattern="**.xml">
<map:read src="{1}.xml"/>
</map:match>
</map:pipeline>
and here is faq.xml format:
<?xml version="1.0" encoding="ISO-8859-2"?>
<document>
<meta-desc>desc</meta-desc>
<meta-key>keys </meta-key>
<meta-author>Zamek</meta-author>
<title>title of faq</title>
<template>nomenu.xml</template>
<content>
<faqs>
<faq id="1">
<question>first</question>
<answer>answer of first</answer>
</faq>
<faq id="2">
<question>second</question>
<answer>answer of second</answer>
</faq>
</faqs>
</content>
</document>
--
thx,
----------------------------------------------------
Zoltan Zidarics programmer
PTE University Pecs, Hungary
icq: 43288694
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]