Wednesday, February 28, 2007

Validating XHTML and CSS

Validating an XHTML document's content involves checking its markup against a DTD and reporting markup errors. You can validate HTML, XHTML, and CSS files by using the W3C's validator. It will allow you to validate files on the Internet or on your computer.

The validator program will go through your coding, find any errors, and create a report. You can then "clean up" your coding and validate again. This service is free.

http://validator.w3.org/

You can also check your external CSS pages through the CSS validator ...

http://jigsaw.w3.org/css-validator/

Once validated as well formed coding, the bottom of the report page will show an icon image that you may display on your page such as the ones you see in the right side column of my site. Display it with pride!

XHTML Doc Types

There are 3 Doctypes usable by an XHTML document. Strict, Transitional, and Frameset. The doctype is used when validating an XHTML document's content against a DTD and reporting markup errors. (The DOCTYPE lines below are broken in parts only to prevent the examples from being too wide for non-horizontal scrolling - you can keep it all on one line).

XHTML 1.0 Strict

Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


XHTML 1.0 Transitional

Use this when you need to take advantage of HTML's presentational features because many of your readers don't have the latest browsers that understand Cascading Style Sheets.

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


XHTML 1.0 Frameset

Use this when you want to use HTML Frames to partition the browser window into two or more frames.

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Reserved Words in MYSQL

In MYSQL, There is a number of words that you cannot use for your table and column names. MySQL uses some specific words for command processing, so using them in your own coding may confuse things a bit.

ADD ALL ALTER
ANALYZE AND AS
ASC ASENSITIVE AUTO_INCREMENT
BDB BEFORE BERKELEYDB
BETWEEN BIGINT BINARY
BLOB BOTH BY
CALL CASCADE CASE
CHANGE CHAR CHARACTER
CHECK COLLATE COLUMN
COLUMNS CONDITION CONNECTION
CONSTRAINT CONTINUE CREATE
CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURSOR DATABASE
DATABASES DAY_HOUR DAY_MICROSECOND
DAY_MINUTE DAY_SECOND DEC
DECIMAL DECLARE DEFAULT
DELAYED DELETE DESC
DESCRIBE DETERMINISTIC DISTINCT
DISTINCTROW DIV DOUBLE
DROP ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FIELDS FLOAT
FOR FORCE FOREIGN
FOUND FRAC_SECOND FROM
FULLTEXT GRANT GROUP
HAVING HIGH_PRIORITY HOUR_MICROSECOND
HOUR_MINUTE HOUR_SECOND IF
IGNORE IN INDEX
INFILE INNER INNODB
INOUT INSENSITIVE INSERT
INT INTEGER INTERVAL
INTO IO_THREAD IS
ITERATE JOIN KEY
KEYS KILL LEADING
LEAVE LEFT LIKE
LIMIT LINES LOAD
LOCALTIME LOCALTIMESTAMP LOCK
LONG LONGBLOB LONGTEXT
LOOP LOW_PRIORITY MASTER_SERVER_ID
MATCH MEDIUMBLOB MEDIUMINT
MEDIUMTEXT MIDDLEINT MINUTE_MICROSECOND
MINUTE_SECOND MOD NATURAL
NOT NO_WRITE_TO_BINLOG NULL
NUMERIC ON OPTIMIZE
OPTION OPTIONALLY OR
ORDER OUT OUTER
OUTFILE PRECISION PRIMARY
PRIVILEGES PROCEDURE PURGE
READ REAL REFERENCES
REGEXP RENAME REPEAT
REPLACE REQUIRE RESTRICT
RETURN REVOKE RIGHT
RLIKE SECOND_MICROSECOND SELECT
SENSITIVE SEPARATOR SET
SHOW SMALLINT SOME
SONAME SPATIAL SPECIFIC
SQL SQLEXCEPTION SQLSTATE
SQLWARNING SQL_BIG_RESULT SQL_CALC_FOUND_ROWS
SQL_SMALL_RESULT SQL_TSI_DAY SQL_TSI_FRAC_SECOND
SQL_TSI_HOUR SQL_TSI_MINUTE SQL_TSI_MONTH
SQL_TSI_QUARTER SQL_TSI_SECOND SQL_TSI_WEEK
SQL_TSI_YEAR SSL STARTING
STRAIGHT_JOIN STRIPED TABLE
TABLES TERMINATED THEN
TIMESTAMPADD TIMESTAMPDIFF TINYBLOB
TINYINT TINYTEXT TO
TRAILING TRUE UNDO
UNION UNIQUE UNLOCK
UNSIGNED UPDATE USAGE
USE USER_RESOURCES USING
UTC_DATE UTC_TIME UTC_TIMESTAMP
VALUES VARBINARY VARCHAR
VARCHARACTER VARYING WHEN
WHERE WHILE WITH
WRITE XOR YEAR_MONTH
ZEROFILL

Monday, February 19, 2007

What is XML, DTD and XSLT?

All these letters, abbreviations, meanings and so forth. What do they all mean and how do we use them? Here are some basics breakdown :

First we will start at the top. The VERY top. SGML stands for Standard Generalized Markup Language. Simply put, it is the very root coding of coding. HTML is an application of SGML.

XML is a simplified subset of SGML. It stands for eXtensible Markup Language.

