Convert HTML Tags to Lower-case for XHTML Compliance

Discussion in 'HTML' started by schmoozes@aol.com, Nov 30, 2006.

  1. Guest

    http://www.ng2000.com/news.php?tp=html

    The XHTML definition demands all tags to be lower-cased. Your page will
    not validate otherwise and will therefore not be valid XHTML. If you
    write all your XHTML by yourself, it shouldn't be an issue. You simply
    write all tags in lower-case. Now, imaging situations where you're not
    in control over the code being written. One situation is when you let
    visitors/users of the website
    , Nov 30, 2006
    #1
    1. Advertising

  2. freemont Guest

    On Thu, 30 Nov 2006 12:05:58 -0800, schmoozes writ:

    > http://shnip
    >
    > The XHTML definition demands all tags to be lower-cased. Your page will
    > not validate otherwise and will therefore not be valid XHTML. If you
    > write all your XHTML by yourself, it shouldn't be an issue. You simply
    > write all tags in lower-case. Now, imaging situations where you're not
    > in control over the code being written. One situation is when you let
    > visitors/users of the website


    It helps when you finish sentences so that

    --
    "Because all you of Earth are idiots!"
    ¯`·..·¯`·-> freemont© <-·¯`·..·¯
    freemont, Nov 30, 2006
    #2
    1. Advertising

  3. mbstevens Guest

    On Thu, 30 Nov 2006 12:05:58 -0800, schmoozes wrote:

    > http://www.ng2000.com/news.php?tp=html
    >
    > The XHTML definition demands all tags to be lower-cased. Your page will
    > not validate otherwise and will therefore not be valid XHTML. If you
    > write all your XHTML by yourself, it shouldn't be an issue. You simply
    > write all tags in lower-case. Now, imaging situations where you're not
    > in control over the code being written. One situation is when you let
    > visitors/users of the website


    The C++ code after going through a couple of pages:
    ____________________________________________________
    private static string LowerCaseHtml(string html)
    {
    string[] tags = new string[] {
    "p", "a", "br", "span", "div", "i", "u", "b", "h1", "h2",
    "h3", "h4", "h5", "h6", "h7", "ul", "ol", "li", "img",
    "tr", "table", "th", "td", "tbody", "thead", "tfoot",
    "input", "select", "option", "textarea", "em", "strong"
    };

    foreach (string s in tags)
    {
    html = html.Replace("<" + s.ToUpper(), "<" + s).Replace("/" + s.ToUpper() + ">", "/" + s + ">");;
    }

    return html;
    }
    _________________________________________________


    It's a nice try, but would you mind running it over the following
    sentence, and letting us know what the results are:

    <P>Colonel Altman said "Target the Border, boys!"</P>

    Looking at the code without actually running it,
    my guess is that you'll get:

    <P>colonel altman said "target the border, boys!"</P>

    The problem is that you have to
    separate out strings that are parts of tags from those that
    are just part of text that gets displayed on a web page.

    You would normally want an (X)HTML parser to do this.

    Languages like Perl and Python have libraries and modules
    that provide (X)HTML parsing capabilities. You link them
    in with a single line of code. I haven't checked
    C++ lately, but I bet it does, too.

    Tidy, I think, can also accomplish this. You can find it
    through the w3c website.
    mbstevens, Nov 30, 2006
    #3
  4. mbstevens Guest

    On Thu, 30 Nov 2006 22:12:21 +0000, mbstevens wrote:

    > On Thu, 30 Nov 2006 12:05:58 -0800, schmoozes wrote:
    >
    >> http://www.ng2000.com/news.php?tp=html
    >>
    >> The XHTML definition demands all tags to be lower-cased. Your page will
    >> not validate otherwise and will therefore not be valid XHTML. If you
    >> write all your XHTML by yourself, it shouldn't be an issue. You simply
    >> write all tags in lower-case. Now, imaging situations where you're not
    >> in control over the code being written. One situation is when you let
    >> visitors/users of the website

    >
    > The C++ code after going through a couple of pages:
    > ____________________________________________________
    > private static string LowerCaseHtml(string html)
    > {
    > string[] tags = new string[] {
    > "p", "a", "br", "span", "div", "i", "u", "b", "h1", "h2",
    > "h3", "h4", "h5", "h6", "h7", "ul", "ol", "li", "img",
    > "tr", "table", "th", "td", "tbody", "thead", "tfoot",
    > "input", "select", "option", "textarea", "em", "strong"
    > };
    >
    > foreach (string s in tags)
    > {
    > html = html.Replace("<" + s.ToUpper(), "<" + s).Replace("/" + s.ToUpper() + ">", "/" + s + ">");;
    > }
    >
    > return html;
    > }
    > _________________________________________________
    >
    >
    > It's a nice try, but would you mind running it over the following
    > sentence, and letting us know what the results are:
    >
    > <P>Colonel Altman said "Target the Border, boys!"</P>
    >
    > Looking at the code without actually running it,
    > my guess is that you'll get:
    >
    > <P>colonel altman said "target the border, boys!"</P>
    >
    > The problem is that you have to
    > separate out strings that are parts of tags from those that
    > are just part of text that gets displayed on a web page.
    >
    > You would normally want an (X)HTML parser to do this.
    >
    > Languages like Perl and Python have libraries and modules
    > that provide (X)HTML parsing capabilities. You link them
    > in with a single line of code. I haven't checked
    > C++ lately, but I bet it does, too.
    >
    > Tidy, I think, can also accomplish this. You can find it
    > through the w3c website.


    If it passes the test sentence, you might also try it on:

    <img src="Alt/Target/Span.jpg" alt="Colonel Altman said 'Target the
    Border, boys!'" HEIGHT=20 WIDTH=36 />

    Begin to see why a fairly elaborate parser is needed?
    mbstevens, Nov 30, 2006
    #4
  5. mbstevens Guest

    On Thu, 30 Nov 2006 22:23:01 +0000, mbstevens wrote:

    >> html = html.Replace("<" + s.ToUpper(), "<" + s).Replace("/" + s.ToUpper() + ">", "/" + s + ">");;



    > Begin to see why a fairly elaborate parser is needed?


    The other thing that worries me is that you are converting the
    string with ToUpper() instead of ToLower(). That has to have some
    bizarre consequences if you're trying to convert to lower case.
    mbstevens, Nov 30, 2006
    #5
  6. Guest

    freemont wrote:
    > On Thu, 30 Nov 2006 12:05:58 -0800, schmoozes writ:
    >
    > > http://shnip
    > >
    > > The XHTML definition demands all tags to be lower-cased. Your page will
    > > not validate otherwise and will therefore not be valid XHTML. If you
    > > write all your XHTML by yourself, it shouldn't be an issue. You simply
    > > write all tags in lower-case. Now, imaging situations where you're not
    > > in control over the code being written. One situation is when you let
    > > visitors/users of the website

    >
    > It helps when you finish sentences so that
    >


    Sorry about tha...

    :->

    > --
    > "Because all you of Earth are idiots!"
    > ¯`·..·¯`·-> freemont© <-·¯`·..·¯
    , Dec 1, 2006
    #6
  7. Jim Moe Guest

    wrote:
    >
    > The XHTML definition demands all tags to be lower-cased. Your page will
    > not validate otherwise and will therefore not be valid XHTML. If you
    > write all your XHTML by yourself, it shouldn't be an issue. You simply
    > write all tags in lower-case. Now, imaging situations where you're not
    > in control over the code being written. One situation is when you let
    > visitors/users of the website
    >

    Use HTML-Tidy <http://sourceforge.net/projects/tidy/> to convert the case of

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
    Jim Moe, Dec 1, 2006
    #7
    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. rhat
    Replies:
    103
    Views:
    1,959
    =?Utf-8?B?TG9nYW4gR3JlZW5sZWU=?=
    Jun 16, 2005
  2. Nik Coughlin
    Replies:
    0
    Views:
    407
    Nik Coughlin
    Jun 16, 2006
  3. Janice

    lower case to upper case

    Janice, Dec 10, 2004, in forum: C Programming
    Replies:
    17
    Views:
    1,162
    Richard Bos
    Dec 14, 2004
  4. penny
    Replies:
    28
    Views:
    2,357
    Charlton Wilbur
    Mar 10, 2008
  5. eli m
    Replies:
    8
    Views:
    198
    Ian Collins
    Mar 21, 2013
Loading...

Share This Page