You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by T A <te...@yahoo.com> on 2004/06/16 21:00:19 UTC

Creating multiple namespaces

Hi,
 
I am a new user and I looked thru the archives for help but couldn't 
find any samples or examples. I did notice that there were similar 
types 
of issues raised but their explanations did not seem clear to my 
inexperienced eye. Any help on the following issue would be 
appreciated.
 
Using Xerces-C++ , I am trying to build and serialize an XML doc like 
so

 
<?xml version="1.0"?>
<bk:book xmlns:bk='urn:loc.gov:books'
         xmlns:isbn='urn:ISBN:0-395-36341-6'>
    <bk:title>Cheaper by the Dozen</bk:title>
    <isbn:number>1568491379</isbn:number>
</bk:book>
 
 
Using the createDocument method with arguments bk:book for name and 
urn:loc.gov:books as namespace. It does sucessfully create the first 
part 
of the doc :
 
<bk:book xmlns:bk='urn:loc.gov:books'
 
However, none of the the things I tried using to add the other 
namespace to the document at the root node, like  CreateAttributeNS or 
SetAttributeNS or setAttributeNodeNS seem to work. At best, I get stuff 
like 

<bk:book xmlns:bk='urn:loc.gov:books' isbn='urn:ISBN:0-395-36341-6'>
 
without the xmlns:isbn. When I try to declare a child element in the 
isbn name space, I get something like 
 
<isbn:number 
xmlns:isbn='urn:ISBN:0-395-36341-6'>1568491379</isbn:number>
 
which I am interpreting as that the isbn attribute in the bk:book 
element is not really working as the namespace declaration.
 
Any advice?
 
Ted



		
---------------------------------
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.