SGML Parser doesn't like <script> contents?

Discussion in 'HTML' started by (Pete Cresswell), Dec 24, 2004.

  1. This code:
    --------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <base target="40thPix_DisplayArea"/>
    <title> Click on a small picture...</title>
    <link rel="stylesheet" type="text/css" href="Master.css"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    </head>

    <body>
    <script type="text/javascript">
    document.write("<p id='ThumbNavListloading'>Loading thumbnails, please
    wait...<\/p>");
    ........
    </script>
    --------------

    makes the W3C's SGML parser flag the 'document.write' line with
    -------------------------------------
    Line 12, column 45: document type does not allow element "p" here

    ....nt.write("<p id='ThumbNavListloading'>Loading thumbnails, please wait...<\/p>

    The element named above was found in a context where it is not allowed. This
    could mean that you have incorrectly nested elements -- such as a "style"
    element in the "body" section instead of inside "head" -- or two elements that
    overlap (which is not allowed).

    One common cause for this error is the use of XHTML syntax in HTML documents.
    Due to HTML's rules of implicitly closed elements, this error can create
    cascading effects. For instance, using XHTML's "self-closing" tags for "meta"
    and "link" in the "head" section of a HTML document may cause the parser to
    infer the end of the "head" section and the beginning of the "body" section
    (where "link" and "meta" are not allowed; hence the reported error).
    -------------------------------------

    Seems like it's not buying the <script> command - but the code works, so
    *somebody* is recognizing it.

    Can anybody tell me where I've sinned?
    --
    PeteCresswell
    (Pete Cresswell), Dec 24, 2004
    #1
    1. Advertising

  2. (Pete Cresswell)

    Oli Filth Guest

    From what I remember, it's good practice to always surround your
    Javascript with comment delimiters, e.g.

    <SCRIPT type="text/javascript">
    <!--
    .... script goes here ...
    //-->
    </SCRIPT>

    That way, anything that doesn't know Javascript won't see it, because
    it's commented out.

    Oli

    (Pete Cresswell) wrote:
    > This code:
    > --------------
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html>
    > <head>
    > <base target="40thPix_DisplayArea"/>
    > <title> Click on a small picture...</title>
    > <link rel="stylesheet" type="text/css" href="Master.css"/>
    > <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    > </head>
    >
    > <body>
    > <script type="text/javascript">
    > document.write("<p id='ThumbNavListloading'>Loading thumbnails, please
    > wait...<\/p>");
    > .......
    > </script>
    > --------------
    >
    > makes the W3C's SGML parser flag the 'document.write' line with
    > -------------------------------------
    > Line 12, column 45: document type does not allow element "p" here
    >
    > ...nt.write("<p id='ThumbNavListloading'>Loading thumbnails, please wait...<\/p>
    >
    > The element named above was found in a context where it is not allowed. This
    > could mean that you have incorrectly nested elements -- such as a "style"
    > element in the "body" section instead of inside "head" -- or two elements that
    > overlap (which is not allowed).
    >
    > One common cause for this error is the use of XHTML syntax in HTML documents.
    > Due to HTML's rules of implicitly closed elements, this error can create
    > cascading effects. For instance, using XHTML's "self-closing" tags for "meta"
    > and "link" in the "head" section of a HTML document may cause the parser to
    > infer the end of the "head" section and the beginning of the "body" section
    > (where "link" and "meta" are not allowed; hence the reported error).
    > -------------------------------------
    >
    > Seems like it's not buying the <script> command - but the code works, so
    > *somebody* is recognizing it.
    >
    > Can anybody tell me where I've sinned?
    Oli Filth, Dec 24, 2004
    #2
    1. Advertising

  3. (Pete Cresswell)

    rf Guest

    wrote:Oli Filth wrote:
    (Pete Cresswell) wrote:

    > From what I remember, it's good practice to always surround your
    > Javascript with comment delimiters, e.g.
    >
    > <SCRIPT type="text/javascript">
    > <!--
    > ... script goes here ...
    > //-->
    > </SCRIPT>
    >
    > That way, anything that doesn't know Javascript won't see it, because
    > it's commented out.


    Nope. That is cargo cult stuff that went out of fashion with release 3
    browsers.

    In XHTML anything inside a script element is cdata and should be marked as
    such:

    <SCRIPT type="text/javascript">
    <![cdata[
    .... script goes here ...
    ]]>
    </SCRIPT>

    google for "xhtml cdata".

    The (better) alternative is put the javascript in an external file and link
    to it.


    >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


    Pete, if you are going to all the hassle of using XHTML (including the fact
    that IE does not understand it) why are you using transitional rather than
    strict?

    --
    Cheers
    Richard.
    rf, Dec 24, 2004
    #3
  4. RE/
    >it's good practice to always surround your
    >Javascript with comment delimiters, e.g.


    Bingo! And everybody's happy...

    Thanks.
    --
    PeteCresswell
    (Pete Cresswell), Dec 24, 2004
    #4
  5. (Pete Cresswell)

    Neal Guest

    On Fri, 24 Dec 2004 02:14:29 GMT, (Pete Cresswell) <> wrote:

    > RE/
    >> it's good practice to always surround your
    >> Javascript with comment delimiters, e.g.

    >
    > Bingo! And everybody's happy...


    I'm not happy... see rf's response for a more appropriate solution.
    Neal, Dec 24, 2004
    #5
  6. (Pete Cresswell)

    Oli Filth Guest

    Oh, sorry, didn't spot the XHTML doctype. I stand corrected.

    Oli

    rf wrote:
    > wrote:Oli Filth wrote:
    > (Pete Cresswell) wrote:
    >
    >
    >>From what I remember, it's good practice to always surround your
    >>Javascript with comment delimiters, e.g.
    >>
    >><SCRIPT type="text/javascript">
    >><!--
    >>... script goes here ...
    >>//-->
    >></SCRIPT>
    >>
    >>That way, anything that doesn't know Javascript won't see it, because
    >>it's commented out.

    >
    >
    > Nope. That is cargo cult stuff that went out of fashion with release 3
    > browsers.
    >
    > In XHTML anything inside a script element is cdata and should be marked as
    > such:
    >
    > <SCRIPT type="text/javascript">
    > <![cdata[
    > ... script goes here ...
    > ]]>
    > </SCRIPT>
    >
    > google for "xhtml cdata".
    >
    > The (better) alternative is put the javascript in an external file and link
    > to it.
    >
    >
    >
    >>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    >
    >
    > Pete, if you are going to all the hassle of using XHTML (including the fact
    > that IE does not understand it) why are you using transitional rather than
    > strict?
    >
    Oli Filth, Dec 24, 2004
    #6
  7. (Pete Cresswell)

    Duende Guest

    While sitting in a puddle rf scribbled in the mud:

    > The (better) alternative is put the javascript in an external file and link
    > to it.


    The best place to put it is... Recycle Bin

    --
    D?
    If it ain't broken fix it anyway.
    Duende, Dec 24, 2004
    #7
  8. (Pete Cresswell)

    Phoenix Guest

    (Pete Cresswell) wrote:

    <snip>

    > <body>
    > <script type="text/javascript">
    > document.write("<p id='ThumbNavListloading'>Loading thumbnails, please
    > wait...<\/p>");
    > .......
    > </script>


    <snip>

    > Seems like it's not buying the <script> command - but the code works, so
    > *somebody* is recognizing it.
    >
    > Can anybody tell me where I've sinned?


    Notice also, that if you are ever going to send this as TRUE XHTML (that
    is with the document type of "application/xhtml+xml" and not as HTML
    (text/html), document.write() will stop working.
    Phoenix, Dec 24, 2004
    #8
  9. rf <rf@.invalid> wrote:

    > Oli Filth wrote:
    >
    >> From what I remember, it's good practice to always surround your
    >> Javascript with comment delimiters, e.g.
    >>
    >> <SCRIPT type="text/javascript">
    >> <!--
    >> ... script goes here ...
    >> //-->
    >> </SCRIPT>
    >>
    >> That way, anything that doesn't know Javascript won't see it,
    >> because it's commented out.


    No, it's not commented out (supposing this is CDATA declared content),
    although in a UA that doesn't support the SCRIPT element type it will
    likely be, yes. But as rf said, this is things that belongs to the
    past.

    > In XHTML anything inside a script element is cdata


    No, the content model for script is (#PCDATA) in XHTML.

    --
    David Håsäther
    David Håsäther, Dec 24, 2004
    #9
  10. (Pete Cresswell)

    Dylan Parry Guest

    Neal wrote:

    >> Bingo! And everybody's happy...

    >
    > I'm not happy... <snip/>


    Can't please everyone ;)

    The OP wants to use Javascript, Oli wants to use comments to hide it,
    Richard wants to use CDATA, David wants PCDATA, and Duende wants the OP
    to not use Javascript at all :s

    Me? I'm indifferent ;)

    --
    Dylan Parry
    http://webpageworkshop.co.uk -- FREE Web tutorials and references
    Dylan Parry, Dec 24, 2004
    #10
  11. RE/
    >Pete, if you are going to all the hassle of using XHTML (including the fact
    >that IE does not understand it) why are you using transitional rather than
    >strict?


    Because I'm still suffering from RCI HTML-wise.

    I probably copied that line from somewhere and it worked...so I never touched
    it.

    I've gotten all my code through W3C's parser with no fatals - as "Transitional".
    Sounds like it's time to find an upgraded !DOCTYPE statement and try strict
    --
    PeteCresswell
    (Pete Cresswell), Dec 24, 2004
    #11
  12. RE/
    >Notice also, that if you are ever going to send this as TRUE XHTML (that
    >is with the document type of "application/xhtml+xml" and not as HTML
    >(text/html), document.write() will stop working.


    That's definately in the works.

    Which remedy should I adopt?

    <![cdata[......]]> ?
    --
    PeteCresswell
    (Pete Cresswell), Dec 24, 2004
    #12
  13. RE/
    >Notice also, that if you are ever going to send this as TRUE XHTML (that
    >is with the document type of "application/xhtml+xml" and not as HTML
    >(text/html), document.write() will stop working.


    Can somebody point me to a page that asks for full enforcement of true XHTML?

    I've looked through a half-dozen and found mostly HTML.
    --
    PeteCresswell
    (Pete Cresswell), Dec 24, 2004
    #13
  14. (Pete Cresswell)

    Spartanicus Guest

    "(Pete Cresswell)" <> wrote:

    >>Notice also, that if you are ever going to send this as TRUE XHTML (that
    >>is with the document type of "application/xhtml+xml" and not as HTML
    >>(text/html), document.write() will stop working.

    >
    >That's definately in the works.


    Don't: http://www.spartanicus.utvinternet.ie/no-xhtml.htm

    --
    Spartanicus
    Spartanicus, Dec 24, 2004
    #14
  15. (Pete Cresswell)

    Dylan Parry Guest

    Dylan Parry, Dec 24, 2004
    #15
  16. (Pete Cresswell), Dec 24, 2004
    #16
  17. (Pete Cresswell)

    Mitja Guest

    On Fri, 24 Dec 2004 21:25:43 GMT, (Pete Cresswell) <> wrote:

    > Are XHTML and CSS inextricably intertwined or can I base formatting on a
    > common CSS file and still use plain-vanilla HTML?


    Sure you can.

    --
    Mitja
    Mitja, Dec 24, 2004
    #17
  18. (Pete Cresswell)

    Neal Guest

    On Fri, 24 Dec 2004 21:25:43 GMT, (Pete Cresswell) <> wrote:

    > RE/
    >>
    >> Don't: http://www.spartanicus.utvinternet.ie/no-xhtml.htm

    >
    > Are XHTML and CSS inextricably intertwined or can I base formatting on a
    > common
    > CSS file and still use plain-vanilla HTML?


    The elements in XHTML 1.0 and HTML 4.01 are identical, so the stylesheet
    should not have to change.
    Neal, Dec 24, 2004
    #18
  19. (Pete Cresswell)

    Dylan Parry Guest

    (Pete Cresswell) wrote:

    > Are XHTML and CSS inextricably intertwined or can I base formatting on a common
    > CSS file and still use plain-vanilla HTML?


    XHTML *is* HTML just with an X. There's no reason for you not to use CSS
    with either. So, no they are not intertwined, and you can use CSS with
    HTML as well as with XHTML

    --
    Dylan Parry
    http://webpageworkshop.co.uk -- FREE Web tutorials and references
    Dylan Parry, Dec 24, 2004
    #19
  20. (Pete Cresswell)

    Neal Guest

    Dylan Parry wrote:

    > XHTML *is* HTML just with an X.


    So we must use XCSS, right? And XJavascript, XFlash, and lay it all out
    with Xtables in an Xframeset!
    Neal, Dec 24, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Clifford W. Racz
    Replies:
    4
    Views:
    2,008
    Clifford W. Racz
    Feb 13, 2004
  2. Benjamin Niemann

    Validating SGML parser?

    Benjamin Niemann, Aug 21, 2004, in forum: Python
    Replies:
    2
    Views:
    352
    Benjamin Niemann
    Aug 22, 2004
  3. Zach Dennis

    HTML-Parser / SGML-Parser

    Zach Dennis, Oct 1, 2003, in forum: Ruby
    Replies:
    5
    Views:
    387
    Bernard Delmée
    Oct 1, 2003
  4. bug in SGML parser

    , Dec 7, 2006, in forum: Ruby
    Replies:
    0
    Views:
    130
  5. Srijayanth Sridhar
    Replies:
    0
    Views:
    92
    Srijayanth Sridhar
    May 23, 2008
Loading...

Share This Page