You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Hasnain A. Mandviwala" <ma...@cc.gatech.edu> on 2001/11/20 12:08:10 UTC
Adding NameSpace Attribute to top Document element
Hi,
I've been trying to add a NameSpace attribute to a Document but
for some reason it's not working. Here is what I'm doing:
I have a template document like the following:
<?xml version="1.0"?>
<results
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="query_results
query_results.xsd">
</results>
For example, now I want to add a namespace to the above document to make
it look like this:
<?xml version="1.0"?>
<results
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:myrental="http://xmlape.cc.gatech.edu/myrental"
xsi:schemaLocation="query3_results
query3_results.xsd">
</results>
I'm not sure if what I'm doing is right but here goes:
// get the DOM tree built first
Document resultDoc = (Document) Utils.parseXMLDocument(RESULT_TEMPL);
// get the Root Document Element
Element resultDocElement = resultDoc.getDocumentElement();
try {
resultDocElement.setAttribute("xmlns:myrental",
"http://xmlape.cc.gatech.edu/myrental");
}
catch(Exception e) {
e.printStackTrace();
}
However, this is not giving me any results. The Document looks
just the same, as the original template document. Some tips, pointers
would be great! Thanks.
-Hasnain
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org