You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by Mike Gratton <mi...@vee.net> on 2002/02/22 18:35:37 UTC

invalid attribute NS URIs / reading 'raw' data files

Hi guys,

I'm trying to track down precisely where Xindice is setting invalid 
attribute namespace URIs for unprefixed attributes. According to the 
namespace rec, unprefixed attributes are *not* in the default namespace 
- hence their namespace URI should be the empty string. In both the SAX 
and DOM representations I'm getting back from Xindice (DarkHorse), 
unprefixed attributes have the same namespace URI as the default namespace.

For example, of you retrieve the following document from Xindice:

<xsl:stylesheet
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

  ...

</xsl:stylesheet>

The namespace URI of the 'version' attribute will be 
'http://www.w3.org/1999/xhtml', rather than ''. This holds true for 
accessing the doc via both the DOM and SAX.

This is a blocker for me as it means Xalan refuses to recognise the 
above XSLT stylesheet as being valid - it rightly complains that there 
is no 'version' attribute - and hence I can't store my stylesheets in 
Xindice. (The document was added using the command line tools, if that 
makes any difference).

Now, if someone knows a quick fix for this, or if it has already been 
fixed in CVS, please let me know, and I promise not to get too mad for 
having spent the last three hours tracking down why Xalan is failing on 
me and looking into where Xindice is going wrong. 8)

If not, I'll happily find the bug and fix it, but it would help greatly 
if I could see what Xindice is storing in it's data files, so I can 
determine if the invalid NS URI is creeping in at document creation time 
or when it is retreived. If someone could provide some pointers here, 
I'd appreciate it.

Also, I assume xml.dom.DOMParser is used by the server to parse incoming 
XML strings when creating or storing new documents. Is this correct?

Thanks,
Mike.

-- 
Mike Gratton <mi...@vee.net>
"Every motive escalate."
  Blatant self-promotion: <http://web.vee.net/>


Re: invalid attribute NS URIs / reading 'raw' data files

Posted by Kimbro Staken <ks...@xmldatabases.org>.
It's in, thanks.

On Friday, February 22, 2002, at 11:22 AM, Mike Gratton wrote:

>
> w00t! Fixed it.
>
> Mike Gratton wrote:
> >
> > According to the namespace rec, unprefixed attributes are *not* in
> > the default namespace [...]
>
> For some reason, I didn't think to look at NodeImpl.getNamespaceURI() 
> until just then. Specifically, NodeImpl.lookupDefaultNamespaceURI() is 
> returning the default namespace even when the node is an attribute.
>
> The attached patch fixes this, please have a look and let me know if 
> there are problems with it. If not, could Tom, Kimbro, or another happy 
> committer please apply it to the repository.
>
> Thanks,
> Mike.
>
> -- Mike Gratton <mi...@vee.net>
> "Every motive escalate."
>  Blatant self-promotion: <http://web.vee.net/>
> Index: java/src/org/apache/xindice/xml/dom/NodeImpl.java
> ===================================================================
> RCS file: /home/cvspublic/xml-xindice/java/src/org/apache/xindice/xml/dom/
> NodeImpl.java,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 NodeImpl.java
> --- java/src/org/apache/xindice/xml/dom/NodeImpl.java	6 Dec 2001 19:34:00 
> -0000	1.1.1.1
> +++ java/src/org/apache/xindice/xml/dom/NodeImpl.java	22 Feb 2002 18:22:07 
> -0000
> @@ -765,9 +765,9 @@
>      * @return The URI (or null)
>      */
>     public final String lookupDefaultNamespaceURI() {
> -      String uri = null;
> -      if ( getNodeType() == Node.ELEMENT_NODE )
> -         uri = ((Element)this).getAttribute(XMLNS_PREFIX);
> +      if ( getNodeType() != Node.ELEMENT_NODE )
> +	  return null;
> +      String uri = ((Element)this).getAttribute(XMLNS_PREFIX);
>        if ( uri != null && uri.length() > 0 )
>           return uri;
>        return parentNode != null ? parentNode.lookupDefaultNamespaceURI()
>
Kimbro Staken - http://www.kstaken.org - http://www.xmldatabases.org
Apache Xindice native XML database http://xml.apache.org
XML:DB Initiative http://www.xmldb.org
Senior Technologist (Your company name here)


Re: invalid attribute NS URIs / reading 'raw' data files

Posted by Mike Gratton <mi...@vee.net>.
w00t! Fixed it.

Mike Gratton wrote:
 >
 > According to the namespace rec, unprefixed attributes are *not* in
 > the default namespace [...]

For some reason, I didn't think to look at NodeImpl.getNamespaceURI() 
until just then. Specifically, NodeImpl.lookupDefaultNamespaceURI() is 
returning the default namespace even when the node is an attribute.

The attached patch fixes this, please have a look and let me know if 
there are problems with it. If not, could Tom, Kimbro, or another happy 
committer please apply it to the repository.

Thanks,
Mike.

-- 
Mike Gratton <mi...@vee.net>
"Every motive escalate."
  Blatant self-promotion: <http://web.vee.net/>