cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Giuseppe Di Pierri" <giuseppe.dipie...@gmail.com>
Subject Re: How to suppress xmlns:jx attribute in output of JXTemplate generator?
Date Thu, 31 May 2007 20:28:55 GMT
On 31/05/07, Christian Schlichtherle <christian@schlichtherle.de> wrote:
>
>
>
> Hi,
>
> I have an XSL stylesheet which needs to be preprocessed with JXTemplate so
> that the resulting sheet strictly conforms to XSL 1.0 (so it can be
> processed by some recent browsers).
>
> The stylesheet looks like this:
>
> <xsl:stylesheet version="1.0"
>                 xmlns="http://www.w3.org/1999/xhtml"
>
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
>                 exclude-result-prefixes="jx">
>     <!-- Parameter declaration. -->
>     <jx:choose>
>         <jx:when test="${empty(cocoon.request.select)}">
>             <xsl:param name="select">start</xsl:param>
>         </jx:when>
>         <jx:otherwise>
>             <xsl:param name="select">${cocoon.request.select}</xsl:param>
>         </jx:otherwise>
>     </jx:choose>
>     <!-- remainder omitted -->
> </xsl:stylesheet>
>
> Now if I preprocess it like this:
>
>             <map:match pattern="*.xsl">
>                 <map:generate label="style" type="jx" src="{0}"/>
>                 <map:serialize type="xml"/>
>             </map:match>
>
> ... then the resulting output still contains the xmlns:jx attribute in the
> <xsl:stylesheet> tag:
>
> <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE stylesheet>
> <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
>     version="1.0"
>     exclude-result-prefixes="jx">
>    <xsl:param name="select">start</xsl:param>
>    <!-- remainder omitted -->
> </xsl:stylesheet>
>
> This should not be necessary since all <jx:tag>s have been processed and
> removed from the output.
>
> Any clues how I can remove them easily (without writing another XSL
> stylesheet hopefully)?
>

If you don't mind using xsl, we adopt something like this in order to
get xhtml namespace only (don't forget to replace the namespace of
xhtml with xsl one - http://www.w3.org/1999/XSL/Transform - and maybe
you don't need to translate text()):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xml:space="default">
	<xsl:template match="/">
		<xsl:apply-templates />
	</xsl:template>

	<xsl:template match="text()">
		<xsl:value-of select="translate(.,'&#9;&#10;&#13;','   ')" />
	</xsl:template>

	<xsl:template match="*">
		<!-- remove element prefix (if any) -->
		<xsl:element name="{local-name()}" namespace="http://www.w3.org/1999/xhtml">
			<xsl:apply-templates select="@*" />
			<xsl:apply-templates />
		</xsl:element>
	</xsl:template>

	<xsl:template match="@*">
		<xsl:attribute name="{local-name()}">
			<xsl:value-of select="." />
		</xsl:attribute>
	</xsl:template>


	<xsl:template match="comment()">
		<xsl:copy />
	</xsl:template>

</xsl:stylesheet>

Good luck with dynamic xsl ;-)

bye

pino


-- 
Giuseppe Di Pierri
Managing Director
______________________
Phiware Engineering Sagl
via Ginevra 5
CH-6900 Lugano
Tel. +41 91 260 75 55
Fax.+41 91 260 75 59
Email. giuseppe.dipierri@phiware.ch

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message