Page 1 of 1

Is this valid DTD?

Posted: Tue Apr 10, 2007 5:33 pm
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).

Posted: Tue Apr 10, 2007 8:35 pm
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)

Posted: Wed Apr 11, 2007 1:51 am
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