validation utility?

C

carlos

If someone were to write a utility that would go through your html,
and javascript code and validate it/modify it, what language/
technology would you experts suggest I use? I know that the W3C
already does this, but I wanted to write something simple on my own
just for learning purposed. Anyway, I was thinking about using C# or
javascript, that would accept the files, and then call some external
objects/classes to handle the parsing and manipulation of the files. I
guess what I was wondering is if there is a better alternative or an
open source project I could modify to handle this?


THanks
 
D

Doug Miller

If someone were to write a utility that would go through your html,
and javascript code and validate it/modify it, what language/
technology would you experts suggest I use? I know that the W3C
already does this,

Right, so why re-invent the wheel?
but I wanted to write something simple on my own
just for learning purposed.

Then I suggest you start with a simple project.

This isn't it.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
oglegroups.com>, Wed, 14 Nov 2007 14:44:34, carlos
If someone were to write a utility that would go through your html,
and javascript code and validate it/modify it, what language/
technology would you experts suggest I use? I know that the W3C
already does this, but I wanted to write something simple on my own
just for learning purposed.

Full validation is a major project, unsuitable for anyone who is leaning
either the coding language or the language being validated.
Anyway, I was thinking about using C# or
javascript, that would accept the files,

Since this would be a text processing project, you would need good text-
processing routines. Javascript has RegExps; C# may need library
routines.
and then call some external
objects/classes to handle the parsing and manipulation of the files.


You might find it appropriate to code, for practice or use, something
that helps with some of the problems of finding where the actual error
is in incorrect code.

For example, within <URL:http://www.merlyn.demon.co.uk/js-quick.htm> I
have a routine to indent Javascript in accordance with its {...}
structure (provided that within a line {...} within strings and comment
balance); and in <URL:http://www.merlyn.demon.co.uk/js-misc1.htm#DC> I
have a utility for checking day-of-week in HTML.

I also have a Batch file to generate indented index lists for headings
in HTML pages (also with provisos, but ones easy to accept).

Start with something reasonably simple; and before that do something
easy.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
C

carlos

In comp.lang.javascript message <[email protected]
oglegroups.com>, Wed, 14 Nov 2007 14:44:34, carlos


Full validation is a major project, unsuitable for anyone who is leaning
either the coding language or the language being validated.


Since this would be a text processing project, you would need good text-
processing routines. Javascript has RegExps; C# may need library
routines.


You might find it appropriate to code, for practice or use, something
that helps with some of the problems of finding where the actual error
is in incorrect code.

For example, within <URL:http://www.merlyn.demon.co.uk/js-quick.htm> I
have a routine to indent Javascript in accordance with its {...}
structure (provided that within a line {...} within strings and comment
balance); and in <URL:http://www.merlyn.demon.co.uk/js-misc1.htm#DC> I
have a utility for checking day-of-week in HTML.

I also have a Batch file to generate indented index lists for headings
in HTML pages (also with provisos, but ones easy to accept).

Start with something reasonably simple; and before that do something
easy.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. [email protected] Turnpike v6.05 IE 6
FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

Thanks for the comments!

I think my post may have came across the wrong way, for I am not
trying to re-invent any validation programs like the WSC. I do realize
that validating againts all those cases is difficult. However, I used
that as an example, because I would like to do something simple like
check for a specific typo in my javascript code(Just one or two
though!!!). That is what I meant when I said that my implementation
would be simple.
I will look into what Dr JR Stockton suggested.

Thanks
 
D

Dr J R Stockton

In comp.lang.javascript message said:
If all you want is something to check your JS for typos and the like,
JSLint already does that along with more:

<URL: http://www.jslint.com/>

That cannot, AFAICS, find all typos; only the ones that breach ECMA 3
and certain conventions. "Its not likely to have among it's powers that
of being able to find the errors in this string."; but a custom-crafted
process might do so. For example, I have a process that, /inter alia/
picks out for correction all instances of the "word" 8061.

Page <http://www.jslint.com/> seems defective; it says "Read the
documentation"; but there is no visually apparent link to the
documentation on the page (using IE6).

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
D

Dr J R Stockton

In comp.lang.javascript message said:
Dr J R Stockton said the following on 11/16/2007 8:23 AM:

Yes. And, *no* utility could ever find all typos. What is the
misspelled word in the following sentence?

"These are some common misspellings of document: doucment, documnet,..."

There, doucment & documnet are intentionally misspelled, but not errors.
There are no JS errors in that string unless it is surrounded by other
quotes. But you already knew that.

There are two errors within that string, but I'm not surprised that you
do not see them. Typos can be worth finding even id they are not
Javascript errors.
"Some common mistakes when typing 8061 are 8601, 0861, etc.."

"Picks out for correction" is not the same as "corrects".
(A) I like to know how many of those mistakes I make,
(B) The correction needed is not necessarily the linguistically-
obvious one.
The correction is therefore offered but not enforced, much as it would
be with Notepad Replace. Of course, I always make *some* change, in
order not to be asked every time the checks are performed.
Indeed it does. Did you email Douglas and ask about it?

Why should I do that? He knows what's there and I know what's there.
No thanks, I think am vaguely familiar with both.

But you could learn from reading the line itself. It was retained as a
clue.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
D

Dr J R Stockton

In comp.lang.javascript message said:
Dr J R Stockton said the following on 11/17/2007 5:45 PM:

And, *no* utility could ever find all typos without human
intervention.

There was no claim made that one could find *all*. Finding some is of
some use.
I didn't say they aren't. I wrote "There are no *JS* errors in that
string ....". Perhaps you should read what I wrote more carefully and
realize that I was not referring to grammatical errors when I wrote "JS
errors".

Indeed; but you should acknowledge that I write the string, and I did
not impose that limitation. Errors which are not code errors are worth
finding.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top