Chitharanjan Mohandas wrote:
> I have the following requirement.. I am sorry If I have posted
> to the woring site. Since cocoon uses XSLT a lot, I guess I
> will be better helped here....
Close, but no cigar. The best place to ask XSLT related
questions is still the XSL list:
http://www.mulberrytech.com/xsl/xsl-list/
THey have a FAQ and an archive there.
> Consider the following XML....
>
> I need to extract the description for the language
> which appears first when sorted alphabetically.....
>
> In this case I need the description for lang "de" i.e German Descrciption...
> The script should extract only for the language de...
...
> Could any one of you please advice me on how to build
> an XSLT script to solve this issue...
The easiest way is to use
<xsl:template match="Item">
<xsl:for-each select="description">
<xsl:sort select="lang"/>
<xsl:if test="position()=1">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
<xsl:template>
This is not very efficient if you have a real lot
of descriptions (run time is O(n*log(n)) instead of
O(n)), but then, I don't think there is an efficient
solution without using an extension function for
lexical string comparisions.
J.Pietschmann
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>