Thanks for your reply.
Is your problem harder than
Yes it is. I do not want to have 2 separate tables (one for the 'input' and
one for the 'password'), I want to use the a single table if both elements
need tables, and not add a table if the element is a 'text'. And its need to
be generic so that if I add in more 'input' or 'text' is will make tables
accordingly.
I try to be a bit more clear, I included the desired output this time.
XML (Input):
.
.
.
<form>
<name>form</name>
<action>submit.do</action>
<method>post</method>
<content>
<text>
<value>Please enter your Name and Password.</value>
<class>instruction</class>
</text>
<input>
<name>username</name>
<label>Name: </label>
<value></value>
<class>mandatory</class>
</input>
<password>
<name>password</name>
<label>Password :</label>
<value></value>
<class>mandatory</class>
</password>
<text>
<value>All attempts are logged.</value>
<class>warning</class>
</text>
</content>
</form>
.
.
.
XHTML (Desired Output)
.
.
.
<form name="form" action="submit.do" method="post">
<div class="instruction">Please enter your Name and Password.</div>
<table>
<tr>
<td>Name: </td>
<td><input type="text" name="username" value=""
class="mandatory"></input></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password" value=""
class="mandatory"></input></td>
</tr>
<table>
<div class="warning">All attempts are logged..</div>
</form>
.
.
.
XSLT (which does not create the table):
.
.
.
<xsl:template match="form">
<form>
<xsl:for-each select="name | action | method">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates"/>
</form>
</xsl:template>
<xsl:template match="text">
<div>
<xsl:for-each select="class">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:value-of select="value"/>
</div>
</xsl:template>
<xsl:template match="label">
<xsl:value-of select="."/>
<xsl:text>: </xsl:text>
</xsl:template>
<xsl:template match="input">
<xsl:apply-templates select="label"/>
<input>
<xsl:attribute name="type">
<xsl:text>text</xsl:text>
</xsl:attribute>
<xsl:for-each select="name | value | class">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
</input>
</xsl:template>
<xsl:template match="password">
<xsl:apply-templates select="label"/>
<input>
<xsl:attribute name="type">
<xsl:text>password</xsl:text>
</xsl:attribute>
<xsl:for-each select="name | value | class">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
</input>
</xsl:template>
.
.
.
Regards,
Daniel
-----Original Message-----
From: Wendell Piez [mailto:wapiez(_at_)mulberrytech(_dot_)com]
Sent: Tuesday, 25 May, 2004 10:56 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Grouping into a table (for vertical alignment)
Daniel,
Is your problem harder than
<xsl:template match="input">
<table>
<tr>
<td>
<xsl:apply-templates select="label"/>
</td>
<td>
<input>
<xsl:attribute name="type">
<xsl:text>text</xsl:text>
</xsl:attribute>
<xsl:for-each select="name | value | class">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
</input>
</td>
</tr>
</table>
</xsl:template>
?
If so, could you be more specific as to what results you want to get?
Cheers,
Wendell
At 09:11 AM 5/24/2004, you wrote:
Hi,
I am trying to make a generic XSLT for converting XML into XHTML.
I want to put my output into a <table> for vertically aligning the 'label'
and 'input' fields.