SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XSL Transformation Creates Invalid XHTML Tags

    I am having a weird problem with my XSL transformation resulting in invalid XHTML output.

    I have input this in my XSL:
    Code:
    <img src="{path/to/url}" alt="{path/to/name}" title="{path/to/name}" />
    And it outputs as this:
    Code:
    <img src="/sitepath/images.jpg alt="" title="">
    As you can see, there is no closing slash at the end of the IMG tag. This results in the W3C saying my page has invalid XHTML.

    Any insights would be very appreciated. Thanks!

  2. #2
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any one? !

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Location
    Finland
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's been a while since I've used XSL, but adding the following element as a child of the xsl:stylesheet element might help:

    Code XML:
    <xsl:output method="xml"/>

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by sinanvq View Post
    Code:
    <img src="{path/to/url}" alt="{path/to/name}" title="{path/to/name}" />
    Code:
    <img src="/sitepath/images.jpg alt="" title="">
    Why do you want the space in front of the /

    If you are generating real XHTML then the space is unnecessary. If you are not using real XHTML then the / is unnecessary.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •