JAVASCRIPT + XML

Fermé
filoulebauju Messages postés 170 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 23 octobre 2018 - 6 avril 2009 à 21:32
filoulebauju Messages postés 170 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 23 octobre 2018 - 6 avril 2009 à 21:53
Bonjour,
voila j'ai un problème. Le javascript dans mon code ne s'execute pas.

Pourtant, il marche très bien dans une page html basique.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
		xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
		xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
		xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
		xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
		xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
		xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
		xmlns:xlink="http://www.w3.org/1999/xlink" 
		xmlns:dc="http://purl.org/dc/elements/1.1/" 
		xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
		xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
		xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
		xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
		xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
		xmlns:math="http://www.w3.org/1998/Math/MathML/" 
		xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
		xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
		xmlns:ooo="http://openoffice.org/2004/office" 
		xmlns:ooow="http://openoffice.org/2004/writer" 
		xmlns:oooc="http://openoffice.org/2004/calc" 
		xmlns:dom="http://www.w3.org/2001/xml-events" 
		xmlns:xforms="http://www.w3.org/2002/xforms/" 
		xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
		xmlns:rpt="http://openoffice.org/2005/report" 
		xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
		xmlns="http://www.w3.org/1999/xhtml"
		version="1.0">

	<xsl:output method="xml" 
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3/org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
	
	<xsl:template match="office:document-content">
		<html>
			<head>
				<title>Foo</title>
				<style>
					.higlight
					 {
						 background-color:#F00;
					 }
				</style>
				<script language="javascript">
					function searchNReplace()
					{
						search_word = document.getElementById("search").value;
						contenu = document.getElementById("contenu").value;
						var reg=new RegExp("("+search_word+")", "gi");
						if(search_word!="")
						{
							document.getElementById("contenu").innerHTML=(chaine.replace(reg,"<span class='higlight'>$1</span>"));
						}
						else
						{
							document.getElementById("contenu").innerHTML = chaine;
						}
					}
				</script>
			</head>
			<body onLoad="searchNReplace();">
			<font size="3">
				<input name="search" id="search" type="text" size="15" onChange="n = 0;" onKeyUp="searchNReplace();"/>
			</font> 
			<div id="entete">
				TABLE DES MATIERES
			</div>
				<ul>
					<xsl:apply-templates select="office:body" mode="table"/>
				</ul>
				<div id="contenu"><xsl:apply-templates select="office:body" mode="contenu"/></div>				
			</body>
		</html>
	</xsl:template>
	
	<!-- 
	key('ecran-cart',generate-id())
	<office:body>
			<text:h outline-level="2">
				<text:refernece-match-start text name="ecran:e1"
					titre
				</text>
			</text:h>
	text:h[starts-with(text:reference-mark-start/@text:name, 'ecran:')]
	key name="chaine-cart" match="office:body/*" use="preceding-sibling::text:h[starts-with(text:refernece-start/@text:name,'ecran')]" 
	-->
	
	<xsl:key name="chain-titre" match="text:h[@text:outline-level = 2]" 
		use="generate-id(preceding-sibling::text:h[@text:outline-level = 1] [1])"/>
		
	<xsl:key name="chain-titre" match="text:h[@text:outline-level = 3]" 
		use="generate-id(preceding-sibling::text:h[@text:outline-level = 2] [1])"/>
		
	<xsl:key name="chain-titre" match="text:h[@text:outline-level = 4]" 
		use="generate-id(preceding-sibling::text:h[@text:outline-level = 3] [1])"/>
	
	<xsl:key name="chain-titre" match="text:h[@text:outline-level = 5]" 
		use="generate-id(preceding-sibling::text:h[@text:outline-level = 4] [1])"/>
	
	
	<xsl:template match="office:text" mode="table">
		<xsl:apply-templates select="text:h[1]"/>
	</xsl:template>
	
	<xsl:template match="text:h">
	<li>
	<div id="titre{@text:outline-level}">(<xsl:value-of select="@text:outline-level"/>) <xsl:apply-templates/></div>
		<ul>
			<xsl:apply-templates select="key('chain-titre',generate-id())"/>
		</ul>
	</li>
	</xsl:template>
	<xsl:template match="text:a">
	<a>
		<xsl:attribute name="href"><xsl:value-of select="@xlink:href" /></xsl:attribute>
		<xsl:attribute name="title"><xsl:value-of select="@office:name" /></xsl:attribute>
		<xsl:choose>		
			<xsl:when test="contains(.,')') and string-length(substring-after(substring-before(.,')'),'('))<=2">
				<xsl:attribute name="hreflang">
					
					<xsl:value-of select="substring-after(substring-before(.,')'),'(')" />
					
				</xsl:attribute>
				<xsl:value-of select="substring-before(.,'(')" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates />
			</xsl:otherwise>
		</xsl:choose>
	</a>
</xsl:template>

<xsl:template match="draw:image">
	<img>
		<xsl:attribute name="src">
			<xsl:value-of select="substring(@xlink:href,2)"/>
		</xsl:attribute>
		<xsl:attribute name="width">
			<xsl:value-of select="round(substring-before(@svg:width,'cm')*38.37)"/>
		</xsl:attribute>
		<xsl:attribute name="height">
			<xsl:value-of select="round(substring-before(@svg:height,'cm')*38.37)"/>
		</xsl:attribute>
		<xsl:attribute name="alt">
			<xsl:value-of select="@draw:name"/>
		</xsl:attribute>
		<xsl:if test="svg:desc">
			<xsl:attribute name="longdesc"><xsl:value-of select="svg:desc"/></xsl:attribute>
		</xsl:if>
	</img>
</xsl:template>
  
<xsl:template match="text:ordered-list">
	<ol>
		<xsl:apply-templates />
	</ol>
</xsl:template> 

<xsl:template match="text:unordered-list"> 
	<ul>
		<xsl:apply-templates />
	</ul>
</xsl:template> 

<xsl:template match="text:list-item"> 
	<li>
		<xsl:apply-templates />
	</li>
</xsl:template>
</xsl:stylesheet>


Merci de votre aide.
A voir également:

1 réponse

filoulebauju Messages postés 170 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 23 octobre 2018 8
6 avril 2009 à 21:53
up?
0

Discussions similaires