RE: [xsl] generic template - possible?

Subject: RE: [xsl] generic template - possible?
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 16 Apr 2002 11:03:11 +0300
Heppa,

> I am somewhat new to XSL.  I am trying to write a template that will
> convert xhtml forms to wml forms. 
> I want to write a generic conversion that will convert:
> 
> <FORM method=GET action="http://www.google.com/search";>
> <INPUT TYPE=text name=q size=12 maxlength=255 value=""> 
> <INPUT type=submit name=btnG VALUE=" Google ">
> </FORM>

This is not XHTML...

> Is this possible to do with one template??  I just don't seem to know
> how to approach this.  Can anybody help?

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:xhtml="http://www.w3.org/1999/xhtml";
                exclude-result-prefixes="xhtml">

<xsl:template match="xhtml:form">
  <xsl:apply-templates select="xhtml:input" />
</xsl:template>

<xsl:template match="xhtml:input">
  <input>
    <xsl:copy-of select="@name | @size | @maxlength" />
  </input>
</xsl:template>

<xsl:template match="xhtml:input[@type = 'submit']">
  <do type="accept" label="{normalize-space(@value)}" /> 
</xsl:template>

</xsl:stylesheet>

or something like this *IF* your input is XHTML.

Cheers,

Santtu

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread