Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] create namespace

Ashar Siddiqui

2005-11-11

Replies:

I am trying to create like this

<?xml version="1.0" encoding="UTF-8" ?>

<BackgroundCheck xmlns=" http://www.hirbc.com/xml/Screening/BackgroundCheck-2_0"    

xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance

xsi: schemaLocation="http://www.hirbc.com/xml/Screening/BackgroundCheck-2_0

http://www.hirbc.com/xml/Screening/Screenings-2_0/Schemas/BackgroundCheck-2_0.xsd" userId="900JHY" password="WF040503" account="900JHY">

<BackgroundSearchPackage >…

 

I am using JDOM 1.0.   

Here is my code.

 

public Element root = new Element("BackgroundCheck" , " http://www.hirbc.com/xml/Screening/BackgroundCheck-2_0" );

Namespace xsi = null ;

                        Namespace schemaloc = null ;

                      xsi= Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance" );

                        root.addNamespaceDeclaration(xsi);

                        schemaloc = Namespace.getNamespace("schemaLocation" , "http://www.hirbc.com/xml/Screening/BackgroundCheck-2_0 http://www.hirbc.com/xml/Screening/Screenings-2_0/Schemas/BackgroundCheck-2_0.xsd ");

                        root.addNamespaceDeclaration(schemaloc);

                        root.setAttribute( "userId","900JHY" );

                        root.setAttribute( "password","WF040503" );

                        root.setAttribute( "account", "900JHY" );

 

this code giving me result like this

 

<?xml version="1.0" encoding="UTF-8" ?>

<BackgroundCheck xmlns=" http://www.hirbc.com/xml/Screening/BackgroundCheck-2_0"    

xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance

xmlns: schemaLocation="http://www.hirbc.com/xml/Screening/BackgroundCheck-2_0

http://www.hirbc.com/xml /Screening/Screenings-2_0/Schemas/BackgroundCheck-2_0.xsd" userId="900JHY" password="WF040503" account="900JHY">

<BackgroundSearchPackage   xmlns="">…

how to fix it special I want xsi:schemaLocation not xmlns:schemaLocation, and why  BackgroundSearchPackage has xmlns=""
thank you

--
Ashar Siddiqui
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.