Is this valid DTD?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Is this valid DTD?

Post by Chris Corbyn »

The DOM functions spit errors when I try to declare a CDATA element. I'm a bit rusty on this stuff but I can swear, even when looking this up again, that this is valid:

Code: Select all

<!ELEMENT example (#CDATA)>
It only does it if I put #CDATA there. #PCDATA works fine :(
Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: ContentDecl : Name or '(' expected in Entity, line: 3 in /Users/d11wtq/public_html/swift-www/apps/website/modules/docs/actions/actions.class.php on line 66

Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: expected '>' in Entity, line: 3 in /Users/d11wtq/public_html/swift-www/apps/website/modules/docs/actions/actions.class.php on line 66

Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: internal errorDOCTYPE improperly terminated in Entity, line: 3 in /Users/d11wtq/public_html/swift-www/apps/website/modules/docs/actions/actions.class.php on line 66

Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Start tag expected, '<' not found in Entity, line: 3 in /Users/d11wtq/public_html/swift-www/apps/website/modules/docs/actions/actions.class.php on line 66
Have I got it wrong or is the DOM extension badly implemented?

EDIT | Just FYI, I'm trying to write a custom wiki-type language using XML, which I want to convert to XHTML using XSLT but this is causing me more headaches than it's worth so I may just do some impressive regex parsing (yuck, slow, memory exhaustive).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I don't think you can mark an element's content as CDATA (that would be a short form of <element><![CDATA[ ... ]]></element>?), only (#PCDATA)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

volka wrote:I don't think you can mark an element's content as CDATA (that would be a short form of <element><![CDATA[ ... ]]></element>?), only (#PCDATA)
Ah OK. But what about things like <script> and <style> tags?

Basically I wanted to be able to type source code (including HTML too) within this document and make sure the DOM extension doesn't try to parse it. I couldn't stop the DOM extension parsing the tags that I wanted to be CDATA. I tried manually placing the <![CDATA[ ... ]]> tags in the XSL stylesheet on a "match" but that just acted as CDATA within the stylesheet. It's be pointless for me to require whoever is typing in the wiki to have to write <![CDATA[[ ... ]]> if they wanted to add code.

I'll just go back to good old tokenizing and custom parsing :)

Cheers,

d11
Post Reply