Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 XML: Does not use my DTD!

Author  Topic 

kfluffie
Posting Yak Master

103 Posts

Posted - 2009-05-21 : 13:08:08
Alright, so I am about to start a course about XML in MSSQL2005 and I started to read a little bit before that course.

This is my DTD, person.dtd:
<!ELEMENT person     (name, profession*)>

<!ELEMENT name (first_name, last_name)>

<!ELEMENT first_name (#PCDATA)>

<!ELEMENT last_name (#PCDATA)>

<!ELEMENT profession (#PCDATA)>


person.xml:
<?xml version="1.0" standalone="no"?>

<!DOCTYPE person SYSTEM "person.dtd">

<person>

<profession>computer scientist</profession>

<name>

<first_name>Alan</first_name>

<first_name>Tomas</first_name>

<first_name>Carl</first_name>

<last_name>Turing</last_name>

</name>

<profession>mathematician</profession>

<profession>cryptographer</profession>

</person>


Unfortunatly, for some reason the XML goes through when there should be a validation error on:
* <profession>computer scientist</profession> (Not allowed in the element person)
* <first_name>Tomas</first_name> (Only one first_name element allowed in <name>)

I also tried this but with no validation error:
<?xml version="1.0"?>

<!DOCTYPE person [

<!ELEMENT first_name (#PCDATA)>

<!ELEMENT last_name (#PCDATA)>

<!ELEMENT profession (#PCDATA)>

<!ELEMENT name (first_name, last_name)>

<!ELEMENT person (name, profession*)>

]>

<person>

<name>

<first_name>Alan</first_name>

<last_name>Turing</last_name>

</name>

<profession>computer scientist</profession>

<profession>mathematician</profession>

<profession>cryptographer</profession>

</person>


I have open the XML in both Internet Explorer, Firefox and two rule out if the browsers doesen't do any validation I also tried XMLFox without any result.

Can anyone assist me on this one?


Best Regards,
KFluffie

kfluffie
Posting Yak Master

103 Posts

Posted - 2009-05-21 : 13:39:46
Same file but with "Topologi Schematron Validator":


**************************************************************************************************
XML File: C:\Documents and Settings\Administratör.TOMAS-0F582193F\Mina dokument\XML\person.xml
Schema: Internal
**************************************************************************************************
XML file passed without errors.


Go to Top of Page

kfluffie
Posting Yak Master

103 Posts

Posted - 2009-05-21 : 17:47:56
Alright, I have now installed "Stylus Studio 2009 XML Ent. Suite" and then I can validate as I want to!
Go to Top of Page
   

- Advertisement -