[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: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 26 May 2004 11:57:05 -0400
password name
Daniel,

What assumptions, if any, can we make about the proximity of <input> and <password> elements? Can either appear independently of the other? Can arbitrary <text> elements appear between them at any point? How many can there be? (You've indicated that more than one <input> can appear, but not said whether none can appear, or whether there will always be a <password>, or how many <password> elements there could be.)

These are relevant since the solution will be to produce one or more tables in a template matching <content> or perhaps a template matching <input> or <password> (which would then pick up certain of the matching element's siblings to tuck them into the table), but this raises the question of how and whether <text>, <input> and <password> elements should be grouped together in a table. The precise logic to do this will be easier to determine if we know what kinds of constraints operate over the input.

If you have a content model for your <content> element (from a DTD or schema), this would be a big help.

Cheers,
Wendell

At 01:20 AM 5/26/2004, you wrote:
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.

___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_
"Thus I make my own use of the telegraph, without consulting
the directors, like the sparrows, which I perceive use it
extensively for a perch." -- Thoreau


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.