You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Er...@Classwell.com on 2002/03/01 00:04:31 UTC

RE: XmlSerializer putting xmlns="" on children of root element

Well alrighty then! Problem solved. Thanks much, Julian.    :^)

Eric



                                                                                                                            
                      "Julian Reschke"                                                                                      
                      <julian.reschke@         To:      <xe...@xml.apache.org>                                      
                      gmx.de>                  cc:                                                                          
                                               Subject: RE: XmlSerializer putting xmlns="" on children of root element      
                      02/28/2002 05:55                                                                                      
                      PM                                                                                                    
                      Please respond                                                                                        
                      to xerces-j-user                                                                                      
                                                                                                                            
                                                                                                                            




> From: Eric_Schwarzenbach@Classwell.com
> [mailto:Eric_Schwarzenbach@Classwell.com]
> Sent: Thursday, February 28, 2002 11:47 PM
> To: xerces-j-user@xml.apache.org
> Subject: RE: XmlSerializer putting xmlns="" on children of root element
>
>
>
> > Hmmm.
>
> > If you don't want the "foo" prefixes, why do you specify them?
> Note: it's
> > perfectly OK not to specfiy a prefix when using createElementNS().
>
> Maybe that is my problem? My understanding from the javadoc and
> what else I
> could find to read was that, the second argument to
> createElementNS() was a
> "qualifiedName" and needed to have the prefix specified...

See
<
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/glossary.html#dt-qu
alifiedname>:

"A qualified name is the name of an element or attribute defined as the
concatenation of a local name (as defined in this specification),
optionally
preceded by a namespace prefix and colon character. See Qualified Names in
Namespaces in XML [Namespaces]."

> Is this not the case? Is the javadoc wrong, or does "qualified name" not
> really mean "name including the namespace prefix"?
>
> If I do take out the "foo:" from those calls, then my code does produce
> exactly the xml I was shooting for. Even the "xmlns:foo=" becomes the
> "xmlns=" I expected.
>
> This surprises me. This seems to suggest that the explicitness or
> implicitness of the namespace prefix is something actually carried in the
> dom model, not something that is the serializer's issue. Is that really
> true? Should it be true?

The DOM allows you to create elements with or without prefixes.
Serialization of DOM isn't really specified (in DOM Level 2). Im DOM level
3, I'd expect it to actually respect the prefixes you assign as long it
doesn't conflict with creating a wellformed serialization.

> Or alternately, when I coded:
>
> Element elem = doc.createElementNS("http://xml.myurl.com/foo", "elem");
>
> Was I in actuality creating an element whose namespace was foo and whose
> name itself was foo.elem (thus actually having the name "foo.foo.elem"?

No. You are creating an element in the namespace named
"http://xml.myurl.com/foo" and a qualified name "elem" (which happens not
to
be prefixed).


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org