JAXB & Namespace

Hi,
can anyone tell me what's going wrong.
XML-Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="journal">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="item" maxOccurs="unbounded" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>XML-Document to used by JAXB:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:journal xmlns:ns0="a-namespace">
  <item>String1</item>
  <item>String2</item>
</ns0:journal>The classes were generated by xjc (jwsdp-1.1).
Executing a very simple unmarshalling test throws:
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: unexpected root element ns0:journal]
...thank's for your help
-chris

Deepak,
thanks a lot. Finally I got it with this XML-Schema:
<xsd:schema attributeFormDefault="unqualified"
            targetNamespace="a-namespace"
            xmlns="a-namespace"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
            jxb:version="1.0">
  <xsd:annotation>
    <xsd:appinfo>
      <jxb:globalBindings bindingStyle="elementBinding"
                          choiceContentProperty="false"
                          collectionType="java.util.Vector"
                          enableFailFastCheck="false"  
                          fixedAttributeAsConstantProperty="true"
                          generateIsSetMethod="false"
                          typesafeEnumBase="xsd:NCName"
                          typesafeEnumMemberName="generateError"
                          underscoreBinding="asCharInWord"/>
      <jxb:schemaBindings>
        <jxb:package name="package.name"/>
      </jxb:schemaBindings>
    </xsd:appinfo>
  </xsd:annotation>
  <xsd:element name="journal" type="journalType" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
  <xsd:complexType name="journalType" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="a-namespace">
    <xsd:sequence>
      <xsd:element name="item" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
<xsd:schema>

