Re: [xsl] XHTML to XHTML transform

Subject: Re: [xsl] XHTML to XHTML transform
From: "Jeffrey Moss" <jeff@xxxxxxxxxxxx>
Date: Fri, 2 Apr 2004 14:55:15 -0700
How do I match text nodes in my custom namespace? As in override the default
text node template for "mynamespace"?

All my variables <mynamespace:name>blah</mynamespace:name> for instance
appear as text in the results, I've tried this:

<xsl:template match="text()[namespace-uri()='mynamespace:namespace']">
</xsl:template>

but that doesn't work... I ended up changing all the elements I want hidden
under all circumstances to the mynamespace-var namespace...

<xsl:template match="*[namespace-uri()='mynamespace-var:namespace']">
</xsl:template>

This works, but I think its messy, I was wondering if there was a better
way? I'm pasting my code below.

Thanks,

-Jeff



<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:nbn="nbn:namespace"
  xmlns:nbn-run="nbn-run:namespace"
  xmlns:nbn-var="nbn-var:namespace"
  exclude-result-prefixes="nbn nbn-run nbn-var">
<xsl:param name="controller" select="'index.php'"/>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:template match="/sitemap">
  <DIV CLASS="navtree">
    <xsl:apply-templates />
  </DIV>
</xsl:template>

<xsl:template match="*[not(namespace-uri())]">
  <xsl:copy>
    <xsl:apply-templates />
  </xsl:copy>
</xsl:template>

<xsl:template match="text()">
</xsl:template>

<xsl:template match="*[namespace-uri()='nbn-var:namespace']">
</xsl:template>

<xsl:template match="nbn:link">
  <xsl:element name="A">
    <xsl:attribute name="HREF">/<xsl:value-of
select="$controller"/>/module/<xsl:value-of
select="nbn-var:location/nbn-var:module" />/action/<xsl:value-of
select="nbn-var:location/nbn-var:action" />/</xsl:attribute>
    <xsl:attribute name="ID"><xsl:value-of select="@id"/></xsl:attribute>
    <xsl:attribute name="CLASS">menuitem</xsl:attribute>
    <xsl:value-of select="@name"/>
  </xsl:element>
  <xsl:apply-templates />
  <BR/>
  <xsl:if test="link">
    <xsl:element name="DIV">
      <xsl:attribute name="CLASS">submenu</xsl:attribute>
      <xsl:apply-templates select="link"/>
    </xsl:element>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

Current Thread