Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:40:58+00:00 2026-06-10T05:40:58+00:00

I’am using JIBX in order to map my XML data to Java objects. This

  • 0

I’am using JIBX in order to map my XML data to Java objects. This perfectly works when the XML is containing only one target namespace. Unfortunately, the requirements have changed and now I get XML data with two different namespaces inside.

Example:

<a:foo> 
  <b:bar>Simple Example</b:bar>
</a:foo>

My question is, how to write a xsd that yields two different target namespaces?

 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="namespace_of_a"
            xmlns:a="namespace_of_a"
            xmlns:b="namespace_of_b"
            elementFormDefault="qualified">

      <xs:element name="foo">
        <xs:complexType>
          <xs:sequence>

             <!-- this won't work, because b is part of a different namespace -->
             <xs:attribute type="xs:string" use="required" name="bar"/>

          </xs:sequence>
        </xs:complexType>
      </xs:element>

 </xs:schema>

I already tried:

 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="namespace_of_a"
            xmlns:a="namespace_of_a"
            xmlns:b="namespace_of_b"
            elementFormDefault="qualified">

      <xs:element name="foo">
        <xs:complexType>
          <xs:sequence>

             <!-- this won't work, because jibx is reporting that targetNamespace is an unknown attribute -->
             <xs:attribute targetNamespace="namespace_of_b" type="xs:string" use="required" name="bar"/>

          </xs:sequence>
        </xs:complexType>
      </xs:element>

 </xs:schema>

Please help. I’m not sure whether this is possible in general or not? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:40:59+00:00Added an answer on June 10, 2026 at 5:40 am

    Yes, it’s possible. It’s one of the core scenarios XSD was designed to handle.

    (1) Write separate schema documents for each namespace involved, with that namespace given as the targetNamespace of the xs:schema element.

    If your a:foo element can accept only a b:bar element as a child, then in the schema document for a you will want to import namespace b , so that the content model for a:foo can refer to element b:bar. For example, modify your sample schema document to include:

    <xs:import namespace="namespace_of_b"/>
    

    (Note: some people would add a schemaLocation hint here; I wouldn’t.)

    Then change the declaration of a:foo to read:

    <xs:element name="foo">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="b:bar"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    

    If a:foo can accept anything, then use an xs:any wildcard in its content model, and you don’t need to import namespace b (because you’re not referring to anything in it).

    In the schema document for namespace b define element bar in the normal way (or attribute bar — I think you must have changed your mind on how to present the example).

    (2) Write a simple top-level ‘driver’ schema document that imports the two namespace-specific schema documents you prepared in step 1. It’s on the xs:import statements here that I’d provide the schema location information.

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
      <xs:import namespace="namespace_of_a" schemaLocation="a.xsd"/>
      <xs:import namespace="namespace_of_b" schemaLocation="b.xsd"/>
    </xs:schema>
    

    Segregating information about physical location of schema documents into a single driver file complicates matters a bit in the short run, by requiring yet another schema document. But it avoids a number of nasty problems that arise when you want to change things just a little bit, later on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.