Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
djmaze
Subject Matter Expert



Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv

PostPosted: Fri Sep 19, 2008 1:44 pm Reply with quote

Gremmie wrote:
djmaze, I'm curious about that, and have read conflicting things. I have used entities such as • and € in pages and they have been accepted by the online W3 validator.

See this from the spec: [ Only registered users can see links on this board! Get registered or login! ]

Edit: so from the above, I believe named entities are allowed in XHTML.


incorrect. The w3c validator is a SGML validator not an XHTML validator.

1. Create a real XHTML document with header('Content-Type: application/xhtml+xml')
2. Try to use javascript:
2.a. document.write()
2.b. document.body.innerHTML('this & that')
2.c. document.body.innerHTML('this   that')

Open in Safari 3, Firefox 3 and Opera 9.5


As per your link to the specs: The specs do say you must include DTD/xhtml-special.ent. Did you ever try that?


http://www.w3.org/TR/REC-xml/#sec-predefined-ent wrote:
[Definition: Entity and character references may both be used to escape the left angle bracket, ampersand, and other delimiters. A set of general entities (amp, lt, gt, apos, quot) is specified for this purpose. Numeric character references may also be used; they are expanded immediately when recognized and MUST be treated as character data, so the numeric character references "<" and "&" may be used to escape < and & when they occur in character data.]

This is because the characters (amp, lt, gt, apos, quot) are part of the XML language itself so you need a substitute for those. Any other entity is not needed because XML is UTF-8 by nature and UTF-8 already supports most characters.
If your editor fails to write proper UTF-8 and your server doesn't support the UTF-8 header then you need the additional .ent files.


Last edited by djmaze on Fri Sep 19, 2008 2:06 pm; edited 1 time in total 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Fri Sep 19, 2008 2:04 pm Reply with quote

No, the online W3 validator looks at your doctype string to determine you are giving it XHTML and validates it accordingly. It does validate XHMTL.

You need to protect your inline javascript with CDATA sections if you are going to use it in XHTML because there are certain characters commonly used in javascript (like [, ], &, etc) that don't follow the XHTML rules.

See for example: [ Only registered users can see links on this board! Get registered or login! ]

The spec does not say you have to include that DTD. The spec says that DTD is part of the XHTML spec and any parser that claims to be XHTML compliant must support those named entities.

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
djmaze







PostPosted: Fri Sep 19, 2008 2:15 pm Reply with quote

Gremmie wrote:
No, the online W3 validator looks at your doctype string to determine you are giving it XHTML and validates it accordingly. It does validate XHMTL.

You need to protect your inline javascript with CDATA sections if you are going to use it in XHTML because there are certain characters commonly used in javascript (like [, ], &, etc) that don't follow the XHTML rules.

See for example: [ Only registered users can see links on this board! Get registered or login! ]

I know that. I never said anything about CDATA. I was talking about entities.
I also didn't told you which errors you get if you follow my rules, therefore.... here's an example:
Code:


