You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Wei Zheng <db...@gmail.com> on 2011/05/06 20:04:42 UTC
How to add more attributes in DOMImplementation::createDocument
For example I need something like below:
<RootElem
xmlns="http://www.abc.com/XMLSchema/product"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://www.abc.com/XMLSchema/product.xsd"
xmlns:pr_attr="http://www.abc.com/XMLSchema/product" pro_attr:ver="1.0">
<CommonElem>
...
</CommonElem>
</RootElem>
It seems that I can only add the "qualified Name" (xmlns part). How about I
want to add xmlns:xs, xs:schemaLocation, and my customized attributes to the
root element?
Thanks in advance!
Wei
Re: How to add more attributes in DOMImplementation::createDocument
Posted by Wei Zheng <db...@gmail.com>.
Thanks Vitaly. It did work.
On Mon, May 23, 2011 at 12:43 AM, Vitaly Prapirny <ma...@mebius.net> wrote:
> Hi!
>
> You can try something like this:
>
> DOMElement* rootElem = doc->getDocumentElement();
>
> DOMAttr* attr = doc->createAttribute(X("xmlns:xsi"));
> attr->setValue(X("http://www.w3.org/2001/XMLSchema-instance"));
> rootElem->setAttributeNode(attr);
>
> Good luck!
> Vitaly
>
>
> Wei Zheng wrote:
>
>> For example I need something like below:
>>
>> <RootElem
>> xmlns="http://www.abc.com/XMLSchema/product"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
>> xs:schemaLocation="http://www.abc.com/XMLSchema/product.xsd"
>> xmlns:pr_attr="http://www.abc.com/XMLSchema/product" pro_attr:ver="1.0">
>> <CommonElem>
>> ...
>> </CommonElem>
>> </RootElem>
>>
>> It seems that I can only add the "qualified Name" (xmlns part). How about
>> I
>> want to add xmlns:xs, xs:schemaLocation, and my customized attributes to
>> the
>> root element?
>>
>> Thanks in advance!
>> Wei
>>
>>
>
Re: How to add more attributes in DOMImplementation::createDocument
Posted by Vitaly Prapirny <ma...@mebius.net>.
Hi!
You can try something like this:
DOMElement* rootElem = doc->getDocumentElement();
DOMAttr* attr = doc->createAttribute(X("xmlns:xsi"));
attr->setValue(X("http://www.w3.org/2001/XMLSchema-instance"));
rootElem->setAttributeNode(attr);
Good luck!
Vitaly
Wei Zheng wrote:
> For example I need something like below:
>
> <RootElem
> xmlns="http://www.abc.com/XMLSchema/product"
> xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
> xs:schemaLocation="http://www.abc.com/XMLSchema/product.xsd"
> xmlns:pr_attr="http://www.abc.com/XMLSchema/product" pro_attr:ver="1.0">
> <CommonElem>
> ...
> </CommonElem>
> </RootElem>
>
> It seems that I can only add the "qualified Name" (xmlns part). How about I
> want to add xmlns:xs, xs:schemaLocation, and my customized attributes to the
> root element?
>
> Thanks in advance!
> Wei
>