[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Grouping into a table (for vertical alignment)

Subject: RE: Grouping into a table (for vertical alignment)
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Wed, 26 May 2004 10:13:10 -0500
table vertical alignment
Your problem is not harder than you think. 

Just write some XHTML into your XSL just like you already do there with the
<input> element.

Is there any special reason why you want XHTML above HTML, btw?

<prs/>

-----Original Message-----
From: Daniel Joshua [mailto:daniel.joshua@xxxxxxxxxxxx] 
Sent: Wednesday, May 26, 2004 12:21 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Grouping into a table (for vertical alignment)

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@xxxxxxxxxxxxxxxx]
Sent: Tuesday, 25 May, 2004 10:56 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.