SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Embed tag soup in xhtml

    Trying to find way to insert poor "tag soup" html into xhtml.

    In IE a cdata seems to work, but in firefox, chrome and safari it doesn't

    If its not in cdata, the code invalidates the xhtml.

    I've looked at object and iframe, but both require src files.

    Needs to be Google, yahoo and bing crawlable.

    Obviously it would be nice if there wasn't conditional code either in script or on the server.

    Am I sol?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,260
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    Hi AdsenseThemes, welcome to the forums,

    Quote Originally Posted by AdsenseThemes View Post
    .....
    the code invalidates the xhtml.

    I've looked at object and iframe, but both require src files.
    .....
    Why not use HTML then?

    errmmm. Doesn't embed need a source too?

    IMHO you're best off using the object tag if you want XHTML
    Second to that - conditional comments.

    SOoL? Only if you discount all of the few possible alternatives that work as options.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A CDATA section will let you insert anything (except the triplet ]]>). But it will be text data, of course, not content elements. There is no way to mix HTML markup within an XHTML document.

    Note that the XHTML document must be served as proper XHTML (e.g., as application/xhtml+xml) for CDATA sections to work in some browsers. It's not guaranteed to work with pretend-XHTML (served as text/html).
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Member
    Join Date
    May 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the tag "embed" is deprecated in html 4 and xhtml 1.0, I just meant a way to insert some crappy html into an xhtml.

    I could use html 4, and not have the issue with invalid xml, but it really wouldn't fix the problem. the inserted html would still screw up the page and would not validate as correct.


    I tried tidy to see if the inserted html could be fixed up, but it didn't fix all the issues.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,870
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    For that matter you can't have conditional comments in XHTML because only IE supports conditional comments and IE doesn't support XHTML.
    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="^$">

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,260
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    Good point. I'm so used to seeing so much fake XHTML I forget that.

    Besides the deprecated embed tag, what others are you talking about? AFAIK they can be replaced by using CSS no?

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,870
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Both embed and iframes were deprecated because the object tag is designed to do what those tags do. In XHTML in particular a single object tag can substitute for an embed tag because the second object tag is only needed to supply special options that IE6 requires in place of the standard params.

    IE is the only browser that doesn't handle the object tag correctly as a direct substitute for embed or iframe and so with XHTML there should be no reason for not using the correct object tag.

    Apart from IE6 needing its own special version of the object tag the only other issues with using the object tag are that you can't turn off the border in IE8 or earlier and if used for anything other than flash (eg. to contain HTML as a replacement for an iframe) there isn't any way to place other elements in front of it (again only a problem in IE and so limited to HTML and not a problem in XHTML).
    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="^$">

  8. #8
    SitePoint Member
    Join Date
    May 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK so for valid xhtml, the options are

    1) "tidy" the inserted html to xml fragment
    2) use <object type"text/html" src=url> which requires a separate file
    3) Javascript (not an option for me)

    How about a xslt tranform? I read that it treats cdata as just a regular text node. Are there any xslt features that could somehow recognize it as html.

  9. #9
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Hmm, EMBED was Netscape 'proprietary' rather than 'deprecated' although you could use the extensibility of XHTML and create an EMBED element very easily. Though I don't see a rational reason for you to do so - for obvious reasons regarding MIME and the fact OBJECT is more than capable of embedding in modern browsers.

    What exactly are you trying to achieve in the long-run; I understand you want to insert some HTML but why?

    Are you trying to show some "rendered HTML" code examples or something within a real XHTML page, in which case you could always use fall-backs or hyperlinks to the code or the object.

    It all seems odd to me and I cannot really see the major benefits of such an approach all you seem to be wanting to do is fool the parser - or perhaps I just need some new glasses.

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AdsenseThemes View Post
    the tag "embed" is deprecated in html 4 and xhtml 1.0, I just meant a way to insert some crappy html into an xhtml.
    No, embed has never been part of any HTML recommendation whatsoever, so it couldn't even be deprecated. It's just plain invalid. (Until the Back-to-the-Future team for HTML5 drags its rotting carcass into the light again.)

    Quote Originally Posted by AdsenseThemes View Post
    How about a xslt tranform?
    Nope. XSLT presumes well-formed XML as input. It can output HTML, but not use it as input.

    Quote Originally Posted by AdsenseThemes View Post
    I read that it treats cdata as just a regular text node.
    Yes, because that's exactly what it is: Character DATA.

    You have two options:
    1. Transform the HTML into XML before including it into the XHTML document.
    2. Put the HTML in a separate document and include it with an object element.
    Birnam wood is come to Dunsinane

  11. #11
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    NOT that ANY of the stuff discussed here likely has anything to do with your question - since you didn't show us the code you are trying to fix.

    No example, everyone is guessing wildly in the dark. That you even are MENTIONING CDATA probably means a lack of well-formedness that should mandate a total rewrite.

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,870
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Another thing with <embed> is that every browser that supports it also supports using the <object> tag to do the same thing. There are even browsers that support <object> that don't support <embed> and so there is nowhere whatsoever where it would make any sense at all to use <embed> instead of <object>.

    One really weird combination tat I have seen used a lot is an embed inside of the particular variant of the object tag used for IE6. Since IE6 is one of the browsers that supports embed that particular construct makes no sense whatever. If you do insist on using embed then the object tag in that instance is just making the code longer than it needs to be and if you are going to use the IE6 version of the object tag you may as well wrap it around the standard version of the object tag that all of the more modern browsers support (possibly including some that do not support embed).
    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
  •