Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Convert HTML Tags to Lower-case for XHTML Compliance

Reply
Thread Tools

Convert HTML Tags to Lower-case for XHTML Compliance

 
 
schmoozes@aol.com
Guest
Posts: n/a
 
      11-30-2006
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

 
Reply With Quote
 
 
 
 
freemont
Guest
Posts: n/a
 
      11-30-2006
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Š <-ˇ¯`ˇ..ˇ¯
 
Reply With Quote
 
 
 
 
mbstevens
Guest
Posts: n/a
 
      11-30-2006
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.



 
Reply With Quote
 
mbstevens
Guest
Posts: n/a
 
      11-30-2006
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?

 
Reply With Quote
 
mbstevens
Guest
Posts: n/a
 
      11-30-2006
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.


 
Reply With Quote
 
schmoozes@aol.com
Guest
Posts: n/a
 
      12-01-2006

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Š <-ˇ¯`ˇ..ˇ¯


 
Reply With Quote
 
Jim Moe
Guest
Posts: n/a
 
      12-01-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert xhtml to another xhtml using xslt Usha2009 XML 0 12-20-2009 01:13 PM
Should I Convert Site To XHTML or XHTML mobile? chronos3d HTML 9 12-05-2006 04:46 PM
Suppress self closing tags for html 4.01 strict compliance Nik Coughlin ASP .Net 0 06-16-2006 02:27 AM
JSP XHTML compliance Michiel Java 1 05-04-2006 08:45 AM
beta2 XHTML compliance? is this necessary. OR STUPID...read UP MICROSOFT rhat ASP .Net 103 06-16-2005 10:06 PM



Advertisments