Agree here also. I discovered something interesting the other day though. I've been working with .NET XML stuff at work lately, and I created a program that takes an XML Schema document and generates a valid, minimal XML document based on the schema. It uses Microsoft's Schema DOM and their XML DOM, and this is what I'm basing it on, not the spec, so take it with a grain of salt. However, I had a schema which had an element with both elements declared explicitly for a particular element, as well as an attribute that was declared at the top-level and referenced in the element. Eg:
<xsd:schema xmlns:xsd="http://..." targetNamespace="urn:mynamespace"> <xsd:element name="anElement"> <xsd:complexType> <xsd:attribute name="explicitAttr" type="xsd:string" use="required"/> <xsd:attribute ref="topLevelAttr"/> </xsd:complexType> </xsd:element> <xsd:attribute name="topLevelAttr" use="required" type="xsd:string"/> </xsd:schema> Now, the MS Schema DOM considered 'explicitAttr' and 'topLevelAttr' to be namespaced ifferently. 'explicitAttr' had no namespace, while topLevelAttr was considered to be in the targetNamespace (urn:mynamespace). This is what I basically expected. What surprised me was what happened when I created an XML document using the MS XML DOM and assigned each node it's appropriate namespace. If I saved the DOM with my target namespace as the default namespace (xmlns="urn:mynamspace"), the following document was generated: <anElement xmlns="urn:mynamespace" xmlns:dhc1="urn:mynamspace" explicitAttr="" dhc1:topLevelAttr="""/> 'dhc1' was an auto-generated namespace prefix created by the DOM. This gells with what James and I have said below - attributes must be prefixed to be namespaced. What surprised me is what was generated when I saved the document with my namespace prefixed: <mns:anElement xmlns:mns="urn:mynamespace" explicitAttr="" topLevelAttr=""/> So, it seems that MS considers that if you have an element declared in the default namespace which has an attribute in the same namespace, the element must still be declared with a prefix, otherwise it will not be namespaced correctly. However, if the containing element is in a prefixed namespace, the namespaced attribute does not require a prefix of its own. Wierd. I don't know how you are supposed to determine what namespace explicitAttr and topLevelAttr are in in the second example. I'm not sure if this is simply an error on the part of the MS DOM (or possibly my own program, although I'm pretty sure it's ok), or if this is to spec. Anybody know? David ----- Original Message ----- From: "James Strachan" <[EMAIL PROTECTED]> To: "David Peterson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, October 23, 2002 7:46 PM Subject: Re: [Jaxen] Default namespaces: alternatives? > Agreed. And I think that these 2 documents are identical... > > <xhtml:html xmlns:xhtml="http://www.w3.org/..."> > <xhtml:body style="mystyle"> > </xhtml:body> > </xhtml:html> > > <html xmlns="http://www.w3.org/..."> > <body style="mystyle"> > </body> > </html> > > i.e. that in both case the style attribute is in no namespace and is > attached to the body element which is in the XHTML namespace. > > It still does suprise me how complex, something as apparently simple as XML > namespaces can be. > > James > ------- > http://radio.weblogs.com/0112098/ > ----- Original Message ----- > From: "David Peterson" <[EMAIL PROTECTED]> > To: "James Strachan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Wednesday, October 23, 2002 9:56 AM > Subject: Re: [Jaxen] Default namespaces: alternatives? > > > > Exactly. Which means that any attributes in an xhtml document that are not > > explicitly prefixed with "xhtml" (or whatever) are not namespaced. Eg: > > > > Example 1: > > <xhtml:html xmlns:xhtml="http://www.w3.org/..."> > > <xhtml:body style="mystyle"> > > </xhtml:body> > > </xhtml:html> > > > > Example 2: > > <xhtml:html xmlns:xhtml="http://www.w3.org/..."> > > <xhtml:body xhtml:style="mystyle"> > > </xhtml:body> > > </xhtml:html> > > > > In Example 1, the 'style' attribute is non-namespaced. In Example 2, it is > > namespace to the XHTML namespace. However, I don't believe that Example 2 > is > > valid XHTML, since the spec does not explicitly declare style attribute in > > the namespace - only a 'style' attribute attached to the body element (and > > other elements, of course). Two different things, to my understanding. > > > > David > > > > ----- Original Message ----- > > From: "James Strachan" <[EMAIL PROTECTED]> > > To: "David Peterson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Wednesday, October 23, 2002 6:48 PM > > Subject: Re: [Jaxen] Default namespaces: alternatives? > > > > > > > From: "David Peterson" <[EMAIL PROTECTED]> > > > > Also, attributes shouldn't be prefixed, unless they are of a different > > > > namespace than the element they are attached to. > > > > > > I thought that attributes without prefixes are always in no namespace > > > (irrespective of whether there is a default namespace defined via > > xmlns=""). > > > Though I remember some confusion on this matter in the early XML schema > > > specs. > > > > > > James > > > ------- > > > http://radio.weblogs.com/0112098/ > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Everything you'll ever need on one web page > > > from News and Sport to Email and Music Charts > > > http://uk.my.yahoo.com > > > > __________________________________________________ > Do You Yahoo!? > Everything you'll ever need on one web page > from News and Sport to Email and Music Charts > http://uk.my.yahoo.com ------------------------------------------------------- This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest