Javascript with XHTML 1.0 strict?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonny

    #1

    Javascript with XHTML 1.0 strict?

    How can you validate Javascript generated HTML for XHTML 1.0 strict
    compliance?

    To avoid the "<" and "&" problem, all inline scripts MUST be enclosed
    with either:
    <!-- script --> Looked down upon at the w3 site.
    //<![CDATA[ script //]]> Recommended.
    Or put into an external js file.

    However, when using any of these methods, you can use any none XHTML
    1.0 strict stuff in a script like <center> and <br> instead of <br />
    and still pass the w3 validation test.
    http://validator.w3.org/

    I've looked for info at w3 but I get the feeling that they have a low
    opinion of Javascript. I'd like to use a XHTML 1.0 strict doctype with
    my pages but why should I bother if they're not bothered with
    Javascript. Is Javascript considered the shell suit of internet
    fashion by the w3?
  • DU

    #2
    Re: Javascript with XHTML 1.0 strict?

    Jonny wrote:
    [color=blue]
    > How can you validate Javascript generated HTML for XHTML 1.0 strict
    > compliance?
    >[/color]

    You can't ... if I understood your post correctly.

    write() and writeln() methods "will produce a document which is not
    necessarily driven by a DTD and therefore might be produce an invalid
    result in the context of the document."

    http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-75233634
    [color=blue]
    > To avoid the "<" and "&" problem, all inline scripts MUST be enclosed
    > with either:
    > <!-- script --> Looked down upon at the w3 site.
    > //<![CDATA[ script //]]> Recommended.
    > Or put into an external js file.
    >
    > However, when using any of these methods, you can use any none XHTML
    > 1.0 strict stuff in a script like <center> and <br> instead of <br />
    > and still pass the w3 validation test.
    > http://validator.w3.org/[/color]

    Yes you can but you don't have to.

    DU
    [color=blue]
    >
    > I've looked for info at w3 but I get the feeling that they have a low
    > opinion of Javascript. I'd like to use a XHTML 1.0 strict doctype with
    > my pages but why should I bother if they're not bothered with
    > Javascript. Is Javascript considered the shell suit of internet
    > fashion by the w3?[/color]

    Comment

    • Richard Cornford

      #3
      Re: Javascript with XHTML 1.0 strict?

      "DU" <drunclear@hotW IPETHISmail.com > wrote in message
      news:buq2f8$8pc $1@news.eusc.in ter.net...[color=blue][color=green]
      >>How can you validate Javascript generated HTML for
      >>XHTML 1.0 strict compliance?[/color]
      >
      >You can't ... if I understood your post correctly.
      >
      >write() and writeln() methods "will produce a document which
      >is not necessarily driven by a DTD and therefore might be
      >produce an invalid result in the context of the document."[/color]

      Mozilla apparently have decided not to implement the W3C HTML DOM
      HTMLDocument interface on the document object in their XHTML DOM
      implementation so with XHTML there are no write or writeln methods to
      use.

      OTOH Opera 7 have implemented HTMLdocument on their XHTML implementation
      but it doesn't yet support script elements so there is no way of
      executing a document.write inline as the page loads.

      Which means that for XHTML (the real thing, not the strangely formatted
      HTML served as text/html as per appendix c) the validity of the result
      of a document.write is (and may remain) academic.
      [color=blue][color=green]
      >>However, when using any of these methods, you can use any
      >>none XHTML 1.0 strict stuff in a script like <center> and
      >><br> instead of <br /> and still pass the w3 validation test.
      >>http://validator.w3.org/[/color]
      >
      > Yes you can but you don't have to.[/color]

      In principal an XHTML UA would be perfectly entitled to throw an
      exception while parsing invalid XHTML even if it resulted from a
      document.write statement. And if the construction of the DOM used
      methods such as appendChile (which seems likely) then they may throw
      HIERARCHY_REQUE ST_ERR exceptions if asked to add a CENTER element to the
      DOM.

      But from the scripting point of view the value in using valid HTML is
      that it gives you the best chance of having a consistent DOM constructed
      with standardised behaviour across-browsers. So hiding invalid HTML in
      document.write statements in order to trick the W3C validator into
      accepting nonsense mark-up will do nothing to promote that desire. And
      if the author knows that the resulting document would be invalid then
      what is the point of hiding the invalid mark-up from the validator, to
      fulfil a contractual requirement for validity in name only? I wouldn't
      be inclined to trust anyone who took that attitude.

      Richard.


      Comment

      • Jonny

        #4
        Re: Javascript with XHTML 1.0 strict?

        DU <drunclear@hotW IPETHISmail.com > wrote in message news:<buq2f8$8p c$1@news.eusc.i nter.net>...[color=blue]
        > Jonny wrote:
        >[color=green]
        > > How can you validate Javascript generated HTML for XHTML 1.0 strict
        > > compliance?
        > >[/color]
        >
        > You can't ... if I understood your post correctly.
        >
        > write() and writeln() methods "will produce a document which is not
        > necessarily driven by a DTD and therefore might be produce an invalid
        > result in the context of the document."
        >
        > http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-75233634
        >[color=green]
        > > To avoid the "<" and "&" problem, all inline scripts MUST be enclosed
        > > with either:
        > > <!-- script --> Looked down upon at the w3 site.
        > > //<![CDATA[ script //]]> Recommended.
        > > Or put into an external js file.
        > >
        > > However, when using any of these methods, you can use any none XHTML
        > > 1.0 strict stuff in a script like <center> and <br> instead of <br />
        > > and still pass the w3 validation test.
        > > http://validator.w3.org/[/color]
        >
        > Yes you can but you don't have to.
        >
        > DU[/color]

        I understand that it's not its job to validate script and yes, I know
        I don't have to use dodgy HTML. But no one can guarantee they won't
        slip in a depreciated tag here or there, especially an old school
        HTML'er like me.

        Basically what I mean is:
        Why is the 'dodgy' HTML displayed as I intended? What is responsible?
        Does the browser, Opera 7.23, NS 7.1 and IE 6 - all guilty, over ride
        the doctype if confused or whatever?

        Should we, Javascript wise, leave XHTML 1.0 strict alone until things
        improve?

        Comment

        • David Dorward

          #5
          Re: Javascript with XHTML 1.0 strict?

          Jonny wrote:
          [color=blue]
          > However, when using any of these methods, you can use any none XHTML
          > 1.0 strict stuff in a script like <center> and <br> instead of <br />
          > and still pass the w3 validation test.
          > http://validator.w3.org/[/color]

          Well yes - its an SGML validator. It doesn't have a JavaScript interpretor.
          What would it do anyway - trigger every event handler in the document, and
          insert every combination of text in every input and prompt, and do these
          things in every possible order? It would take forever, or longer.
          [color=blue]
          > I've looked for info at w3 but I get the feeling that they have a low
          > opinion of Javascript.[/color]

          What gives you that idea?
          [color=blue]
          > I'd like to use a XHTML 1.0 strict doctype with
          > my pages but why should I bother if they're not bothered with
          > Javascript.[/color]

          Why should someone's opinion of JavaScript influence your use of another
          technology?
          [color=blue]
          > Is Javascript considered the shell suit of internet
          > fashion by the w3?[/color]

          JavaScript is a tool, more often then not its used poorly (when the same
          task could be achieved better with other tools[1] or best not achieved at
          all[2]), there are plenty of places when it can be useful.


          [1] e.g. including a menu on multiple pages
          [2] e.g. forcing a full screen window

          --
          David Dorward <http://dorward.me.uk/>

          Comment

          • Jim Ley

            #6
            Re: Javascript with XHTML 1.0 strict?

            On 22 Jan 2004 18:24:54 -0800, jonny_xyz_75@ya hoo.co.uk (Jonny) wrote:
            [color=blue]
            ><!-- script --> Looked down upon at the w3 site.[/color]

            no, it's not looked down upon, it just means a comment in XHTML and
            the script would not be executed!
            [color=blue]
            >//<![CDATA[ script //]]> Recommended.[/color]

            I don't agree with this. I'd recommend if you're going to embed to
            escape your script, but use external
            [color=blue]
            >I've looked for info at w3 but I get the feeling that they have a low
            >opinion of Javascript. I'd like to use a XHTML 1.0 strict doctype with
            >my pages but why should I bother if they're not bothered with
            >Javascript.[/color]

            Script is well supported in the doctype, what is not supported is
            XHTML 1.0 in the real world - don't use it, if you're going to use
            XHTML, use XHTML 1.1 absolutely no reason to limit yourself to 1.0

            Jim.
            --
            comp.lang.javas cript FAQ - http://jibbering.com/faq/

            Comment

            • Martin Honnen

              #7
              Re: Javascript with XHTML 1.0 strict?



              Jonny wrote:
              [color=blue]
              > DU <drunclear@hotW IPETHISmail.com > wrote in message news:<buq2f8$8p c$1@news.eusc.i nter.net>...
              >[color=green]
              >>Jonny wrote:
              >>
              >>[color=darkred]
              >>>How can you validate Javascript generated HTML for XHTML 1.0 strict
              >>>compliance ?[/color][/color][/color]
              [color=blue][color=green][color=darkred]
              >>>To avoid the "<" and "&" problem, all inline scripts MUST be enclosed
              >>>with either:
              >>><!-- script --> Looked down upon at the w3 site.
              >>>//<![CDATA[ script //]]> Recommended.
              >>>Or put into an external js file.
              >>>
              >>>However, when using any of these methods, you can use any none XHTML
              >>>1.0 strict stuff in a script like <center> and <br> instead of <br />
              >>>and still pass the w3 validation test.
              >>>http://validator.w3.org/[/color]
              >>
              >>Yes you can but you don't have to.[/color][/color]
              [color=blue]
              >
              > I understand that it's not its job to validate script and yes, I know
              > I don't have to use dodgy HTML. But no one can guarantee they won't
              > slip in a depreciated tag here or there, especially an old school
              > HTML'er like me.
              >
              > Basically what I mean is:
              > Why is the 'dodgy' HTML displayed as I intended? What is responsible?
              > Does the browser, Opera 7.23, NS 7.1 and IE 6 - all guilty, over ride
              > the doctype if confused or whatever?
              >
              > Should we, Javascript wise, leave XHTML 1.0 strict alone until things
              > improve?[/color]

              That has nothing to do with JavaScript, write an XHTML 1.0 document that
              validates with the W3C validator to the script document type, then put
              in some <embed> element, upload the page to a web server that sends the
              file as text/html and I am sure all those browser will happily render
              the page including the <embed> element.
              When sending a page as text/html the browser doesn't even use an XML
              parser to parse the page, and you have to send your XHTML as text/html
              as IE doesn't even know how to treat application/xhtml+xml.
              It seems you have fallen for the trap that XHTML 1.0 is superior to HTML
              4.01 and think it is good to move there, even when it is served as
              text/html to HTML user agents. Many people disagree on that, see

              and
              Aalto University, Finland is a new multidisciplinary science and art community in the fields of science, business, and art and design.

              for instance.

              To go even further, browsers like Netscape 7 respectively Mozilla or
              like Opera 7 which accept application/xhtml+xml and then use an XML
              parser do not use a validating parser at all, and you can even serve
              application/xhtml+xml to them with an <embed> element (properly closed
              with </embed> to have well-formed XHTML) for instance referencing a
              flash movie and they will happily play that.

              So, yes, leave XHTML alone, unless you have a real use for it, for
              instance mixed namespace documents mixing XHTML with MathML and user
              agents like Mozilla that know how to deal with that.



              --

              Martin Honnen
              http://JavaScript.FAQTs.com/

              Comment

              Working...