Deleted member 66701
Deleted member 66701
XML - DTD's and XSD's - one or the other but not both?
EDIT:- Topic renamed to make it clear what I'm asking:-
************************************************
*XML - DTD's and XSD's - one or the other but not both?*
************************************************
Hi all
I've the following code
That is passing validation (here) but I get a "No DOCTYPE found! Checking XML syntax only." comment. If I add the relevant doctype (see line six commented code) then it breaks and I get a raft of errors (there is no attribute "xmlns" and so on - which you'd fully expect).
Now, I don't think I need to declare a doctype if I'm using an xsd to validate, but my uni lecturer thinks differently - are they correct?
EDIT:- Topic renamed to make it clear what I'm asking:-
************************************************
*XML - DTD's and XSD's - one or the other but not both?*
************************************************
Hi all
I've the following code
Code:
<?php
header("Content-type: text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<?xml-stylesheet type="text/xsl" href="artists.xsl"?>';
// echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo '<artists xmlns="http://discography.frontierwebdesign.co.uk/discography" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://discography.frontierwebdesign.co.uk/discography artists.xsd">';
//perform query and store in $result
$results = mysql_query("SELECT * FROM `ARTIST`");
while($row = mysql_fetch_array($results)) {
echo '<artist>';
echo "<fname>" .
$row["artist_fname"] .
"</fname>";
echo "<sname>" .
$row["artist_sname"] .
"</sname>";
echo "<id>" .
$row["artist_id"] .
"</id>";
echo "<bio>" .
htmlentities($row["artist_description"]) .
"</bio>";
echo '<albums>';
//perform query and store in $result
$albumResult = mysql_query("SELECT *
FROM `ARTIST_ALBUM`
INNER JOIN `ALBUM`
ON `ARTIST_ALBUM`.`album_id` =
`ALBUM`.`album_id`
WHERE `artist_id` =
{$row['artist_id']}
ORDER BY `album_year` ASC
");
while($albumRow = mysql_fetch_array($albumResult)) {
echo '<album>';
echo "<name>" .
$albumRow["album_name"] .
"</name>";
echo "<album_id>" .
$albumRow["album_id"] .
"</album_id>";
echo '</album>';
}
echo '</albums>';
echo '</artist>';
}
echo '</artists>';
?>
That is passing validation (here) but I get a "No DOCTYPE found! Checking XML syntax only." comment. If I add the relevant doctype (see line six commented code) then it breaks and I get a raft of errors (there is no attribute "xmlns" and so on - which you'd fully expect).
Now, I don't think I need to declare a doctype if I'm using an xsd to validate, but my uni lecturer thinks differently - are they correct?
Last edited by a moderator: