Jump to content

[XSLT 1.0] 2 codes that don't have effect when used together


sacha74

Recommended Posts

Hello,I'm trying to transform an XHTML file.

<html xmlns="http://www.w3.org/1999/xhtml"><head>  <meta name="template" content="Modele_NexT.htt" />  <meta http-equiv="content-type" content="text/html; charset=utf-8" />  <meta name="topic-status" content="Complete" />  <meta name="generator" content="Adobe RoboHelp - www.adobe.com" />  <meta name="generator-major-version" content="0.1" />  <meta name="generator-minor-version" content="1" />  <meta name="filetype" content="RoboHelp" />  <meta name="filetype-version" content="1" />  <meta name="page-count" content="1" />  <meta name="layout-height" content="684" />  <meta name="layout-width" content="727" />  <title>Sans chablons</title>  <link rel="StyleSheet" href="../DocNexT.css" /></head><body>  <div placeholder="" id="header" style="width: 100%; position: relative;">	<p> </p>  </div>  <h1>Sans chablons</h1>  <p>Cette fonctionnalité vous permet de saisir une transaction sans utiliser de modèle particulier.</p>  <p> </p>  <p><img src="TransferOperation21.jpg" style="border: none; width: 605px; height: 65px; border-style: none; border-style: none;" width="605" height="65" border="0" alt="" /></p>  <p> </p>  <p>Renseignez les champs obligatoires qui figurent en rouge avec un astérisque :</p>  <p> </p></head>

I want to do 2 transformations:

  • Delete tags <meta> et <div>

  • Delete namespace xmlns="
http://www.w3.org/1999/xhtml"

I have the two codes :the one for tags

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#default">	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>   <xsl:template match="node()">	   <xsl:copy>		<xsl:apply-templates select="node()"/>	   </xsl:copy>	</xsl:template>	<xsl:template match="meta|div"/>	<xsl:template match="span">		<xsl:apply-templates/>	</xsl:template>	</xsl:stylesheet>

the one for namespace

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>	<xsl:template match="*">		<xsl:element name="{local-name()}">			<xsl:apply-templates select="@*|node()"/>		</xsl:element>	</xsl:template>	<xsl:template match="@*">		<xsl:attribute name="{local-name()}">			<xsl:value-of select="."/>		</xsl:attribute>	</xsl:template>	</xsl:stylesheet>

The problem is that when I combine the two codes, only the one for deleting the namespace works.Please can you help me to do the 2 codes in one stylesheet.NB: However, this is not a real problem but if I can delete the <p> </p>. All the ideas era welcomedThanks for all

Link to comment
Share on other sites

If you really have XHTML elements in the namespace http://www.w3.org/1999/xhtml then doing match="div" or match="meta" does not help as that matches elements with local name "div" or "meta" in no namespace. You rather need

<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:xhtml="http://www.w3.org/1999/xhtml"  version="1.0">  <xsl:template match="@* | comment() | text() | processing-instruction()">	 <xsl:copy/>  </xsl:template>   <xsl:template match="*">	 <xsl:element name="{local-name()}">		<xsl:apply-templates select="@* | node()"/>	 </xsl:element>  </xsl:template>  <xsl:template match="xhtml:div | xhtml:meta"/></xsl:stylesheet>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...