Page 1 of 1

[FR] Template XML + XSL : gratuit aussi ! :-)

Posted: 2004-06-20 14:32:25
by rangoon
Salut à tous,

Voici un petit template qui permet d'afficher la liste des films tranquillement... C'est grâce à lui que je suis tombé sur celui de Willspo :lol:

Installation :
- Créer les trois fichiers ci-dessous dans un dossier (exemple c:\movies)
- dans AMC, utiliser le fichier "c:\movies\antMovieCatalogue_template" comme template pour un type d'expoertation HTML
- cocher la case "copier les images [...] dans le même répertoire [...]"
- enregistrer l'exportation dans le même dossier que les trois fichiers pécédents et en mettant l'extension ".xml"
- ouvrir le fichier ".xml" avec internet explorer

ATTENTION
- si l'image n'apparaît pas, cela est sûrement du à un titre de film comprtant des caractères dits "spéciaux" : & - : etc. Ces caractères ne peuvent pas apparaitres dans un nom de fichiers ou dans une URL... :-(
- il vous faudra un fichier icone nommé "ico_photo.jpg" de taille 15x13 qui apparaîtra si une image existe pour le film

antMovieCatalogue_template.xml

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="antMovieCatalogue.xsl" type="text/xsl"?>
<!DOCTYPE films_catalogue SYSTEM "antMovieCatalogue.dtd">

<films_catalogue>
<details>
  <creation_date>$$DATE</creation_date>
  <creation_time>$$TIME</creation_time>
  <catalogue_name>$$OWNER_NAME</catalogue_name>
  <catalogue_filepath>$$FILEPATH</catalogue_filepath>
  <nb_films>$$TOTALMOVIES</nb_films>
</details>
<films>
	$$ITEM_BEGIN
	<film>
	  <film_id>$$ITEM_NUMBER</film_id>
	  <film_appreciation>$$ITEM_RATING</film_appreciation>
	  <film_pix>$$ITEM_PICTUREFILENAME</film_pix>
	  <film_title>$$ITEM_ORIGINALTITLE</film_title>
	  <film_localized_title>$$ITEM_TRANSLATEDTITLE</film_localized_title>
	  <file_size>$$ITEM_SIZE</file_size>
	  <film_lang>$$ITEM_LANGUAGES</film_lang>
	  <film_subtitles>$$ITEM_SUBTITLES</film_subtitles>
	  <film_descr>$$ITEM_DESCRIPTION</film_descr>
	  <video_format>$$ITEM_VIDEOFORMAT</video_format>
	  <video_resolution>$$ITEM_RESOLUTION</video_resolution>
	  <audio_encoding>$$ITEM_AUDIOFORMAT</audio_encoding>
	</film>
	$$ITEM_END
</films>
</films_catalogue>
antMovieCatalogue.xsl

Code: Select all

<!-- xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="JavaScript" // -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="//films_catalogue">
	<HTML>
	<HEAD>
		<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<TITLE>Films Renaud</TITLE>
	<style>
	BODY,P,TH,TD,DT,DD,DL,DIV,BLOCKQUOTE,H1,H2,H3,H4,UL,LI {
		font-family:Verdana, Arial, Helvetica, sans-serif;
		font-size:13px;
		font-color:#000000;
	}
	
	BODY,P,TH,TD,DT,DD,DL,DIV,BLOCKQUOTE,H1,H2,H3,H4 {
		margin:0px;
	}
	
	BODY {
		scrollbar-arrow-color:#FFFFFF;
		scrollbar-base-color:#0000AA;
		scrollbar-highlight-color:#C4C4C4;
		margin:10px;
	}

	UL,LI{
		list-style-type: square;
	}
	</style>
	<SCRIPT LANGUAGE="Javascript">
		if (document.layers) { // Netscape
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = captureMousePosition;
		} else if (document.all) { // Internet Explorer
			document.onmousemove = captureMousePosition;
		} else if (document.getElementById) { // Netcsape 6
			document.onmousemove = captureMousePosition;
		}
		
		// Global variables
		xMousePos = 0; // Horizontal position of the mouse on the screen
		yMousePos = 0; // Vertical position of the mouse on the screen
		xMousePosMax = 0; // Width of the page
		yMousePosMax = 0; // Height of the page
		xScrollOffset = 0; // Width of the page
		yScrollOffset = 0; // Height of the page

		function captureMousePosition(e) {
			if (document.layers) {
				xMousePos = e.pageX;
				yMousePos = e.pageY;
				xMousePosMax = window.innerWidth+window.pageXOffset;
				yMousePosMax = window.innerHeight+window.pageYOffset;
				xScrollOffset = window.pageXOffset;
				yScrollOffset = window.pageYOffset;
			} else if (document.all) {
				xMousePos = window.event.x+document.body.scrollLeft;
				yMousePos = window.event.y+document.body.scrollTop;
				xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
				yMousePosMax = document.body.clientHeight+document.body.scrollTop;
				xScrollOffset = document.body.scrollLeft;
				yScrollOffset = document.body.scrollTop;
			} else if (document.getElementById) {
				xMousePos = e.pageX;
				yMousePos = e.pageY;
				xMousePosMax = window.innerWidth+window.pageXOffset;
				yMousePosMax = window.innerHeight+window.pageYOffset;
				xScrollOffset = window.pageXOffset;
				yScrollOffset = window.pageYOffset;
			}
		}
	</SCRIPT>
	<SCRIPT LANGUAGE="Javascript">
		
		var oldId=null;
		if(document.all){
			doc = 'document.all.';
		}else{
			doc = 'document.'
		}
		function openClose(tagId){
			var newId=null;
			newId = eval(doc+tagId);
			if(oldId && oldId!=newId){
				close(oldId);
			}
			if(newId.style.display==''){
				close(newId);
			}else{
				newId.style.top=yScrollOffset+80;
				newId.style.left=xMousePosMax-500;
				open(newId);
			}
			oldId=newId;
		}
	
		function open(id){
			id.style.display='';
		}
		
		function close(id){
			id.style.display='none';
		}
	</SCRIPT>
	</HEAD>
	
	<BODY color="#000000" bgcolor="#FFFFFF" link="#000090" vlink="#900090">
			<xsl:apply-templates select="details"/>
			<hr />
			<div id="referer" style="position:absolute;display:none"></div>
		<ul type="square">
			<xsl:apply-templates select="films/film"/>
		</ul>
	</BODY>
	</HTML>	
</xsl:template>



<xsl:template match="details">
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
      <tr>
        <td align="center" valign="middle" nowrap="true">
        	<h2><xsl:value-of select="catalogue_name"/></h2>
        	<xsl:value-of select="nb_films"/> films
        	<br/>
        	<small><i><xsl:value-of select="catalogue_filepath"/></i></small>
        	<br />
        	<i>
        	le <xsl:value-of select="creation_date"/>
        	à <xsl:value-of select="creation_time"/>
			</i>
        </td>
      </tr>
 	</table> 	
</xsl:template>



<xsl:template match="film">
	<li>
		  <xsl:if test="./film_pix!=''">
			  <xsl:attribute name="style">list-style-image:url("ico_photo.jpg")</xsl:attribute>
		  </xsl:if>
		
		   <table border="0" cellspacing="2" cellpadding="0" >
				  <tr valign="top">
					<td nowrap="nowrap" >
						<a>
							<xsl:attribute name="href">javascript:openClose('id<xsl:value-of select="film_id"/>');</xsl:attribute>
							<!--xsl:attribute name="onMouseOver">javascript:openClose('id<xsl:value-of select="film_id"/>');</xsl:attribute-->
							<xsl:attribute name="href">javascript:openClose('id<xsl:value-of select="film_id"/>');</xsl:attribute>
								<xsl:value-of select="film_title"/> <xsl:value-of select="film_lang"/></a>
								 <xsl:if test="./film_localized_title!=''">
									 (<xsl:value-of select="film_localized_title"/> )
								</xsl:if>
					</td>
				  </tr>
			</table>
	<div style="position:absolute;display:none">
		<xsl:attribute name="id">id<xsl:value-of select="film_id"/></xsl:attribute>
   <table border="1" bordercolor="#505050" bgcolor="#FFFFFF" cellspacing="0" cellpadding="0" width="450">
	      <tr valign="top">
      		<td>
			   <table border="0" bgcolor="#FFFFFF" cellspacing="0" cellpadding="0" width="450">
					  <tr valign="top">
						<td nowrap="nowrap" width="150">
						  <!--xsl:if test="./film_pix!=''"-->
								<img>
										<xsl:attribute name="src"><xsl:value-of select="film_pix"/></xsl:attribute>
										<xsl:attribute name="style">margin:1px;margin-right:4px;</xsl:attribute>
										<xsl:attribute name="align">left</xsl:attribute>
										<xsl:attribute name="border">1</xsl:attribute>
										<xsl:attribute name="bordercolor">#000000</xsl:attribute>
										<xsl:attribute name="width">150</xsl:attribute>
										<xsl:attribute name="height">150</xsl:attribute>
										<xsl:attribute name="onError">this.style.visibility="hidden"</xsl:attribute>
									</img>
							<!--/xsl:if-->
							   <table border="0" cellspacing="0" cellpadding="4" bgcolor="#F0F0F0">
								  <tr>
									<td nowrap="nowrap">
										<b>Taille :</b> <xsl:value-of select="file_size" /> Mo
										<br />
										<b>Audio:</b> <xsl:value-of select="audio_encoding" />
										<br />
										<b>Video:</b> <xsl:value-of select="video_format" /> 
										<br />
										<b>Resolution :</b>  <xsl:value-of select="video_resolution" />
										<br/>
										<b>Description :</b><xsl:value-of select="film_descr" />
										<br />
										<b>Note :</b>
											  <xsl:if test="./film_appreciation!=''">
												<img>
														<xsl:attribute name="src">appr<xsl:value-of select="(film_appreciation mod 4) * 2"/>.gif</xsl:attribute>
														<xsl:attribute name="border">0</xsl:attribute>
														<xsl:attribute name="onError">this.style.visibility="hidden"</xsl:attribute>
												</img>
												<xsl:value-of select="(film_appreciation mod 4) * 2"/> / 10
											</xsl:if>
									</td>
								  </tr>
								</table>
						</td>
					  </tr>
				</table>
			</td>
		  </tr>
	</table>
    </div>
    </li>
</xsl:template>
</xsl:stylesheet>
antMovieCatalogue.dtd

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!ENTITY film_id "CDATA">
<!ENTITY creation_date "CDATA">
<!ENTITY creation_time "CDATA">
<!ENTITY catalogue_name "CDATA">
<!ENTITY catalogue_filepath "CDATA">
<!ENTITY nb_films "CDATA">
<!ENTITY author "CDATA">
<!ENTITY film_appreciation "CDATA">
<!ENTITY film_pix "CDATA">
<!ENTITY film_title "CDATA">
<!ENTITY film_localized_title "CDATA">
<!ENTITY file_size "CDATA">
<!ENTITY film_lang "CDATA">
<!ENTITY film_subtitles "CDATA">
<!ENTITY film_descr "CDATA">
<!ENTITY video_format "CDATA">
<!ENTITY video_resolution "CDATA">
<!ENTITY audio_encoding "CDATA">
<!ELEMENT film (	film_id+, film_appreciation, film_pix, film_title, film_localized_title, file_size, film_lang, film_subtitles, film_descr, video_format, video_resolution, audio_encoding)>
<!ELEMENT films (film*)>
<!ELEMENT details (creation_date, creation_time, catalogue_name, catalogue_filepath, nb_films, author)>
<!ELEMENT films_catalogue (details, films)>
[/list]

would be

Posted: 2005-01-30 00:42:43
by Guest
Would be cool if someone could translate this to english =)

Posted: 2005-01-30 10:18:18
by Guest