users@jaxb.java.net

Again: Problem with namespaces in jaxb generated files

From: Zoltan Sebestyen <szoli2_at_FREEMAIL.HU>
Date: Wed, 06 Nov 2002 02:00:05 -0700

Since the last try to post this message went wrong I post it again, hoping someone can help me out.

 Regards,

"
Hi,

 I've got problems with generating valid XML files. JAXB
puts the whole file
into a namespace called 'ns1', even though it doesn't do so
in case of the
sample applications. I suppose it has to do with my xml
schema, JAXB's
missing something and creates this 'ns1' namespace as a
default. Could you
tell me please what's missing?

Regards,

Zoltan

To check things I wrote a little app that unmarshal an xml
file and then
marshalls it into another file.

The schema header:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.mx.com/Schemas/2002/Service"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.mx.com/Schemas/2002/Service"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
        <xsd:element name="AppPortal">
        ...
        </xsd:element>
        ...
</xsd:schema>


The source file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DEFANGED_AppPortal
xmlns="http://www.mx.com/Schemas/2002/Service"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mx.com/Schemas/2002/Service
D:\Development\AppPortal\src\MyApp\in.xsd">
        <sdtResponse version="00.01" client="1234567890">
                <client>
                        <name>Jozsi Corporate</name>
                        <site>

        <contactName>JoskaPista</contactName>
                                <contactTel>1-234-
567</contactTel>
                                <Location>Joska
Inc.</Location>
                        </site>
                </client>
                <topology>
                        <sapList>
                                <sap id="1234567890"/>
                        </sapList>
                </topology>
        </sdtResponse>
</AppPortal>

The result:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:AppPortal
xsi:schemaLocation="http://www.mx.com/Schemas/2002/Service
D:\Development\AppPortal\src\MyApp\in.xsd"
xmlns:ns1="http://www.mx.com/Schemas/2002/Service"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:sdtResponse version="00.01" client="1234567890">
<ns1:client>
<ns1:name>Jozsi Corporate</ns1:name>
<ns1:site>
<ns1:contactName>JoskaPista</ns1:contactName>
<ns1:contactTel>1-234-567</ns1:contactTel>
<ns1:Location>Joska Inc.</ns1:Location>
</ns1:site>
</ns1:client>
<ns1:topology>
<ns1:sapList>
<ns1:sap id="1234567890"></ns1:sap>
</ns1:sapList>
</ns1:topology>
</ns1:sdtResponse>
</ns1:AppPortal>

"