DTD stands for Document Type Declaration. It is a set of instructions that states what tags are usable and what (re)action they create. Each browser has a DTD set in it's programming set by the browser companies. This is how some tags will work in only one type of browser or version. It has the tags stated in it's DTD. XML makes it possible to create unique tag sets by applying it's own DTD. This makes the DTD more compatable with more browsers.

XSLT stands for eXtensible Stylesheet Language Transformation. It is a strong verions of CSS that formats the XML page for viewing.

XHTML

What is XHTML?

* XHTML stands for eXtensible Hyper Text Markup Language.
* It is aimed to replace HTML.
* It is almost identical to HTML 4.01
* It is the reformulation of HTML 4.01 as an application of XML.
* It is a stricter, tidier version of HTML.

XHTML 1.0 is the next level of coding as specified by the W3C.

XHTML is a transition / combination of HTML and XML. To change from HTML to XHTML requires just a few changes in your coding styles. The main page to check out is CONVERTING but all the others provide valuable information about this coding technique as well.

XHTML provides the framework for future extensions of HTML and aims to replace HTML in the future. Some resources refer to XHTML as HTML5.

XHTML 1.0 became an official W3C recommendation on January 26, 2000. A W3C recommendation means that the specification is stable, that it has been reviewed by the W3C membership, and that the specification is now a Web standard.

XHTML 1.0 is the first step toward a modular and extensible web environment based on XML (eXtensible Markup Language). It provides the bridge for web designers to use a future based coding and still be able to maintain compatibility with today's browsers.

SGML stands for Standard Generalized Markup Language. Simply put, it is the very root coding of coding. HTML is an application of SGML. XML is a simplified subset of SGML.

DTD stands for Document Type Declaration. It is a set of instructions that states what tags are usable and what (re)action they create. Each browser has a DTD set in it's programming set by the browser companies. This is how some tags will work in only one type of browser or version. It has the tags stated in it's DTD. XML makes it possible to create unique tag sets by applying it's own DTD. This makes the DTD more compatable with more browsers.

Saturday, February 17, 2007

ruby-mp3info gem patch

IF you are using the gem "ruby-mp3info", it will work well in windows. but in linux, it wont. Coz mp3info will throw errors on 64 bit versions of Ruby.

To clear this problem, you have to apply the following patch which allows mp3info to work on 64 bit versions of Ruby...

Remove the NumericBits module from extension_modules.rb.
Remove "head.extend(NumericBits)" from mp3info.rb
Add this to the top of mp3info.rb

-class Bignum
- def bits(b, a)
- t = 0
- b.downto(a){ |i| t += t + self[i] }
- t
- end
-end

And the most important point is

you have to include "rubygems" while including "mp3info"
like this

require "rubygems"

require "mp3info"

otherwise it will throw "no such file to load" error....

Thursday, February 15, 2007

Having trouble in installing gems???

Many Rails developers have faced problems installing gems with the updated RubyGems release. solution to this problem is given here...

Problem:

" gem update mysql Updating installed gems… ERROR: While executing gem … (NoMethodError) undefined
method `refresh’ for #"

Solution:

...you should remove your local source_cache file. This is the file that locally caches any gem metadata from the gem server to avoid having to re-download it every time you execute a gem command.

To discover the location of this file on your system, run the following command:

$ gem env
RubyGems Environment:
- VERSION: 0.9.2 (0.9.2)
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- GEM PATH:
- /usr/local/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org

The source_cache file should be in the path labeled by GEM PATH. Removing that file should clear up any related issues.

Tuesday, February 06, 2007

Form helper methods

form(url) ...

Starts a form tag that points the action to an url.

The url options should be given either as a string, or as a url() function. The method for the form defaults to POST.

Options:

  • multipart - If set to True, the enctype is set to "multipart/form-data".
  • method - The method to use when submitting the form, usually either "get" or "post".

start_form(url)

Starts a form tag that points the action to an url.

The url options should be given either as a string, or as a url() function. The method for the form defaults to POST.

Options:

  • multipart - If set to True, the enctype is set to "multipart/form-data".
  • method - The method to use when submitting the form, usually either "get" or "post".

end_form()

Outputs ""

select(name, option_tags='')

Creates a dropdown selection box

option_tags is a string containing the option tags for the select box:

>>> select("people", "George")

Options:

  • multiple - If set to true the selection will allow multiple choices.

text_field(name, value=None)

Creates a standard text field.

value is a string that will the contents of the text field will be set to

Options:

  • disabled - If set to True, the user will not be able to use this input.
  • size - The number of visible characters that will fit in the input.
  • maxlength - The maximum number of characters that the browser will allow the user to enter.

Remaining keyword options will be standard HTML options for the tag.

hidden_field(name, value=None)

Creates a hidden field

Takes the same options as text_field

file_field(name, value=None)

Creates a file upload field.

If you are using file uploads then you will also need to set the multipart option for the form.

password_field(name='password', value=None)

Creates a password field

Takes the same options as text_field

text_area(name, content='')

Creates a text input area.

Options:

  • size - A string specifying the dimensions of the textarea.

Example:

>>> text_area("body", '', size="25x10")

check_box(name, value='1', checked=False)

Creates a check box.

radio_button(name, value, checked=False)

Creates a radio button.

submit(value='Save changes', name='commit')

Creates a submit button with the text value as the caption.

Options:

  • confirm - A confirm message displayed when the button is clicked.
  • disable_with - The value to be used to rename a disabled version of the submit button.

If options contains a keyword pair with the key of "disable_with", then the value will be used to rename a disabled version of the submit button.