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

RE: [NH] LOCAL XHTML TESTING

Expand Messages
  • Grant Mackenzie
    ... //this will trigger quirks, get rid of it Only if you put the xml proccessing instruction on top of the Doc..
    Message 1 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 2 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.