XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Michael SalmanSubject: Validation error
Author: Michael Salman
Date: 23 Nov 2015 06:29 PM
I wonder if someone could tell me why I am getting this validation error
Here is the xml file:
<?xml version="1.0"?><!DOCTYPE employees SYSTEM "file:///e:/XmlProjects/TestUml.dtd">
<employees>
<employee id="1">
<firstName>Mike</firstName>
<lastName>Smith</lastName>
</employee>
</employees>
Here is the DTD file:
<?xml version="1.0" encoding="UTF-16LE"?>
<!ELEMENT firstName (#PCDATA)>
<!ELEMENT lastName (#PCDATA)>
<!ELEMENT employee (firstName,lastName)>
<!ATTLIST employee id ID #REQUIRED>
<!ELEMENT employees (employee)>
Here is the error stylus studio gives me:
Validating TestUml.xml...
file:///e:/XmlProjects/TestUml.xml:3,18: value '1' for attribute 'id' is invalid Name or NMTOKEN value
The XML document TestUml.xml is NOT valid (1 errors)

Now if I change ID to CDATA the xml file validates. Could someone tell me what is wrong with my DTD file as far as I can tell the syntax is valid

Postnext
Ivan PedruzziSubject: Validation error
Author: Ivan Pedruzzi
Date: 23 Nov 2015 10:21 PM
http://www.stylusstudio.com/xsllist/handler.asp?/xsllist/200908/post90210.html

Change the id attribute definition to
<!ATTLIST employee id CDATA #REQUIRED>


Ivan Pedruzzi
Stylus Studio Team

Postnext
Michael SalmanSubject: Validation error
Author: Michael Salman
Date: 24 Nov 2015 12:53 AM
Well I am not an xml expert but I have to disagree with you on this. First of all ID is a legal Content Type. I wrote a c# program which has an XmLDocument class which is used for parsing and manipulating xml files. It has a function called GetElementById(string) which returns an element containing the attribute. In this case I would use it like this
GetElementById("1") but this function will not work if it is not defined with the Content Type ID (which is used to identify an attribute as being unique. Stylus Studio should not report that there is a validation error as there is none
Regards Mike

Postnext
Ivan PedruzziSubject: Validation error
Author: Ivan Pedruzzi
Date: 24 Nov 2015 01:37 AM
I am not sure on what you are disagreeing. This is what the XML specification states.

Type ID in the XML DTD specifications is defined as NAME therefore it cannot be a number.

http://www.w3.org/TR/REC-xml/#id
<<"Values of type ID must match the Name production">>
http://www.w3.org/TR/REC-xml/#NT-Name

The error you see in the output window is reported by Apache Xerces and any other XML complaint parsers when DTD validation is enabled.

The fact that the .NET DOM API getElementByID does not throw an error is irrelevant.

Ivan Pedruzzi
Stylus Studio Team

Posttop
Michael SalmanSubject: Validation error
Author: Michael Salman
Date: 24 Nov 2015 02:44 AM
I apologize it is my error. I changed it to id="one" and it now works fine. The only excuse I have is I am reading a book on xml and it gives sample xml and dtd files which are obviously erroneous
Thanks for your prompt response
Regards Mike

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.