this issue has been discussed on the list before., and i entered it in
jira. i have the same problem. so far there does not seem to exist a
real solution for it. 
the only possibility to add the desired attribute 'xsi:schemaLocation' 
is by adding get/set methods for it to your mapped classes.

i build a workaround to handle the cases 'xsi:schemaLocation' and
'xsi:noNamespaceSchemaLocation' by writing a class 'NSPInfo' which has
to get/set method pairs:

class NSPInfo {
  String schemaLocation = null;
  String noNamespaceSchemaLocation = null;
  public void setSchemaLocation(String sloc) {
    schemaLocation = sloc; 
  }
  public void setNoNamespaceSchemaLocation(String nnsloc) {
    noNamespaceSchemaLocation = nnsloc;
  }     
  public String getSchemaLocation() { 
    return schemaLocation; 
  }
  public String getNoNamespaceSchemaLocation() { 
    return noNamespaceSchemaLocation; 
  }
}

An instance of this class is referenced by the Class which is mapped to
the Root-Element. 

class RootClass {
  NSPInfo nspinfo; 
  public NSPInfo getNamespaceInformation() {
    return nspinfo;
  }
  public void setNamespaceInformation(NSPInfo nsp) {
    nspinfo = nsp;
  }
  ....
}

The binding is then something like:

<binding>
  <namespace uri="http://www.w3.org/2001/XMLSchema-instance";
prefix="xsi"/>

  <mapping name = "RootElement" class = "RootClass">

    <structure get-method="getNamespaceInformation"
set-method="setNamespaceInformation">
      <value style="attribute"
ns="http://www.w3.org/2001/XMLSchema-instance";
name="noNamespaceSchemaLocation"
get-method="getNoNamespaceSchemaLocation"
set-method="setNoNamespaceSchemaLocation"
usage="optional"/>
      <value style="attribute"
ns="http://www.w3.org/2001/XMLSchema-instance"; name="schemaLocation"
get-method="getSchemaLocation" set-method="setSchemaLocation"
usage="optional"/>
    </structure>
    
    .....
  </mapping>
  ....
</binding>


This is not very nice (because these things should not have anything to
do with the classes you map), but it should work... hopefully this cases
will soon be handled by JiBX itself.

regards,

tilman




On Mon, 2004-09-20 at 17:34, Bao Trang wrote:
> I want my root element to be defined as follows:
> 
> <Root xmlns="urn:us:gov:epa"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="urn:us:gov:epa
> C:\jibx\test\testSchema.xsd"></Root>
> 
> ---------
> 
> So far, the best I can do is to get the first ns defined: <Root
> xmlns="urn:us:gov:epa">.
> 
> How do I add the lines for the xml schema namespace and the xml schema location?
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
> Project Admins to receive an Apple iPod Mini FREE for your judgement on
> who ports your project to Linux PPC the best. Sponsored by IBM.
> Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
> _______________________________________________
> jibx-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
> 



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to