- From: Dag-Erling Smørgrav <des@des.no>
- Date: Wed, 21 Jul 2010 12:52:33 +0200
- To: "Philip Taylor \(Webmaster\, Ret'd\)" <P.Taylor@Rhul.Ac.Uk>
- Cc: Richard Ishida <ishida@w3.org>, 'David Dorward' <david@dorward.me.uk>, www-validator@w3.org
"Philip Taylor (Webmaster, Ret'd)" <P.Taylor@Rhul.Ac.Uk> writes:
> I think there is a better solution : write a custom DTD that extends
> the DOCTYPE against which you are trying to validate by making all
> well-formed constructs of the form
>
> <?php echo $clang;?>
>
> legal within attribute values and anywhere else that you wish to use
> them but which do not satisfy the formal requirements for a Processing
> Instruction (PI), then validate against that DTD.
Regardless of DTD, you can't have unescaped angle brackets inside
attribute values; nor can you write a DTD that makes <?php ...?>
something else than a PI or allows its use in places where a PI is not
permitted.
<?php ...?> is a well-formed PI and will be ignored by processors that
do not understand it as long as it is used only where a PI is permitted;
I gave a complete list in an earlier reply.
This means you can't do something like
<div>
<?php if (red) {?>
<p style="color: red">
<?php } else {?>
<p style="color: black">
<?php }?>
Hello!
</p>
</div>
because anything other than PHP will ignore the <?php ...?> bits and see
<div>
<p style="color: red">
<p style="color: black">
Hello!
</p>
</div>
which is not well-formed XML.
DES
--
Dag-Erling Smørgrav - des@des.no
Received on Wednesday, 21 July 2010 10:53:08 UTC