SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict Brak's Avatar
    Join Date
    Jul 2004
    Location
    Central Coast, CA
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making HTML Elements not auto-close (XSLT)

    Okay, say I've got this code:
    Code:
    <xsl:template match="form.element[@type='textarea']">
    		<label class="textfield"><xsl:value-of select="@prompt" /></label>
    		<textarea name="{@name}" class="textfield"></textarea>
    		<xsl:if test="not(position() = last())">
    			<br />
    		</xsl:if>
    	</xsl:template>
    This will result in HTML output of
    Code:
    <label class="textfield">Description</label>
    <textarea name="name1" class="textfield" />
    <br />
    How do I get the <textarea> to not auto-close, or any tag for that matter? It messes up browsers soemthing fierce... I've also run into this problem with empty link elements before...
    Studio Rockstar's Blog - A journey to quitting the dayjob.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Set your output to HTML 4.01 instead of XML or XHTML.

  3. #3
    SitePoint Addict Brak's Avatar
    Join Date
    Jul 2004
    Location
    Central Coast, CA
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not really acceptable... I'm not going to go back to '96 because of one bug
    Studio Rockstar's Blog - A journey to quitting the dayjob.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Brak
    That's not really acceptable... I'm not going to go back to '96 because of one bug
    HTML 4.01 is a 1998-era creation, only one year older than XHTML 1.0.

    You have to realize that setting your output to XML (which you have to do for proper XHTML output) is going to do things like auto-closing empty elements. You can either set your output to HTML and manage elements yourself to turn them XHTML again (or let HTML 4 do its thing), or you can try and add default content into the textarea tag content so it doesn't revert to the short form. But anyway, HTML 4.01 is just as valid a standard as XHTML. You shouldn't dread using it.

  5. #5
    SitePoint Addict Brak's Avatar
    Join Date
    Jul 2004
    Location
    Central Coast, CA
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It may be as "valid" but it's not advancing the web - and I cannot use advanced DOM scripting with HTML 4.01. It's an old standards, and there's no reason people should really continue using it when we have XHTML out there.

    We're trying to advance the web, and to me - that means using XML with XSLT transformations and delivering XHTML the best I can. I really think there must be another solution other than "go back 7 years" thinking.
    Studio Rockstar's Blog - A journey to quitting the dayjob.

  6. #6
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Tulsa, Oklahoma
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't get it, where is it causing problems? What browser/OS is holding you back?

  7. #7
    SitePoint Addict Brak's Avatar
    Join Date
    Jul 2004
    Location
    Central Coast, CA
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting a <textarea /> element in a page instead of <textarea></textarea>. Since the <textarea> tag is meant to be filled, it is not auto-closing - thus conforming to the XHTML spec by displaying <textarea></textarea> instead of <textarea />.
    Studio Rockstar's Blog - A journey to quitting the dayjob.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •