Loading ...
Sorry, an error occurred while loading the content.

Re: [NH] LOCAL XHTML TESTING

Expand Messages
  • loro
    ... Not sure if we mean the same thing with quirks mode ? Browser will treat XHTML as HTML, i.e. use their HTML parser, if the document is served as
    Message 1 of 8 , Dec 12, 2004
    • 0 Attachment
      weigheyeman wrote:
      ><snip>
      >2. I realise that there are difficulties presenting XHTML to some
      >browsers (IE in particular) and that I will end up with the browser
      >treating my code as HTML in "quirks" mode.

      Not sure if we mean the same thing with "quirks mode"? Browser will treat
      XHTML as HTML, i.e. use their HTML parser, if the document is served as
      text/html. Locally the same thing happens if you use the html extension. An
      .xhtml extension makes them use their XML parser.

      The browser can treat the document as HTML and still use Standards Mode
      (AKA Strict Mode) as the rendering mode. How the doctype is written is used
      as a trigger for Standards or Quirks Mode, but it has nothing to do with
      Strict or Transitional (X)HTML.
      <http://www.hut.fi/u/hsivonen/doctype.html>

      >For that reason I intend
      >to change to HTML 4.01 strict DOCTYPE before going live and carrying
      >out validation and final testing.

      I can understand that approach.

      >That's the background. The question is what is the best way of
      >testing and validating my XHTML code locally?

      Do you mean locally as in not connected to the Internet?
      I know only two options if you don't want to install one of the online
      validators on your own machine (which isn't all that easy, I'm told).

      ARV - the offline version of WDG's excellent validator and well worth its
      modest price.
      <http://arealvalidator.com/>

      Igor Podlubny's cool freeware for Notetab.
      <http://www.tuke.sk/podlubny/ov.html>

      Otherwise, just upload to one of the online validators. The w3c one has
      already been mentioned. WDG's is here:
      <http://www.htmlhelp.com/tools/validator/>

      >I am not very clear how
      >browsers, validators/linters, Tidy etc manage doctypes when looking
      >at code.

      Browsers don't understand doctypes. They just use them for their "doctype
      switching", as this rendering mode thing is called. Validators understand
      them very well a check a document's syntax against the corresponding
      doctype definition, DTD. Tidy and other lints typically didn't use to care
      about doctypes either, but that can have changed for all I know. Either
      way, they don't validate the document against a DTD.

      >How can I be sure that they are treating the code as XHTML
      >1.0 strict and not HTML?

      To sum up, browsers only care about HTML or XHTML (they don't know Strict
      and Transitional). The trigger is the content-type from a server and the
      extension locally.
      Validators use the DTD you refer to in the doctype.
      Lints do what lints do, whatever that is. ;-)

      Lotta
    • Grant Mackenzie
      ... //this will trigger quirks, get rid of it Only if you put the xml proccessing instruction on top of the Doc..
      Message 2 of 8 , Dec 12, 2004
      • 0 Attachment
        >Hi,
        >I'm an experienced real time software engineer getting involved in
        >Web design. I have done a lot of reading, both books and web pages
        >and, after a lot of heart searching, have arrived at the following
        >strategy for developing web pages:
        >
        >1. Develop and test the site initially using an XHTML 1.0 strict
        >DOCTYPE until I have the site working to my satisfaction. This will
        >be done locally on my PC (I will not upload the site). I hope that
        >this will set me on the right road to producing well formed XHTML
        >code which will be ready when more browsers (IE) support XHTML. I
        >intend to follow the W3C compatibility rules (Annex C) to make sure
        >that my XHTML is backwards compatible with HTML.
        >
        >2. I realise that there are difficulties presenting XHTML to some
        >browsers (IE in particular) and that I will end up with the browser
        >treating my code as HTML in "quirks" mode.

        <?xml version="1.0" encoding="UTF-8"?> //this will trigger quirks, get rid
        of it
        Only if you put the xml proccessing instruction on top of the Doc..
        otherwise quirks mode is not triggered.

        >For that reason I intend
        >to change to HTML 4.01 strict DOCTYPE before going live and carrying
        >out validation and final testing.

        Why?
        Leave the DOCTYPE as xhtml strict.
        give it a html or htm extension and the server will serve it as text/html
        your browser is happy ... it loads and parses as an html doc
        however your doc is now bipolar..
        can be loaded into sgml parser( a browser ) and rendered like html..
        can be loaded into xml parser ( may be a xml parser in a browser, maybe not
        ... )

        >That's the background. The question is what is the best way of
        >testing and validating my XHTML code locally?

        The way i do it is to load it into a validating xml parser..
        msxml 4 does the trick..

        I've got a little notetab clip that
        replaces the Public Doctype to a local one
        ^!Set %dtSystem%=<!DOCTYPE html SYSTEM "^$GetAppPath$DTD\xhtml1-strict.dtd">

        it then calls a script from WSH

        ^!Set %file%="^$GetScriptPath$validateByDTD.js"
        ^!Set %arg%=^$GetDocName()$
        ^!Set %arg%=^$StrReplace("\";"\\";"^%arg%";0;0)$
        ^!Set %out%=^$StrTrim(^$GetInputOutput(cscript "^%file%" "^%arg%"
        //NoLogo )$)$

        the ^%file% contains the following..small jscript

        var stdout = WScript.StdOut;
        var x
        var file = WScript.Arguments.Unnamed(0)
        stdout.WriteLine(file)
        //instantiate latest msxml parser
        x = new ActiveXObject("Msxml2.DOMDocument.4.0");
        x.async = false;
        x.validateOnParse = true;
        x.resolveExternals = true;
        if(!x.load(file))
        {
        var err = x.parseError
        if(err.errorCode != 0)
        {
        stdout.WriteLine(err.reason);
        stdout.WriteLine('line:#: ' + err.line + ' ');
        stdout.WriteLine('linepos: ' + err.linepos);
        }
        }
        else
        {
        stdout.WriteLine("Valid against strict DTD " + x.parsed)
        }

        I replace the doctype back ..
        and go to position curser at line error if there is one...


        ^!Set %errLinePos%=^$StrTrim(^$StrCopy(^%out%;^$Calc(^%idx%+7)$;6)$)$
        ^!Info ^%out%
        ^!IfTrue ^%Public% ^!Replace "^%dtSystem%" >> "^%dtPublic%" CIWHS
        ^!SetCursor ^%errLinePos%:1
        ^!GOTO END

        Viola its done ...
        file is validated against the DTD and this is done locally



        >I am not very clear how
        >browsers, validators/linters, Tidy etc manage doctypes when looking
        >at code. How can I be sure that they are treating the code as XHTML
        >1.0 strict and not HTML?
        >
        >Can anyone point me at any interesting sites or offer any suggestions?
        >
        >Thanks,
        >
        >Charlie





        CSE HTML Validator Lite - it's free:
        http://home.earthlink.net/~5wink/dl/cselite652.exe

        Fookes Software Home: http://www.fookes.us/redir



        Yahoo! Groups Sponsor
        ADVERTISEMENT






        Yahoo! Groups Links

        To visit your group on the web, go to:
        http://groups.yahoo.com/group/ntb-html/

        To unsubscribe from this group, send an email to:
        ntb-html-unsubscribe@yahoogroups.com

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      • weigheyeman
        Hi again, Thanks to everyone who replied. I thought I had done a lot of reading on the subject but you ve given me lots to think about. I definitely understand
        Message 3 of 8 , Dec 14, 2004
        • 0 Attachment
          Hi again,
          Thanks to everyone who replied.
          I thought I had done a lot of reading on the subject but you've given
          me lots to think about. I definitely understand the DOCTYPE and
          rendering thing a lot better now.
          Regards,

          Charlie
        Your message has been successfully submitted and would be delivered to recipients shortly.