Topic: Automaticly generating gallery.xml with XSLT

Hello everybody,
I'm actually coding an images database website which consists of more than 300 differents galleries and this number will increase.
Therefore I automatically generates the gallery.xml file with an XSLT processor when a visitor hits a link as my website uses an XML database to locates the images on my hard-drive.
From now the website is still locally run on my machine but when I'll put it online, what will happened if severals visitors hit differents links at the same time (means different gallery.xml file will be generated at the same time)?
Details :
Hiting a link on my website both call to simpleviewer.swf and generates gallery.xml at the same exact moment.
Therefore gallery.xml is rewrited every time a link is hit.

Is it possible to do that without conflicts between different visitors? If so, I'll move to simpleviewer pro.

Thanks in advance for your answers (and sorry for my english).

CMK

Re: Automaticly generating gallery.xml with XSLT

Dynamically creating the gallery.xml should not be a problem. You can try it with the standard version before purchaing Pro.

Felix Turner
SimpleViewer Support Team.

Re: Automaticly generating gallery.xml with XSLT

Ok, thank you for your answer.

Regards

Re: Automaticly generating gallery.xml with XSLT

Ok here comes a safe solution as I find out the ping time on the net could create a mess if several users would rewrite the same file to reuse it as a database immediately (tell me if I'm wrong, it seems logical):

Php (my Simpleviewer is embedded) :

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
flashvars.galleryURL = "gallery/<?php echo $_GET['exposition']; ?>_GA.xml";
var params = {};
params.allowfullscreen = true;
params.allowscriptaccess = "always";
params.wmode = "transparent";
swfobject.embedSWF("simpleviewer.swf", "flashContent", "800", "600", "9.0.124", false, flashvars, params);
</script> 
    </head>
<body>
/* FIRST CREATING THE GALLERY */
<?php 

$exposition = $_GET['exposition'];

$xslt = new XSLTProcessor();

$xml = new domDocument();
$xml -> load('expographie_v041109.xml');

$xsl = new domDocument();
$xsl -> load('gallery_generator.xslt');

$xslt -> importStylesheet($xsl);
$xslt -> setParameter(null,'exposition',$exposition);

$xslt -> transformToURI($xml,'gallery/'.$exposition.'_GA.xml');

/*THEN CREATING THE PAGE WHERE SIMPLEVIWER IS EMBBED */
$xslt = new XSLTProcessor();

$xml = new domDocument();
$xml -> load('expographie_v041109.xml');

$xsl = new domDocument();
$xsl -> load('exposition_unique_index.xslt');

$xslt -> importStylesheet($xsl);
$xslt -> setParameter(null,'exposition',$exposition);

echo $xslt -> transformToXml($xml);
?>
 
?>
</body> 
</html>

gallery_generator.xslt :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="utf-8" indent="yes" />
<xsl:param name="exposition" />

<xsl:template match="EXPOSITION">
<xsl:if test="@ID_EXPOSITION[self::node()=$exposition]">
<simpleviewergallery maxImageWidth="1200" maxImageHeight="800" textColor="0x444444" frameColor="0xFFFFFF" frameWidth="0" galleryStyle="Modern" stagePadding="2" navPadding="40" thumbColumns="2" thumbRows="5" thumbPosition="right" vAlign="center" hAlign="center" title="{@TITRE}" enableRightClickOpen="false" backgroundImagePath="" imagePath="" thumbPath="">
<xsl:apply-templates select="VISUEL_NUMERISE_ET_PUBLIABLE" />
</simpleviewergallery>
</xsl:if>
</xsl:template>

<xsl:template match="VISUEL_NUMERISE_ET_PUBLIABLE">
<xsl:for-each select="@FICHIER_CONSULTABLE">
<image>
<filename><xsl:value-of select="."/></filename>
<caption><xsl:value-of select="../@LEGENDE"/></caption>
</image>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

and the page where simpleviewer is called : exposition_unique_index.xslt

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:php="http://php.net/xsl">
<xsl:output method="html" encoding="ISO-8859-1" indent="yes" />
<xsl:param name="exposition" />

<xsl:template match="EXPOSITION">
<xsl:if test="@ID_EXPOSITION[self::node()=$exposition]">
<div id="flashContent">SimpleViewer requires JavaScript and the Flash Player. 
<a href="http://www.adobe.com/go/getflashplayer/">Get Flash.</a></div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Last edited by Chicobuarque (2009-12-04 18:37:17)