Similar Messages

  • JAXB Namespace Requirements

    I was able to solve the unexpected root element error by including the namespace in the xml. Is there a way to configure JAXB to work with or without the namespace?

    Here is an excerpt from the top level schema: Is there anything here that would require the use of a namespace?
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by Salim Djaffar (WaMu) -->
    <xs:schema targetNamespace="http://schema.wamu.com/wamuhomeloans/loan/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:crm="http://schema.wamu.com/crm/customer/" xmlns="http://schema.wamu.com/wamuhomeloans/loan/" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="2.6">
         <xs:include schemaLocation="loantypes.xsd"/>
         <xs:import namespace="http://schema.wamu.com/crm/customer/" schemaLocation="crmtypes.xsd"/>
         <xs:element name="NoteHistoryRequest" type="NoteHistoryRequestType"/>
         <xs:element name="NoteHistoryResponse" type="NoteHistoryResponseType"/>
         <xs:complexType name="NoteHistoryRequestType">
              <xs:sequence>
                   <xs:element name="LoanInformation" type="LoanInformationType" minOccurs="0"/>
                   <xs:element name="ListFilter" type="ListFilterType" minOccurs="0"/>
              </xs:sequence>
         </xs:complexType>
    </xs:schema>

  • JAXB NameSpace URI

    I am currently using JAXB for data binding to our schemas. However, we maintain our schemas in each of our environments (Dev, Test, and Production). In each environment the schemas contain different namespace URIs that are relative to their environment.
    Is there anyway to compile JAXB so that it doesn't care what NameSpace URI is? This is important when validation (via JAXP) occurs so it doesn't fail when unmarshaling an XML instance generated from a different environment.
    If this is not possible my only option would be to compile 3 sets of objects for dev, test, and production which would not be a great approach : (
    Thanks
    Brian

    Having different name spaces but wanting one set of objects seem contradictory. The motivation for wanting separate name spaces frequently justifies separate objects.
    You could try specifying the same value to -p when you compile each of the schemas. This would place the bindings in the same package. However, you might run into name collisions, which you then would need to resolve (with an external binding file, e.g.).
    Regards,
    -- Ed

  • JAXB namespace common elements

    Hi,
    I'm generating a parser according to 3 DTDs:
    main.dtd
    devinf.dtd
    metinf.dtd
    I have translated the DTDs in 3 XML schemas with DTD to XML Schema translator (found on w3c) that Translate a Document Type Definition (XML 1.0 DTD) into an XML schema (REC-xmlschema-1-20010502):
    http://puvogel.informatik.med.uni-giessen.de/dtd2xs/
    The main.dtd contains an element Meta defined such as:
    <!-- Meta element type -->
    <!-- Element types in the content MUST have name space declared. -->
    <!--The Meta content would be something such as:
    <Meta>
    <Type xmlns='metinf'>myType</Type>
    <Format xmlns='metinf'>myFormat</Format>
    </Meta>-->
    <!ELEMENT Meta (#PCDATA)>
    AND 2 elements Format and Type!!!!
    Converting to Schema:
    <xs:element name="Meta" type="xs:string" />
    <xs:element name="Format" type="xs:string" />
    <xs:element name="Type" type="xs:string" />
    The metinf DTD defines the elements Type and Format such as after converting in schema we have:
    <xs:element name="Format" type="xs:string" />
    <xs:element name="Type" type="xs:string" />
    The devinf DTD defines also these two elements !!!!
    I tried to modify the main schema to import the devinf and metinf schema. However when I try to compile, I receive the error that the compiler atempts to generates the same interface (Format and Type) from the 3 different schema.
    (compile line is:
    xjc -jar %JAVA_LIBS%\jaxb-xjc.jar -p mypackage devinf.xsl metinf.xsl main.xsl)
    How could I do to obtain a Parser that could read and write the following XML:
    <!-- These Format and Type refer to main.dtd -->
    <Format>formatA</Format>
    <Type>typeA</Type>
    <Meta>
    <!-- These Format and Type refer to metinf.dtd -->
    <Format xmlns="metinf">formatB</Format>
    <Type xmlns="metinf">typeB</Type>
    </Meta>
    <!-- These Format and Type refer to devinf.dtd -->
    <Format xmlns="devinf">formatC</Format>
    <Type xmlns="metinf">typeC</Type>
    Many thanks and sorry for my poor english!

    Sorry to disturb you....
    Sometimes you found you are really stupid.
    The solution for the above problem is to define a custom binding (specifying per example a different package for the different DTDs)
    Sorry again
    Tanguy

  • Namespace error with JAXB

    Hello everyone! This is my problem:
    I am using jaxb to unmarshall a xml file. When I unmarshall, the program doesn�t work at this point:
    JAXBContext jc = JAXBContext.newInstance("com.claynet.core.clom");
    Unmarshaller u = jc.createUnmarshaller();
    u.setValidating(true);
    Clom clom =
    (Clom)u.unmarshal(
    new FileInputStream( ".." + File.separatorChar +
    "webapps"+ File.separatorChar + "claybrary" + File.separatorChar
    + "objetosCLOM" + File.separatorChar + file_name.trim()) );
    The error I get is the following one:
    javax.xml.bind.UnmarshalException: Probably namespace URI of tag "clom" is wrong (correct one is "http://www.clayformacion.com/xsd/clomv1.0")
    - with linked exception:
    [com.sun.msv.verifier.ValidityViolation: Probably namespace URI of tag "clom" is wrong (correct one is "http://www.clayformacion.com/xsd/clomv1.0")]
    The problem seems to be a conflict with the namespace, but the schema has the namespace correctly set:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:clom="http://www.clayformacion.com/xsd/clomv1.0" xmlns="http://www.clayformacion.com/xsd/clomv1.0" targetNamespace="http://www.clayformacion.com/xsd/clomv1.0" elementFormDefault="qualified">
    The validation inside the unmarshalling crash.
    Is there any errors with the code? Can Anyone help me?
    Thanks

    Looks like error is clear namespace mismatch...try changing the following url in wsdl and regen the code
    http://example.ws found http://example.ws/xsd

  • [JAXB] Several different prefixes for the same namespace

    Hi!
    I have generated some code from 2 schemas using JAXB. One of them (the main) defines some elements and the other one defines values for those elements. Then, when runring my code, I get an XML document with elements from the main schema an elements from the other one. However, elements from the second schema are qualified with different names. That is:
    <party>
    <ns3:uid xmlns:ns3="http:/schema1.com/schema1">CN=User1 - RSA/RSA,OU=IAIK,O=TU Graz,C=AT</ns3:uid>
    <ns4:role xmlns:ns4="http:/schema1.com/schema1">client</ns4:role>
    </party>
    As you can see, I get two different prefixes for the same namespace.
    Could you be so kind as to tell me if there is a way of getting only one prefix for each namespace, please? Do I have to modify JAXB compiler's properties???
    Thanks a lot in advance.

    No, I don't know how to do that. I also don't think it should matter. Are these multiple prefixes causing you any problems other than offending against Occam's Razor?

  • JAXB 2.0 with JXDM gives error.  Use @XmlType.name and @XmlType.namespace

    Hi,
    I am getting the below error for JXDM when using. It was mentioned in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302524 that it is fixed. Still getting this error.
    a) Appreciate if anyone can tell how to use the bug fix b20 that is mentioned in the above? I downloaded the latest jaxb 2.0 from this site and also from the jaxb RI(Reference Implementation and tried both).
    b) Is there any workaround to get through this?
    Will appreciate if any one can give advise on this.
    ************** Here is the error message ******************
    There was this problem creating a context com.sun.xml.bind.v2.runtime.IllegalAnn
    otationsException: 1 counts of IllegalAnnotationExceptions
    Two classes have the same XML type name "usStateCodeType". Use @XmlType.name and
    @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
    at gov.ojp.it.jxdm.usps_states._1.USStateCodeType
    at protected gov.ojp.it.jxdm.usps_states._1.USStateCodeType gov.
    ojp.it.jxdm._3_0_2.proxy.usps_states._1.USStateCodeType.value
    at gov.ojp.it.jxdm._3_0_2.proxy.usps_states._1.USStateCodeType
    at protected gov.ojp.it.jxdm._3_0_2.proxy.usps_states._1.USState
    CodeType generated.CjsAddressType.locationStateCodeUSPostalService
    at generated.CjsAddressType
    at protected java.util.List generated.CjsPersonType.personAddres
    s
    at generated.CjsPersonType
    at protected generated.CjsPersonType generated.CjsSuspectType.su
    spectPerson
    at generated.CjsSuspectType
    at protected generated.CjsSuspectType generated.CjsReportType.su
    spect
    at generated.CjsReportType
    at public generated.CjsReportType generated.ObjectFactory.create
    CjsReportType()
    at generated.ObjectFactory
    this problem is related to the following location:
    at gov.ojp.it.jxdm.fips_5_2._1.USStateCodeType
    at protected gov.ojp.it.jxdm.fips_5_2._1.USStateCodeType gov.ojp
    .it.jxdm._3_0_2.proxy.fips_5_2._1.USStateCodeType.value
    at gov.ojp.it.jxdm._3_0_2.proxy.fips_5_2._1.USStateCodeType
    at protected java.util.List gov.ojp.it.jxdm._3_0.AddressType.loc
    ationStateCodeFips52Alpha
    at gov.ojp.it.jxdm._3_0.AddressType
    at protected java.util.List gov.ojp.it.jxdm._3_0.LocationType.lo
    cationAddress
    at gov.ojp.it.jxdm._3_0.LocationType
    at protected java.util.List gov.ojp.it.jxdm._3_0.OrganizationTyp
    e.organizationLocation
    at gov.ojp.it.jxdm._3_0.OrganizationType
    at protected java.util.List gov.ojp.it.jxdm._3_0.BookingType.boo
    kingAgency
    at gov.ojp.it.jxdm._3_0.BookingType
    at generated.CjsBookingType
    at public generated.CjsBookingType generated.ObjectFactory.creat
    eCjsBookingType()
    at generated.ObjectFactory
    Check this out
    Exception in thread "main" java.lang.NullPointerException
    at bpd.MakeNewItem.marshallItem(MakeNewItem.java:119)
    at bpd.MakeNewItem.persistItem(MakeNewItem.java:112)
    at bpd.MakeNewItem.<init>(MakeNewItem.java:31)
    at bpd.MakeNewItem.main(MakeNewItem.java:137)
    ********************End of error message ******************
    Thanks
    Sat
    Message was edited by:
    sat_p

    In Help > About > Properties:
    sqldeveloper.oci.available = true

  • Setting namespace prefix with JAXB

    I'm trying to build and use a JAXB application.
    1. Generate the Java source files by submitting the XML Schema with Namespace to the binding compiler.
    2. Compile the Java source code.
    3. Marshal the data to new XML documents(valid XML document).
    But namespace prefix of XML Schema doesn't equal namespace prefix of new XML document.
    The prefix of new XML Schema is "heo". But, the prefix of new XML document set as "ns1" at discretion.
    Is there any way to solve namespace prefix setting?
    Thank you for your help.

    Why is java the only one doing this?
    I know prefixes are arbitrary, but when groups/individuals design XML docs, the instinct is to specify unique prefixes and to expect them coming in and out of other systems.
    When joe-developer emails an API to a buddy, she's got to include a lot more info every time, not just "cool:news" vs. "bad:news" but "cool:news" and "xmlns:cool=uri-foobar-smyte" and ...
    Sooo much simpler to handle the xml when its not only declared correctly, but you can expect specific prefixes. Less lines in writing tests, less lines in parsing out namespace declarations in order to expand them to uris and then map those to the random prefixes... blah.
    If you are concerned about dropping uri's then THAT should be the exception to the rule, then you write tests to lookup the namespace-uri.
    I suppose sun's xml stack is kind of a lesson to teach us developers to handle xml the orthodox way, using random prefixes, thanks for that.
    Classic: look at the amount of code it takes to parse xml in java. Then add on complexity (weirdness) in terms of random prefixes .... then compare that to .net/python/ruby/php/perl/c/c++ ... sun is all alone on this one and about 10x more verbose.
    At least honor the xml prefixes declared and developers round the world will appreciate the boost in productivity.
    Word!
    -jhn

  • JAXB - Java to XML namespaces question

    I want the following XML to be produced:
    <service
    xmlns="http://www.example.org/service"
    xmlns:db="http://www.example.org/db"
    >
    <firstElement>
       <db:title>Testing</db:title>
    </firstElement>
    </service>However, this is proving to be impossible in JAXB. If I put any namespace within any annotation within my java bean I get unwanted prefixes everywhere. If I use the XmlSchema at the package level and specify prefixes with @XmlNs that doesn't even show up in the XML.
    I feel I am almost at a loss?

    Well, i got it to work in JAXB 1, w/o xfire, schema-to-java. Marshall and unmarshall.
    But w/ xfire, it doesn't appear to be possible. Would probably require implementing it for them myself...

  • JAXB: using anonymous namespace (no prefix)

    I am using a namespace for my JAXB serialized object, so that the first part looks like that:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ns2:DataRecords xmlns:ns2="http://test.org/DataRecord/" StartProcessingTime="2010-05-20T12:34:37.123Z" ChargingDataVersion="1.0">
        <Item>
    ....As you can see JAXB uses the default Prefix "ns2" for assigning the DataRecords node to the namespace. Due to a special request I need
    to use an anonymous namespace with no prefix, something like this:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <DataRecords xmlns="http://test.org/DataRecord/" StartProcessingTime="2010-05-20T12:34:37.123Z" ChargingDataVersion="1.0">
        <Item>
    ....If I got the XML specifications right this should do the job as well, as long as only one namespace is used. Using JAXB I only recognized the
    possibility to change the prefix via a property of the marshaller and a custom prefix manager. But it seems impossible to abandon the prefix
    completely (returning null or an empty string in the custom prefix manager falls back to the default name prefixes)
    any idea?
    Edited by: Maurice_T on Jul 21, 2010 2:34 PM

    This seems wrong to me. I've filed Bug 2400119 to get this looked into by development.
    I'd expect any document with an appropriate qualified name to be found by your XPath expression, irrespective of whether syntactically one of the documents happened to use the default namespace syntax.

  • JAXB Unmarshalling and namespace

    Hi All ,
    Im using jaxb to marshall and unmarshall xml messages.Every thing seems to work fine expect for one
    small part ...... the namespace is removed form the xml .For example
    <RECORD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Record.xsd">
    becomes
    <RECORD>
    Any idea why this happens ?
    thanks
    Jim

    Hi Jimmy -
    Have you tried including this code at marshall time?
    marshaller.setProperty( Marshaller.JAXB_SCHEMA_LOCATION, "schema_path path_to_xsd.xsd");
    Good luck.
    cm

  • JAXB parser fails on multiple xsd files in same namespace

    I am having a problem with JAXB parsing a schema that imports 2 schema files from a similar namespace. Lets say we have 3 schema files A.xsd, B.xsd, and C.xsd as follows:
    A: <xsd:schema xmlns:xsd="<http://www.w3.org/2001/XMLSchema> targetNamespace="A" xmlns="A" xmlns:z="Z" xmlns:jxb="<http://java.sun.com/xml/ns/jaxb> jxb:version="1.0" elementFormDefault="qualified"> <xsd:import namespace="Z" schemaLocation="B.xsd"/> <xsd:import namespace="Z" schemaLocation="C.xsd"/> </xsd:schema>
    B: <xsd:schema xmlns:xsd="<http://www.w3.org/2001/XMLSchema> targetNamespace="Z" xmlns="Z" elementFormDefault="qualified"><xs:element name="BElement"></xs:element></xsd:schema>
    C: <xsd:schema xmlns:xsd="<http://www.w3.org/2001/XMLSchema> targetNamespace="Z" xmlns="Z" elementFormDefault="qualified"> <xs:element name="CElement"></xs:element></xsd:schema>
    The problem we have is that JAXB compiler fails during parsing and complains about an unresolved element (z:CElement) in the second schema (C.xsd) for the single namespace (Z). The complaint is reversed if we flip the order of the imported schema. The exact error is as follows: [ERROR] src-resolve: Cannot resolve the name 'z:CElement' to a(n) element declaration component.
    So the question is, how do we get JAXB to permit the import of 2 or more elements that are defined in individual schema files that belong to the same namespace.
    Thanks for your support,

    Greg,
    I believe that Xerces does not (and is not required to) parse anything other than the first <import> for a given namespace. I think what you are seeing is that Xerces is ignoring the second import for the "Z" namespace and therefore, the JAXB schema compiler is complaining that it can't resolve the element ref.
    Others on this thread may have already covered these work arounds, but here goes:
    1. you can disable JAXB's schema validation check by passing "-nv" to xjc or <arg value="-nv"/> to the ant task. This should allow XJC to get past the xerces behavior and generate proper code. In the current codebase, we are realying on some xerces internals to perform schema validation within XJC.
    2. you might also be able to create another schema file, say Z.xsd, that <includes> all of your schemas belonging to that namespace. Then you can bring all of them in with a single <import> of Z.xsd in A.xsd.
    I haven't tried it, but I think it'll work.
    Greg, FYI we have a very active developer community on Java.net - that's the best place to post these kinds of questions. We (the JAXB team) don't monitor the developer forums as closely. Check it out:
    http://jaxb.dev.java.net
    and join the "users" interest list:
    https://jaxb.dev.java.net/servlets/ProjectMailingListList
    Thanks,
    --Ryan Shoemaker, Sun Microsystems, Inc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • JAXB: how to turn off namespaces?

    I want to get rid of these silly little namespaces that JAXB is adding for the attributes in my XML output. Here is an example of what I am talking about:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <invocation xmlns="http://appriss.com/xsd/invocation.xsd" hashCode="1658591237">
      <method>
        <signature>public void com.appriss.core.hibernate.StoredProcedurePersister.insert(java.io.Serializable,java.lang.Object[],java.lang.Object,org.hibernate.engine.SessionImplementor) throws org.hibernate.HibernateException</signature>
        <args>
          <arg xmlns:ns1="http://appriss.com/xsd/invocation.xsd" ns1:type="com.appriss.demo.CompositePK">com.appriss.demo.CompositePK@a71d9209</arg>
          <arg xmlns:ns2="http://appriss.com/xsd/invocation.xsd" ns2:type="[Ljava.lang.Object;">[Ljava.lang.Object;@17d41d12</arg>
          <arg xmlns:ns3="http://appriss.com/xsd/invocation.xsd" ns3:type="com.appriss.demo.TestCompositePKEntity">com.appriss.demo.TestCompositePKEntity@897d5ad</arg>
          <arg xmlns:ns4="http://appriss.com/xsd/invocation.xsd" ns4:type="org.hibernate.impl.SessionImpl">SessionImpl(PersistenceContext[entityKeys=[EntityKey[com.appriss.demo.TestCompositePKEntity#component[key1,key2]{key1=1, key2=ninety-nine}]],collectionKeys=[]];ActionQueue[insertions=[EntityInsertAction[com.appriss.demo.TestCompositePKEntity#com.appriss.demo.CompositePK@a71d9209]] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])</arg>
        </args>
      </method>
    </invocation>This xmlns:ns1, ns2, ns3, ns4 garbage has got to go. How can I do this? Is there something in my XSD that may be causing this? If that is possible, I will post my XSD as well, but I'm hoping there is simply a way to turn this off at the JAXBContext or Marshaller level.

    Since you are desperately longing for some deeper
    meaning, I will give it.Good. Posting the real question is always better than posting a meaningless question.
    These XML messages will
    likely be parsed visually by a human, not a computer
    program. I am trying to reduce the line noise to make
    it more readable. Obviously I could pass it through a
    filter or an XSL transform, but I was hoping for a
    simpler solution within JAXB.+Making people read XML documents is extremely user-unfriendly in my opinion. I would agree with your idea of an XSL transform, especially if it produced text instead of XML. Just removing the namespace prefixes isn't going to make much difference.
    I see you have made upwards of 26k posts here. Are
    they all as useless and pretentious as this one?It made you admit your real question, didn't it? Your original few posts were useless (but not pretentious).

  • JAXB and Namespaces

    I would like to spit out an XML file using JAXB with namespace prefixes in place. I've tried but it seems like JAXB doesn't want to include the prefix "bo" in the xml file it generates. I would like JAXB generated xml file to look something like this:
    <task xmlns=http://www.bigb.com>
       <bo:metadata reference="abc" location="task1.xml" type="tracking" description="Track Inventory" />
    </task>
    Here is what my schema looks like:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bo="http://www.bigb.com" targetNamespace="http://www.bigb.com" elementFormDefault="qualified">
      <xs:element name="task" maxOccurs="1" minOccurs="1">
        <xs:sequence>
          <xs:element name="metadata" type="bo:MetaData" minOccurs="0" maxOccurs="1" />
        </xs:sequence>
      </xs:element>
      <xs:complexType name="MetaData">
        <xs:sequence>
          <xs:element name="metadata" minOccurs="0" maxOccurs="1" />
        </xs:sequence>
        <xs:attribute name="reference" type="xs:string" use="required" />
        <xs:attribute name="description" type="xs:string" use="required" />
        <xs:attribute name="type" type="xs:string" use="optional" />
        <xs:attribute name="location" type="xs:string" use="required" />
      </xs:complexType>
    </xs:schema>

    I've tried the NamespacePrefixMapper class and it doesn't work in my case. I only want one element to have namespace prefix and that is the metadata element.
    Can someone perhaps post a sample xml schema where it is possible to have just a single element to have a namespace prefix?
    thanks.

  • JAXB and attributes with namespace

    Hi,
    I'm using JAXB together with Apache Xindice. The problem comes when I use XPathQueryService, which returns my document + 2 attributes in the root tag:
    <myDoc xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/myCollection" src:key="00000002">
    </myDoc>
    I tried to model these attributes in my XML Schema as optional attributes:
    <xs:attribute name="col" type="xs:string" use="optional"/>
    <xs:attribute name="key" type="xs:string" use="optional"/>
    But JAXB doesn't like these attributes at runtime. Any Ideas?

    you must include the following attribute in the <schema> element
    xmlns:whatever ="http://xml.apache.org/xindice/Query"
    then define those attributes as
    <xs:attribute name="whatever:col" type="xs:string" use="optional"/>
    <xs:attribute name="whatever:key" type="xs:string" use="optional"/>
    i think it should work like that.
    now i ask a question.
    by any chance have you managed to unmarshal XML that isn't the root element? e.g. you have
    <A>
    <B>sdfsdf</B>
    </A>
    and just unmarshal B into a String directly, instead of unmarshalling A and then reading "sdfsdf " through getB().
    cheers.

Maybe you are looking for

  • Inspire 5500 - Speakers Cut Out?

    Hello... I'm using the excellent Inspire 5500 speakers, but occasionally one of the speakers, usually front center, just cuts out. If you pull the power and plug it back in (a simple off/on doesn't work) it'll come back. But sometimes when I turn the

  • Printing problem for picking list

    Hi friends, Whenever we print the picking list of material with batch number. the printing job will bring a extra page with basic form information . it's kind of wasting the paper since the extra page doen not contain any specific picking information

  • Parser in javacc

    I have to write a parser for a language called DISP. I am having trouble with javacc. deos anyone know about material more explanatory than what comes with the package?? any hints/suggestions are welcome

  • What are the function modules used in interactive ALV and parameters?

    what are the function modules used in interactive ALV and parameters?

  • Why the portrait photo icon isn´t in my ipad 2?

    hello! somebody can help me? i don't know why the portrait photo icon isn´t in my ipad 2?