[jdom-interest] xml namespaces

Stacie Clark zeclarks at sprynet.com
Thu Sep 7 19:57:03 PDT 2000


Actually now that I've gone back to it, I remember that most of the necessary changes
were in Namespace.java.  (I thought that with all the discussion about namespaces, that
the fixes might have been withheld)

The error that I am seeing comes from the function:
Verifier.checkNamespacePrefix(String prefix)
which is called from:
public static Namespace getNamespace(String prefix, String uri)
The error is produced because, logically, the xml prefix cannot be determined to be
valid without the URI.  The (prefix, URI) pair can be (xml,
"http://www.w3.org/XML/1998/namespace") or (xml, "")

When I looked at this last month, I fixed this problem by adding a guard clause to
public static Namespace getNamespace(String prefix, String uri) :

        if(isXmlNamespace(prefix, uri))
        {
            return (Namespace)namespaces.get(XML_NAMESPACE_URI);
        }

The clause uses this function in Namespace, which I also added:

   public static boolean isXmlNamespace(String prefix, String uri)
    {
       if(prefix.toLowerCase().equals(XML_PREFIX) && uri.equals(""))
       {
          return true;
       }
       if(uri.equals(XML_NAMESPACE_URI))
       {
          return true;
       }

       return false;
    }

The strigs are:
    public static final String XML_NAMESPACE_URI =
"http://www.w3.org/XML/1998/namespace";
    public static final String XML_PREFIX = "xml";

This fixed the problem tonight when I added it to Namespace.java

Jason Hunter wrote:

>  % grep xml:lang *.java
> Verifier.java:        // Allow xml:space and xml:lang as special cases
> Verifier.java:            name.equals("xml:lang")) {
>
> -jh-
>
> Stacie Clark wrote:
> >
> > Did the fix for xml:lang and xml:space not make it into CVS?  I just
> > tested on the latest code in CVS and I got an error.
> >
> > Stacie Clark
> >
> > _______________________________________________
> > To control your jdom-interest membership:
> > http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com




More information about the jdom-interest mailing list