W3C home > Mailing lists > Public > www-validator@w3.org > July 2010

RE: Validator fails on PHP instructions inside attribute values

From: Richard Ishida <ishida@w3.org>
Date: Mon, 19 Jul 2010 16:25:12 +0100
To: 'Dag-Erling Smørgrav' <des@des.no>
Cc: "'David Dorward'" <david@dorward.me.uk>, <www-validator@w3.org>
Message-ID: <00a501cb2756$951e4210$bf5ac630$@org>
I'm beginning to understand that the processing instruction thing is clouding the issue, since php code is not inside processing instructions.  

So I suppose that what I really want is a pre-processor that goes through my code and removes everything between <?php ... ?> (taking care obviously to avoid literal strings containing such delimiters), before the validation starts.  

I understand that if you have not coded your PHP carefully you could, by removing it, create an apparently invalid document (eg. if you had a live <p> tag but used echo '...</p>' to close the tag) - that's fair enough.  But I usually find that if I code a little more carefully its usually possible to avoid such problems, and produce more easily maintainable code too.

The benefit is that you can work on PHP documents and validate them without running them through a PHP processor.  There is a lot of PHP out there, and I think this could be very useful to encourage validity.  It would certainly solve problems for me when dealing with translators who otherwise struggle to ensure that what they have translated is still valid wrt the HTML.  Making it easier for them to fix errors they have introduced rather than making me deal with it some time later, describe the problem and return through the cycle has huge benefits for the process.

I also realise that PHP is just one format among many.  

Perhaps, what I really want then, is a checkbox on the validator page that says "Remove PHP code before validating", which does just that, and avoids treating php code as processing instructions.


Richard Ishida
Internationalization Lead
W3C (World Wide Web Consortium)


> -----Original Message-----
> From: Dag-Erling Smørgrav [mailto:des@des.no]
> Sent: 19 July 2010 15:48
> To: Richard Ishida
> Cc: 'David Dorward'; www-validator@w3.org
> Subject: Re: Validator fails on PHP instructions inside attribute values
> "Richard Ishida" <ishida@w3.org> writes:
> > The pages contains lots of PHP instructions, but none of them cause a
> > validation problem other than these instances where the PHP code is
> > inside the attribute value.
> Perhaps because...  *drumroll* processing instructions are not allowed
> inside attribute values.  They are only allowed a) between the XML
> declaration and the DOCTYPE declaration, b) between the DOCTYPE
> declaration and the top-level element, c) after the top-level element,
> and d) as content, i.e. somewhere between the opening and closing tags
> of a non-empty element.
> --
> Dag-Erling Smørgrav - des@des.no
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.839 / Virus Database: 271.1.1/3010 - Release Date: 07/18/10
> 19:35:00
Received on Monday, 19 July 2010 15:25:43 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:18:01 UTC