[jdom-interest] DOCTYPE still giving me the worst headache!

Jason Hunter jhunter at servlets.com
Mon Feb 4 22:40:24 PST 2002


Elliotte Rusty Harold wrote:
> 
> >I don't think we should allow colons in JDOM element names.  If we do,
> >people are going to try to put colons in element names as a way to
> >manage namespaces (since that's the obvious way to do it), and get
> >themselves into loads of trouble.
> >
> 
> I agree, but you mistook what I did. checkElementName() is still
> there and still used for elements. That hasn't changed. Its behavior
> has not changed. However *entity* names can contain colons (as can
> other types of XML names like ID and IDREF attribute values). This
> requires a different method to check. That's why I exposed and used
> checkXMLName(). But I didn't in any way change the existing behavior
> or interface of the Element class.

Glad we agree!  I'm still confused though.  Here's the patch of
Element.java.

diff -d -u -r1.106 Element.java
--- src/java/org/jdom/Element.java      2002/01/25 18:42:52     1.106
+++ src/java/org/jdom/Element.java      2002/02/03 11:03:43
@@ -215,7 +215,9 @@
       *         Element name.
       */
      public Element setName(String name) {
-        String reason = Verifier.checkElementName(name);
+        // Use checkXMLName() instead of checkElementName() here
+        // because we do need to allow this to contain a colon
+        String reason = Verifier.checkXMLName(name);
          if (reason != null) {
              throw new IllegalNameException(name, "element", reason);
          }

I read your comment and code to say you're allowing element names to
contain colons.

And here's the code in EntityRef:

      public EntityRef setName(String name) {
+        // This can contain a colon so we use checkXMLName()
+        // instead of checkElementName()
+        String reason = Verifier.checkXMLName(name);
+        if (reason != null) {
+            throw new IllegalNameException(name, "EntityRef", reason);
+        }

Looks basically the same.  Seems like perhaps you copy/paste typo'd the
Element version and really wanted checkElementName() afterall, which is
why we agree in principle if not in code?

-jh-



More information about the jdom-interest mailing list