<?php header('Content-Type: application/xhtml+xml; charset=utf-8'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Home</title>
<script type="text/javascript"><![CDATA[
   try { document.write('this and that'); } catch (e) { alert('write() failed'); }
   try { document.body.innerHTML('this &amp; that'); } catch (e) { alert('innerHTML(amp) failed'); }
   try { document.body.innerHTML('this &nbsp; that'); } catch (e) { alert('innerHTML(nbsp) failed'); }
]]></script>
</head>
<body>
</body>
</html>


Also Javascript is a complete different ballgame when i start talking about createElement() vs createElementNS()
 
wHiTeHaT
Life Cycles Becoming CPU Cycles



Joined: Jul 18, 2004
Posts: 579

PostPosted: Fri Sep 19, 2008 2:59 pm Reply with quote

Djmaze is right abouth the statement, as it is 'accepted' it doesnt mean it is the right way.,
Evereyone should be able to write dayly used characters.
Beside that , if you follow utf-8 , it isnt needed at all.

And from my own humble opinion, i think best way is to go strict.

There is aloth of efford done from w3c to get the old methode's in conjuntion with there vision of current standarisation.

There can be said aloth of this but it isnt uppon me to do, i am not able to explain it.
Sorry!
However think of it if you write simply € or write &euro; or € or &#x20AC;
Grtzzz wHiTeHaT
 
View user's profile Send private message Send e-mail
Gremmie







PostPosted: Fri Sep 19, 2008 3:16 pm Reply with quote

djmaze wrote:
I was talking about entities.


So was I.

Here is what you said:

djmaze wrote:

XHTML speaking: you're not allowed to use entities. So &pound; is NOT, i repeat, IS NOT the solution!


This is not true. There are entities in XHTML. They are allowed and are in the spec.
 
wHiTeHaT







PostPosted: Fri Sep 19, 2008 3:31 pm Reply with quote

Mmm sorry if i try to participate.
It is hard to explain for just html or just xhtml withouth iso and utf.
However if you write xhtml and dont want to get in to troubles you must use utf-8 and prepare your database ( if use one) for it aswell .. that is fact.

Problems what can occure is directly what this topic is abouth , so to avoid you should follow the rules.
If you use anything below strict , you not folow the best way of create things ... sorry it isnt what we deside as individuals... however some smart peep did it for us.

And if the smart peeps where on theire own , they would eliminate al below strict and utf.
 
Gremmie







PostPosted: Fri Sep 19, 2008 3:45 pm Reply with quote

I see what you are saying wHiTeHaT about using utf-8, and I agree with you 100%. But to say entities are not allowed or are illegal in XHTML is wrong. I'm done.
 
wHiTeHaT







PostPosted: Fri Sep 19, 2008 3:51 pm Reply with quote

I think djmaze want to say that (expression) entities arent part of xhtml but are by default HTML , and yes then he's right.
But in mixes of different coding languages it is in some cases maby not to avoid , however i put my big question {?} mark on this one
 
djmaze







PostPosted: Fri Sep 19, 2008 3:54 pm Reply with quote

Gremmie i understand you, i really do!

I understand browsers that parse XHTML do accept entities. However, these days more and more people get involved with AJAX and Comet.
If you learn to use invalid XML then it will break when you learn more and start integrating.

One other big mistake people make due to entities is to store the entities in the database table column.
What if you want to output a text version or RSS or Atom?
You convert all entities back?

What if you start using XSLT to convert your XHTML into PDF, HTMLHelp and who knows what else?
 
wHiTeHaT







PostPosted: Fri Sep 19, 2008 4:06 pm Reply with quote

djmaze wrote:
Gremmie i understand you, i really do!

I understand browsers that parse XHTML do accept entities. However, these days more and more people get involved with AJAX and Comet.
If you learn to use invalid XML then it will break when you learn more and start integrating.

One other big mistake people make due to entities is to store the entities in the database table column.
What if you want to output a text version or RSS or Atom?
You convert all entities back?

What if you start using XSLT to convert your XHTML into PDF, HTMLHelp and who knows what else?


Well and that is the whole point abouth php-nuke and all fork based.
This is excactly why i see more and more peep avoid all related to nuke.
I'm sorry for it , i really like it's simplicity ( as i started with php-nuke and a few week after was a dev of osc2nuke) , i havent learned much from other cms systems , it is the reason why i still stick to nuke.

I cant blame these peep , i know they are right , and i know my choice is bad aswell, however , for now it is all i can work with.
It still was a good learning base, but even i would only suggest a nuke user to use a ravennuke but i wouldnt suggest it to a fresh starter.

Sorry if i go off-topic , but it was in my mind for a long time , and i knew it wouldnt take long before it came out.
 
wiz
Involved
Involved



Joined: Oct 09, 2006
Posts: 413
Location: UK

PostPosted: Fri Sep 19, 2008 5:09 pm Reply with quote

This, was a simple table converted to php using echo statements. I got my answer, so this proves the worth of this forum. however the responses, prove that there is lots to discuss. This is excellent!!
Can i just quote this though...
djmaze wrote:
XHTML speaking: you're not allowed to use entities. So &pound; is NOT, i repeat, IS NOT the solution!

Get a hang of charset usage and UTF-8


As djmaze Quite rightly says, this is not the solution..it solves the IE errors, but man; you should see Seamonkey (Mozilla) outputting the &pound as text.
so where and how do i call the utf-8?
its 1 page running a css sheet.
cheers lads
 
View user's profile Send private message Visit poster's website AIM Address
testy1
Involved
Involved



Joined: Apr 06, 2008
Posts: 484

PostPosted: Fri Sep 19, 2008 6:58 pm Reply with quote

montego wrote:
Yup... that is how I do it as well. Only thing I wanted to add, is that I have moved away from even using the . "\n" as it is just extra characters to type and with the good extensions these days for FF and other browsers, you can with a click of the button, have your HTML reformatted for easier reading if you really need it.


good point, I have a script i built that formats it for me to save on time, but I may have to update it.Those extra pieces of code could add a lot of useless information to a big site.


Edit: 2 pages lol sorry didn't realise
 
View user's profile Send private message
djmaze







PostPosted: Sat Sep 20, 2008 2:44 am Reply with quote

wiz wrote:
As djmaze Quite rightly says, this is not the solution..it solves the IE errors, but man; you should see Seamonkey (Mozilla) outputting the &pound as text.
so where and how do i call the utf-8?
its 1 page running a css sheet.
cheers lads


Nuk is not utf-8 and not xhtml. To use entities you must use the right format: &pound; (you forgot the last character)
 
testy1







PostPosted: Sat Sep 20, 2008 3:38 am Reply with quote

djmaze wrote:

&pound;


To make it bold like that it should be;

Code:


<strong>&pound;</strong>


sorry couldn't resist Smile
 
wiz







PostPosted: Sat Sep 20, 2008 7:15 am Reply with quote

yep! I missed the semicolon.
 
djmaze







PostPosted: Sat Sep 20, 2008 8:59 am Reply with quote

testy1 wrote:
djmaze wrote:

&pound;


To make it bold like that it should be;

Code:


<strong>&pound;</strong>


sorry couldn't resist Smile


You should report that as a bug in ravennuke Razz
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©