cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan" <ifon...@latinia.com>
Subject Produce an independent xml archive from another xml
Date Wed, 03 Jan 2001 12:28:18 GMT
Hi all again!
Is there anyway to produce an XML archive from
another XML within an XSL. The example I wrote:

XML File (proverbs.xml)

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="proverbs.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<proverbs>
<pro>
Poverty is the mother of all arts. 
</pro>
<pro>
If you scratch my back, I'll scratch yours. 
</pro>
<pro>
There's many a good tune played on an old fiddle. 
</pro>
<pro>
Of evil grain, no good seed can come. 
</pro>
<pro>
That's the thanks you get. 
</pro>
<pro>
Words hurt more than swords. 
</pro>
<pro>
Once in a while never hurt anyone. 
</pro>
<pro>
Many a true word is spoken in jest. 
</pro>
<pro>
God tempers the wind to the shorn lamb.
</pro>
<pro>
Where there's a sweet, there's always a bitter. 
</pro>
<pro>
In many words, a lie or two may escape. 
</pro>
<pro>
A man's house is his castle.
</pro>
</proverbs>

XSL File (proverbs.xsl)

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java"
exclude-result-prefixes="java" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="proverbs">
<xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction>

<html>
<head>
<title>Random Proverbs</title>
</head>
<body>
<xsl:variable name="pro" select="count(pro)" /> 
<center>
There are <b><xsl:value-of select="$pro" /></b> proverbs in the list. 
<br /> 
<br />
<xsl:for-each select="pro">
<xsl:apply-templates select="." /> 
<br /> 
</xsl:for-each>
<br /> 
</center>
<xsl:variable name="Rand" select="java:java.util.Random.new()" />
<xsl:variable name="result" select="ceiling(count(pro) * java:nextDouble($Rand))" />

<center><big><b>Selected Proverb</b></big></center>
<xsl:choose>
<xsl:when test="$result = 0">
<p>
<center><b><xsl:value-of select="pro[1]" /></b></center>
</p>
</xsl:when>
<xsl:otherwise>
<p>
<center><b><xsl:value-of select="pro[$result]" /></b></center>
</p>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>

Concerning this examples, is anyway to get outputed to another independent
XML file the result of the random selection, instead of getting the result in the
same xml file?¿ I mean producing an independent proverb1.xml file, i.e.
Could anyone point me in the right way to achieve it?¿

TIA

Iván Fontán
Technical Department

LATINIA CORPORATION 
www.latinia.com

Spain Office
Barcelona
Trav. Gràcia, 342-344
08025 Barcelona (Spain)
Tel.: +34 934 465 026

US Offices
New York
885 3rd Avenue
Suite 2800
New York, NY 10022

Miami
1210 Brickell Avenue
Suite 430
Miami, FL 33131

Mime
View raw message