XML+XSL+PHP conserver le texte sans encodage - XML/XSL - Programmation
Marsh Posté le 20-06-2004 à 19:14:29
http://www.nexen.net/docs/php/anno [...] decode.php
Marsh Posté le 20-06-2004 à 19:35:55
euh, merci ! ;-)
c'est pas encore gagné car il décode tout, évidemment , même les javascript! donc terminé les additions!
existe-t-il une fonction 'replace' ?
Marsh Posté le 20-06-2004 à 19:40:57
c'est ok, l'ai ajouté qq modifs :
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); |
Marsh Posté le 20-06-2004 à 19:08:12
Bonjour,
quand j'utilise ce code :
je me retrouve avec des images dont le chemin de la source et codé comme une URL (avec des %20 etc.), le tag concerné est "film_pix".
Pourtant quand j'utilise le tag "film_title" (identique à "film_pix" mais sans ".jpg" ) en affichage, il n'est pas modifié!!!
Quelqu'un saurait comment conserver le textes tel que le contient le XML ?
liste.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="antMovieCatalogue.xsl" type="text/xsl"?>
<films_catalogue>
<details>
<creation_date>20/06/2004</creation_date>
<creation_time>18:06:27</creation_time>
<catalogue_name>Films DVD / DIVx</catalogue_name>
<catalogue_filepath>g:\Mes documents\AntMovieCatalog\films.amc</catalogue_filepath>
<nb_films>67</nb_films>
</details>
<films>
<film>
<film_id>23</film_id>
<film_appreciation></film_appreciation>
<film_pix>il était une fois la vie.jpg</film_pix>
<film_title>Il était une fois la vie</film_title>
<film_localized_title>07 Le coeur</film_localized_title>
<file_size>167</file_size>
<film_lang></film_lang>
<film_subtitles></film_subtitles>
<film_descr></film_descr>
<video_format>DivX 4.x</video_format>
<video_resolution>512x408</video_resolution>
<audio_encoding>MPEG Layer 3 (MP3)</audio_encoding>
</film>
</films>
</films_catalogue>
antMovieCatalogue.xsl
<!-- 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">images/<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"/> / 10
</xsl:if>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</li>
</xsl:template>
</xsl:stylesheet>
index.php
<?php
$xh = xslt_create();
$file=fopen("liste.xml","r" );
//$xml=fread($file,16384);
$xml=fread($file,200000);
fclose($file);
$file=fopen("antMovieCatalogue.xsl","r" );
$xsl=fread($file,16384);
fclose($file);
$arguments = array(
'/_xml' => $xml,
'/_xsl' => $xsl
);
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
xslt_free($xh);
print "$result";
?>
N.B. : je n'y connais strictement rien au PHP, je ne développait qu'en ASP avant!
Merci ! ;-)
Message édité par RenO_Coke le 20-06-2004 à 19:10:24
---------------
"tu vois tuco le monde se divise en deux, ce qui ont un revolver chargé, et ceux qui creusent, toi, tu creuses" Clint Eastwood dans "le Bon, la Brute et le Truand" de Sergio Leone