xsl-list
[Top] [All Lists]

Re: XHTML to XHTML transform

2004-04-02 11:53:32
Jeffrey Moss wrote:

I want to create XHTML files and run them through some transforms to turn
things

Hi,

one thing to remember is that XHTML is lowercase. You could do something like this:


<xsl:variable name="upper_case" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="lower_case" select="'abcdefghijklmnopqrstuvwxyz'"/>

<xsl:template match="node()|@*">
  <xsl:element name="translate(local-name(), $upper_case, $lower_case)">
    <xsl:apply-templates select="@*"/>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

*and* catch any non-compliant elements and convert them to something like:

<div class="nonCompliantName"/>

You will also want to catch things like empty title, script and textareas and do something like:

<xsl:template match="title | script | textarea">
  <xsl:choose>
    <xsl:when test="not(boolean(text()))">
<xsl:element name="translate(local-name(), $upper_case, $lower_case)">
        <xsl:apply-templates select="@*"/>
        <!-- **** -->
        <xsl:comment/>
        <!-- **** -->
      </xsl:element>
    </xsl:when>
    <xsl:otherwise>
      do the same thing as the default template above
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

best,
-Rob



-Jeff



<Prev in Thread] Current Thread [Next in Thread>