LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-01-2017, 09:50 AM   #1
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,606
Blog Entries: 4

Rep: Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997
Does 'libxml' (PHP 'schemaValidate') understand parameter entities in DTDs?


I am dealing with a DTD file which has, for instance, the following parameter entity declaration:

Code:
<!ENTITY % ContentType      "CDATA" >
The purpose of this declaration is so that the DTD can later include &ContentType; and this will be immediately replaced by the string, CDATA, which will then be immediately used in the declaration in which it appears. (Hence, "parameter" entity.) It's a common technique that's used to make DTDs more human-readable.

However, the DOMDocument::schemaValidate() method of PHP-7, which uses libxml.so under the hood, does not appear to understand this. It rejects the DTD with "invalid element type."

Looking at the source-code to this library on GitHub, I think that I have found (in parse.c) that it does not. But, I thought I'd ask ...

Obviously, I can circumvent the problem with a little text-editing, but it's a shame to lose that information and it seems strange to me that it doesn't work.

Last edited by sundialsvcs; 08-01-2017 at 09:55 AM.
 
Old 08-01-2017, 01:08 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,606
Blog Entries: 4

Original Poster
Rep: Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997
I am marking this thread as [SOLVED], not because I have yet found my answer ... (I still want one!) ... but because I found an effective work-around.

It turns out that "validateSchema" does not want a DTD, although it won't overtly refuse one. (Maybe it's supposed to allow both – I don't know.)

Anyhow – when I converted my DTD to an XSD file using an available tool, it was rejected as "not a schema file."

However, when I found and installed the "trang" tool to make a RelaxNG file, I actually got validation to work with the appropriate PHP method-call. Whew!

Last edited by sundialsvcs; 08-01-2017 at 02:59 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 5.3.3 update - missing xml2 or libxml install dir?? macg Linux - Server 4 07-11-2011 04:25 PM
PHP session parameter injection gregorian Linux - Security 5 07-11-2010 02:25 PM
sajax, php, entities, JS and IE eantoranz Programming 2 08-22-2006 05:02 PM
Installing php 5 on suse 9.2 - libxml error lee110968 Linux - Newbie 0 06-11-2006 04:25 AM
PHP Pass Parameter Gerardoj Programming 2 05-25-2004 09:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration