(XmlSchema->targetNamespace) error while writing xsd

M

Maansi Sanghi

Hello,

I am trying to write an xsd file using .NET System.Xml.Sxhema Class Library.

(1) I get an error while writitng if the XSD has a taregetnamespace.
(II) for any xsd with no targetnamespace the program works fine.

I want to create an xsd with the following namespaces

<xsd:schema targetNamespace"http://www.homedepot.com/HD"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:hd="http://www.homedepot.com/HD">

Following is the code

XmlSchema* schema = new XmlSchema();
XmlNamespaceManager* nsmgr = new XmlNamespaceManager(new NameTable());
nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
nsmgr->AddNamespace("hd", "http://www.homedepot.com/HD");
schema->TaregetNamspace = "http://www.homedepot.com/HD";
System::IO::FileStream* fs = new FileStream("XSDWrite.xsd",
FileMode::OpenOrCreate);
schema->Write(fs, nsmgr); ///UNKNOWN EXCEPTION WHILE writing

(111) Is there a limitation that the targetnamespace cannot be in the
namespace manager???
I am unable to find out the problem here

Thanks,
Maansi
 
T

Tomas Restrepo \(MVP\)

Maansi,

must be something else in your code. I just tried it out (fixing the syntax
errors) and it worked just fine, no exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top