Hi all,
|| -----Original Message-----
|| From: Discussion list for the Java Architecture for XML
|| Binding [mailto:JAXB-INTEREST_at_JAVA.SUN.COM] On Behalf Of
|| Kohsuke Kawaguchi
|| Sent: maandag 28 juli 2003 18:54
|| To: JAXB-INTEREST_at_JAVA.SUN.COM
|| Subject: Re: Namespaces in marshalled Node
||
|| This seems like more of a XML Schema question, but anyway,
|| you have to add @targetNamespace to <xsd:schema>.
Ok, so I did. Now the resulting xml file look like this:
<?xml version="1.0"?>
<user xmlns="
http://www.mycomp.com/user">
<email xmlns="">jeroenb7_at_x-hive.com</email>
<password xmlns="">XSPXJPSB</password>
<ip xmlns="">127.0.0.1</ip>
<host xmlns="">127.0.0.1</host>
<name xmlns="">fewfew</name>
<title xmlns="">fewfew</title>
<companyName xmlns="">j</companyName>
<companyAddress xmlns="">j</companyAddress>
<companyCity xmlns="">j</companyCity>
<companyState xmlns="">j</companyState>
<companyZip xmlns="">j</companyZip>
<companyCountry xmlns="">j</companyCountry>
<companyTelephone xmlns="">jj</companyTelephone>
<companyFax xmlns=""/>
<companyURI xmlns=""/>
<comments xmlns=""/>
<industries xmlns=""/>
<relation xmlns=""/>
<size xmlns=""/>
<project xmlns=""/>
<timeframe xmlns=""/>
<os xmlns=""/>
<source xmlns=""/>
<updateNews xmlns=""/>
<downloads xmlns=""/>
</user>
For some reason on the newly created nodes a namespace is set but it is
not set to the 'targetNamespace' (only the root-element). Of course when
all subelements wouldn't have the default namespace attributes xmlns
everything would be in the correct namespace
'
http://www.mycomp.com/user'.
I suspect this could be a incompatibilty between the DOM implementation
I use (from X-Hive/DB) and the one (I think) most use namely Xerces.
Could somebody confirm this or tell me what I doing wrong?
This is my schema:
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:userSpace="
http://www.mycomp.com/user"
targetNamespace="
http://www.mycomp.com/user">
<xsd:element name="user">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="email" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
<xsd:element name="ip" type="xsd:string"/>
<xsd:element name="host" type="xsd:string"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="companyName" type="xsd:string"/>
<xsd:element name="companyAddress" type="xsd:string"/>
<xsd:element name="companyCity" type="xsd:string"/>
<xsd:element name="companyState" type="xsd:string"/>
<xsd:element name="companyZip" type="xsd:string"/>
<xsd:element name="companyCountry" type="xsd:string"/>
<xsd:element name="companyTelephone" type="xsd:string"/>
<xsd:element name="companyFax" type="xsd:string"/>
<xsd:element name="companyURI" type="xsd:string"/>
<xsd:element name="comments" type="xsd:string"/>
<xsd:element name="industries" type="xsd:string"/>
<xsd:element name="relation" type="xsd:string"/>
<xsd:element name="size" type="xsd:string"/>
<xsd:element name="project" type="xsd:string"/>
<xsd:element name="timeframe" type="xsd:string"/>
<xsd:element name="os" type="xsd:string"/>
<xsd:element name="source" type="xsd:string"/>
<xsd:element name="updateNews" type="xsd:string"/>
<xsd:element name="downloads" type="userSpace:DownloadsType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="DownloadsType">
<xsd:sequence>
<xsd:element name="download" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="file" type="xsd:string"/>
<xsd:element name="date" type="xsd:string"/>
<xsd:element name="ip" type="xsd:string"/>
<xsd:element name="host" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Thanks and regards,
Jeroen
--
X-Hive Corporation
e-mail: jeroenb_at_x-hive.com
phone: +31 10 2818080
http://www.x-hive.com