Hi Daniel,
Your output is not XHTML, it is plain HTML - and your question seems not
XSLT but HTML related...?
Cheers,
<prs/>
-----Original Message-----
From: Daniel Joshua [mailto:daniel(_dot_)joshua(_at_)gridnode(_dot_)com]
Sent: Monday, May 24, 2004 8:12 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Grouping into a table (for vertical alignment)
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.
Here's a simplified example...
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>
.
.
.
XSLT:
.
.
.
<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>
.
.
.
XHTML (Output):
.
.
.
<form name="form" action="submit.do" method="post"> <div
class="instruction">Please enter your Name and Password.</div>
Name: <input type="text" name="username" value=""
class="mandatory">Password: <input type="password" name="password" value=""
class="mandatory">
<div class="warning">All attempts are logged..</div> .
.
.
Regards,
Daniel
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--