wood burning stoves*
The moose likes XML and Related Technologies and the fly likes Why you should avoid Notation Declarations ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Why you should avoid Notation Declarations ?" Watch "Why you should avoid Notation Declarations ?" New topic
Author

Why you should avoid Notation Declarations ?

Razvan MIHAIU
Ranch Hand

Joined: Nov 12, 2004
Posts: 43
Hi,



In an article by Mr. Kohsuke Kawaguchi found at:

http://www.xml.com/pub/a/2001/06/06/schemasimple.html?page=2

he explains why notations should be avoided. The following XML Schema is provided:

<xsd:notation name="jpeg" public="image/jpeg" system="viewer.exe" />

<xsd:element name="picture2">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:hexBinary">
<xsd:attribute name="pictype">
<xsd:simpleType>
<xsd:restriction base="xsd:NOTATION">
<xsd:enumeration value="jpeg"/>
<xsd:enumeration value="png"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>

The following XML is OK:

<picture pictype="jpeg"> ... </picture>

and so is this: (I tested with XML Spy 2005 and XSV 2.8-1)

<pic :p icture pictype="jpeg"> ... </pic :p icture>

but the author says that the later form is invalid:

"
But the following fragment is not valid even if the prefix "pic" is properly declared.

<pic:picture pictype="jpeg"> ... </pic:picture>

Confused? You have to write it as follows because it's a QName:

<pic:picture pictype="pic:jpeg"> ... </pic:picture>

Apparently it fails to serve its only reason for existing. There's really no
reason to use notations. Notations are for SGML.
"

Can somebody explain why notations are bad and they should be avoided ?



Regards,
Razvan
[ February 23, 2005: Message edited by: Razvan MIHAIU ]

Regards,<br /><a href="http://www.mihaiu.name" target="_blank" rel="nofollow">Razvan</a><br /> <br /> <br />SCJP PREPARATION MATERIAL:<br /><a href="http://www.mihaiu.name/2004/sun_java_scjp_310_035/index.html" target="_blank" rel="nofollow">SCJP 310-035</a><br /><a href="http://www.mihaiu.name/2004/sun_java_scjp_310_035_test1/index.html" target="_blank" rel="nofollow">SCJP 310-035 T1</a><br /><a href="http://www.mihaiu.name/2004/sun_java_scjp_310_035_test2/index.html" target="_blank" rel="nofollow">SCJP 310-035 T2</a><br /><a href="http://www.mihaiu.name/2004/sun_java_scjp_310_035_test3/index.html" target="_blank" rel="nofollow">SCJP 310-035 T3</a><br /><a href="http://www.mihaiu.name/2004/sun_java_scjp_310_035_test4/index.html" target="_blank" rel="nofollow">SCJP 310-035 T4</a>
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Interesting.
The author concludes at the end saying
Even worse, you can't detect this error in some validators because they think that those missing components may appear afterward.

may be xmlspy is one of it.
Have you checked with topologi schematron validator or with others. i guess refering w3c spec would be the best choice.

By the way..i see you have edited your post and added space between some letter to disable smilies that appear because of xml tags,instead you tick the check box that appear below the post submit button "Disable smilies in this post". That will remove the cause.


Spritle Software Blogs
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why you should avoid Notation Declarations ?
 
Similar Threads
XSD Conditional
extending a complexType
Simple Type Inheritance
Help in creating XML Schema
Xml Schema (xsd element/attribute) question