By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

problems with adding the targetnamespace with the xmlns component in my xsd file

P: n/a
Hi,

I am trying to add the targetNamespace with the xmlns to my xml schema
file, but I am getting the following

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.ciber.com/myfile" version="1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

The correct schema root is

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.ciber.com/myfile"
xmlns="http://www.ciber.com/myfile" version="1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

Here is my code sofar.

public void CreateSchemaRoot(string strNameSpace, bool
bElemFormDefault, bool bAttrForm, string strTargetNamespace)
{

if (strTargetNamespace.Length > 0)
{
schema.TargetNamespace = strTargetNamespace;
System.Xml.S
XmlSerializerNamespaces efilens = new XmlSerializerNamespaces();
efilens.Add("", strTargetNamespace);
schema.Namespaces= efilens;
The error is in this line. It will get overwritten by the last line in
the function. How do I add the targetNamespace xmlns next to the
targetNamespace?
}

if (bElemFormDefault)
schema.ElementFormDefault = XmlSchemaForm.Qualified;
else
schema.ElementFormDefault = XmlSchemaForm.Unqualified;
if (bAttrForm)
schema.AttributeFormDefault = XmlSchemaForm.Qualified;
else
schema.AttributeFormDefault = XmlSchemaForm.Unqualified;

schema.Version = "1.0";
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add(strNameSpace, schemaNS);
schema.Namespaces = ns;
}

Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.