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

How do you use the xsd file?

P: n/a

I get "The attribute targetNamespace does not match the designated namespace
URI" and nothing else.

I have an xml file, that was pre-existing.
I have to validate against the schema provided, I downloaded it, and was
attempting to use (where FILENAME = the .xml and sSchema is the
path+filename.xsd):

public void ReadXml(string sSchema)
{

string sInfo = "";
XmlValidatingReader reader = null;
XmlSchemaCollection xsc = new XmlSchemaCollection();

try
{
xsc.Add(sSchema, new XmlTextReader(sSchema));
reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
reader.Schemas.Add(xsc);
reader.ValidationType = ValidationType.Schema;
reader.ValidationEventHandler += new
ValidationEventHandler(ValidationReaderHandler);

while (reader.Read())
{
sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
reader.Name + "\r\nValue: " + reader.Value;

Debug.WriteLine(sInfo);
Debug.WriteLine("----------");

}
Debug.WriteLine("Validation Finished.");

} // try
catch (Exception ex)
{

Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
ex.StackTrace);

} // catch (Exception ex)

} // public void ReadXml(string sSchema)
--
tym, Eskimo
Nov 12 '05 #1
Share this Question
Share on Google+
9 Replies

P: n/a
Hi Eskimo,

This sounds like either the xmlns for the root element of your instance
document doesn't match the targetNamespace of your schema or perhaps your
instance document isn't formed according to the rules of the schema (look at
<schema attributeFormDefault=? )
Try posting the first few lines of the instance document and the schema, if
you can.

Cheers
Phil

"Eskimo" wrote:

I get "The attribute targetNamespace does not match the designated namespace
URI" and nothing else.

I have an xml file, that was pre-existing.
I have to validate against the schema provided, I downloaded it, and was
attempting to use (where FILENAME = the .xml and sSchema is the
path+filename.xsd):

public void ReadXml(string sSchema)
{

string sInfo = "";
XmlValidatingReader reader = null;
XmlSchemaCollection xsc = new XmlSchemaCollection();

try
{
xsc.Add(sSchema, new XmlTextReader(sSchema));
reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
reader.Schemas.Add(xsc);
reader.ValidationType = ValidationType.Schema;
reader.ValidationEventHandler += new
ValidationEventHandler(ValidationReaderHandler);

while (reader.Read())
{
sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
reader.Name + "\r\nValue: " + reader.Value;

Debug.WriteLine(sInfo);
Debug.WriteLine("----------");

}
Debug.WriteLine("Validation Finished.");

} // try
catch (Exception ex)
{

Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
ex.StackTrace);

} // catch (Exception ex)

} // public void ReadXml(string sSchema)
--
tym, Eskimo

Nov 12 '05 #2

P: n/a
top of the schema from
http://www.adlnet.org/index.cfm?fuse...id=41&bc=false

<?xml version = "1.0"?>
<xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
elementFormDefault = "qualified"
version = "1.0">

I modified the top of my xml file:

<?xml version="1.0"?>
<!--Generated on 2-5-2004 11:47:41 AM-->
<manifest identifier="EK-1869" version="1.5"
xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
</metadata>

but I still get

The attribute targetNamespace does not match the designated namespace URI.

"Phil Hobgen" wrote:
Hi Eskimo,

This sounds like either the xmlns for the root element of your instance
document doesn't match the targetNamespace of your schema or perhaps your
instance document isn't formed according to the rules of the schema (look at
<schema attributeFormDefault=? )
Try posting the first few lines of the instance document and the schema, if
you can.

Cheers
Phil

"Eskimo" wrote:

I get "The attribute targetNamespace does not match the designated namespace
URI" and nothing else.

I have an xml file, that was pre-existing.
I have to validate against the schema provided, I downloaded it, and was
attempting to use (where FILENAME = the .xml and sSchema is the
path+filename.xsd):

public void ReadXml(string sSchema)
{

string sInfo = "";
XmlValidatingReader reader = null;
XmlSchemaCollection xsc = new XmlSchemaCollection();

try
{
xsc.Add(sSchema, new XmlTextReader(sSchema));
reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
reader.Schemas.Add(xsc);
reader.ValidationType = ValidationType.Schema;
reader.ValidationEventHandler += new
ValidationEventHandler(ValidationReaderHandler);

while (reader.Read())
{
sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
reader.Name + "\r\nValue: " + reader.Value;

Debug.WriteLine(sInfo);
Debug.WriteLine("----------");

}
Debug.WriteLine("Validation Finished.");

} // try
catch (Exception ex)
{

Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
ex.StackTrace);

} // catch (Exception ex)

} // public void ReadXml(string sSchema)
--
tym, Eskimo

Nov 12 '05 #3

P: n/a
The schema doesn't have a manifest element defined within it. I guess that
the validating parser is loading the whole element and then looking for a
definition of "an identifier attribute within a manifest element" - when it
can't find it then you get your error message (thats just my guess - someone
else may correct me).

Is there perhaps another schema that imports or includes the one you are
using and defines the manifest element? If so then that would be the schema
to add to the XmlSchemaCollection. The include or import element would have a
schemaLocation attribute that would point to the schema you are currently
using.

Or perhaps you should be using an entirely separate schema that happens to
be in the same targetNamespace?
"Eskimo" wrote:
top of the schema from
http://www.adlnet.org/index.cfm?fuse...id=41&bc=false

<?xml version = "1.0"?>
<xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
elementFormDefault = "qualified"
version = "1.0">

I modified the top of my xml file:

<?xml version="1.0"?>
<!--Generated on 2-5-2004 11:47:41 AM-->
<manifest identifier="EK-1869" version="1.5"
xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
</metadata>

but I still get

The attribute targetNamespace does not match the designated namespace URI.

"Phil Hobgen" wrote:
Hi Eskimo,

This sounds like either the xmlns for the root element of your instance
document doesn't match the targetNamespace of your schema or perhaps your
instance document isn't formed according to the rules of the schema (look at
<schema attributeFormDefault=? )
Try posting the first few lines of the instance document and the schema, if
you can.

Cheers
Phil

"Eskimo" wrote:

I get "The attribute targetNamespace does not match the designated namespace
URI" and nothing else.

I have an xml file, that was pre-existing.
I have to validate against the schema provided, I downloaded it, and was
attempting to use (where FILENAME = the .xml and sSchema is the
path+filename.xsd):

public void ReadXml(string sSchema)
{

string sInfo = "";
XmlValidatingReader reader = null;
XmlSchemaCollection xsc = new XmlSchemaCollection();

try
{
xsc.Add(sSchema, new XmlTextReader(sSchema));
reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
reader.Schemas.Add(xsc);
reader.ValidationType = ValidationType.Schema;
reader.ValidationEventHandler += new
ValidationEventHandler(ValidationReaderHandler);

while (reader.Read())
{
sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
reader.Name + "\r\nValue: " + reader.Value;

Debug.WriteLine(sInfo);
Debug.WriteLine("----------");

}
Debug.WriteLine("Validation Finished.");

} // try
catch (Exception ex)
{

Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
ex.StackTrace);

} // catch (Exception ex)

} // public void ReadXml(string sSchema)
--
tym, Eskimo

Nov 12 '05 #4

P: n/a
I have no clue if there's an link in the schema to include another schema...

I inherited 400 +/- xml files and the xsd's give me this error. It should
be simple...

"Phil Hobgen" wrote:
The schema doesn't have a manifest element defined within it. I guess that
the validating parser is loading the whole element and then looking for a
definition of "an identifier attribute within a manifest element" - when it
can't find it then you get your error message (thats just my guess - someone
else may correct me).

Is there perhaps another schema that imports or includes the one you are
using and defines the manifest element? If so then that would be the schema
to add to the XmlSchemaCollection. The include or import element would have a
schemaLocation attribute that would point to the schema you are currently
using.

Or perhaps you should be using an entirely separate schema that happens to
be in the same targetNamespace?
"Eskimo" wrote:
top of the schema from
http://www.adlnet.org/index.cfm?fuse...id=41&bc=false

<?xml version = "1.0"?>
<xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
elementFormDefault = "qualified"
version = "1.0">

I modified the top of my xml file:

<?xml version="1.0"?>
<!--Generated on 2-5-2004 11:47:41 AM-->
<manifest identifier="EK-1869" version="1.5"
xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
</metadata>

but I still get

The attribute targetNamespace does not match the designated namespace URI.

"Phil Hobgen" wrote:
Hi Eskimo,

This sounds like either the xmlns for the root element of your instance
document doesn't match the targetNamespace of your schema or perhaps your
instance document isn't formed according to the rules of the schema (look at
<schema attributeFormDefault=? )
Try posting the first few lines of the instance document and the schema, if
you can.

Cheers
Phil

"Eskimo" wrote:

>
> I get "The attribute targetNamespace does not match the designated namespace
> URI" and nothing else.
>
> I have an xml file, that was pre-existing.
> I have to validate against the schema provided, I downloaded it, and was
> attempting to use (where FILENAME = the .xml and sSchema is the
> path+filename.xsd):
>
> public void ReadXml(string sSchema)
> {
>
> string sInfo = "";
> XmlValidatingReader reader = null;
> XmlSchemaCollection xsc = new XmlSchemaCollection();
>
> try
> {
> xsc.Add(sSchema, new XmlTextReader(sSchema));
> reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
> reader.Schemas.Add(xsc);
> reader.ValidationType = ValidationType.Schema;
> reader.ValidationEventHandler += new
> ValidationEventHandler(ValidationReaderHandler);
>
> while (reader.Read())
> {
> sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
> reader.Name + "\r\nValue: " + reader.Value;
>
> Debug.WriteLine(sInfo);
> Debug.WriteLine("----------");
>
> }
> Debug.WriteLine("Validation Finished.");
>
> } // try
> catch (Exception ex)
> {
>
> Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
> ex.StackTrace);
>
> } // catch (Exception ex)
>
> } // public void ReadXml(string sSchema)
>
>
> --
> tym, Eskimo

Nov 12 '05 #5

P: n/a
I certainly empathise with you. Some of these large sets of schemas seem to
be written without any real consideration of how they will be used. But then
again the authors probably believe that they bend over backwards to
accommodate the developers.

In reality it should be fairly simple, here is how I think of it (there are
probably far better explanations available):

For any one message that you need to validate, there will be a single schema
that defines the starting point for that message. The starting point is the
root element.

If your root element is <manifest> then somewhere you should have a schema
with an element that starts something like:
<xs:element name="manifest"
This is the schema you need to load into the XmlSchemaCollection. This
schema will have a targetNamespace (a uri). This is the uri that should be
used in the "xmlns" attribute of your root element.

The schema may "import" and/or "include" other schemas, and from the number
of xsd files you have I would think these features are being used. Once you
have your starting point you can look up references on "import" and "include"
and their usage should start to make some sense.

There is a very good reference/tutorial site for all things xml at
http://www.zvon.org
"Eskimo" wrote:
I have no clue if there's an link in the schema to include another schema...

I inherited 400 +/- xml files and the xsd's give me this error. It should
be simple...

"Phil Hobgen" wrote:
The schema doesn't have a manifest element defined within it. I guess that
the validating parser is loading the whole element and then looking for a
definition of "an identifier attribute within a manifest element" - when it
can't find it then you get your error message (thats just my guess - someone
else may correct me).

Is there perhaps another schema that imports or includes the one you are
using and defines the manifest element? If so then that would be the schema
to add to the XmlSchemaCollection. The include or import element would have a
schemaLocation attribute that would point to the schema you are currently
using.

Or perhaps you should be using an entirely separate schema that happens to
be in the same targetNamespace?
"Eskimo" wrote:
top of the schema from
http://www.adlnet.org/index.cfm?fuse...id=41&bc=false

<?xml version = "1.0"?>
<xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
elementFormDefault = "qualified"
version = "1.0">

I modified the top of my xml file:

<?xml version="1.0"?>
<!--Generated on 2-5-2004 11:47:41 AM-->
<manifest identifier="EK-1869" version="1.5"
xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
</metadata>

but I still get

The attribute targetNamespace does not match the designated namespace URI.

"Phil Hobgen" wrote:

> Hi Eskimo,
>
> This sounds like either the xmlns for the root element of your instance
> document doesn't match the targetNamespace of your schema or perhaps your
> instance document isn't formed according to the rules of the schema (look at
> <schema attributeFormDefault=? )
> Try posting the first few lines of the instance document and the schema, if
> you can.
>
> Cheers
> Phil
>
> "Eskimo" wrote:
>
> >
> > I get "The attribute targetNamespace does not match the designated namespace
> > URI" and nothing else.
> >
> > I have an xml file, that was pre-existing.
> > I have to validate against the schema provided, I downloaded it, and was
> > attempting to use (where FILENAME = the .xml and sSchema is the
> > path+filename.xsd):
> >
> > public void ReadXml(string sSchema)
> > {
> >
> > string sInfo = "";
> > XmlValidatingReader reader = null;
> > XmlSchemaCollection xsc = new XmlSchemaCollection();
> >
> > try
> > {
> > xsc.Add(sSchema, new XmlTextReader(sSchema));
> > reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
> > reader.Schemas.Add(xsc);
> > reader.ValidationType = ValidationType.Schema;
> > reader.ValidationEventHandler += new
> > ValidationEventHandler(ValidationReaderHandler);
> >
> > while (reader.Read())
> > {
> > sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
> > reader.Name + "\r\nValue: " + reader.Value;
> >
> > Debug.WriteLine(sInfo);
> > Debug.WriteLine("----------");
> >
> > }
> > Debug.WriteLine("Validation Finished.");
> >
> > } // try
> > catch (Exception ex)
> > {
> >
> > Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
> > ex.StackTrace);
> >
> > } // catch (Exception ex)
> >
> > } // public void ReadXml(string sSchema)
> >
> >
> > --
> > tym, Eskimo

Nov 12 '05 #6

P: n/a
I certainly empathise with you. Some of these large sets of schemas seem to
be written without any real consideration of how they will be used. But then
again the authors probably believe that they bend over backwards to
accommodate the developers.

In reality it should be fairly simple, here is how I think of it (there are
probably far better explanations available):

"For any one message that you need to validate, there will be a single
schema that defines the starting point for that message. The starting point
is the root element."

If your root element is <manifest> then somewhere you should have a schema
with an element that starts something like:
<xs:element name="manifest"
This is the schema you need to load into the XmlSchemaCollection. This
schema will have a targetNamespace (a uri). This is the uri that should be
used in the "xmlns" attribute of your root element.

The schema may "import" and/or "include" other schemas, and from the number
of xsd files you have I would think these features are being used. Once you
have your starting point you can look up references on "import" and "include"
and their usage should start to make some sense.

There is a very good reference/tutorial site for all things xml at
http://www.zvon.org


"Eskimo" wrote:
I have no clue if there's an link in the schema to include another schema...

I inherited 400 +/- xml files and the xsd's give me this error. It should
be simple...

"Phil Hobgen" wrote:
The schema doesn't have a manifest element defined within it. I guess that
the validating parser is loading the whole element and then looking for a
definition of "an identifier attribute within a manifest element" - when it
can't find it then you get your error message (thats just my guess - someone
else may correct me).

Is there perhaps another schema that imports or includes the one you are
using and defines the manifest element? If so then that would be the schema
to add to the XmlSchemaCollection. The include or import element would have a
schemaLocation attribute that would point to the schema you are currently
using.

Or perhaps you should be using an entirely separate schema that happens to
be in the same targetNamespace?
"Eskimo" wrote:
top of the schema from
http://www.adlnet.org/index.cfm?fuse...id=41&bc=false

<?xml version = "1.0"?>
<xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
elementFormDefault = "qualified"
version = "1.0">

I modified the top of my xml file:

<?xml version="1.0"?>
<!--Generated on 2-5-2004 11:47:41 AM-->
<manifest identifier="EK-1869" version="1.5"
xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
</metadata>

but I still get

The attribute targetNamespace does not match the designated namespace URI.

"Phil Hobgen" wrote:

> Hi Eskimo,
>
> This sounds like either the xmlns for the root element of your instance
> document doesn't match the targetNamespace of your schema or perhaps your
> instance document isn't formed according to the rules of the schema (look at
> <schema attributeFormDefault=? )
> Try posting the first few lines of the instance document and the schema, if
> you can.
>
> Cheers
> Phil
>
> "Eskimo" wrote:
>
> >
> > I get "The attribute targetNamespace does not match the designated namespace
> > URI" and nothing else.
> >
> > I have an xml file, that was pre-existing.
> > I have to validate against the schema provided, I downloaded it, and was
> > attempting to use (where FILENAME = the .xml and sSchema is the
> > path+filename.xsd):
> >
> > public void ReadXml(string sSchema)
> > {
> >
> > string sInfo = "";
> > XmlValidatingReader reader = null;
> > XmlSchemaCollection xsc = new XmlSchemaCollection();
> >
> > try
> > {
> > xsc.Add(sSchema, new XmlTextReader(sSchema));
> > reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
> > reader.Schemas.Add(xsc);
> > reader.ValidationType = ValidationType.Schema;
> > reader.ValidationEventHandler += new
> > ValidationEventHandler(ValidationReaderHandler);
> >
> > while (reader.Read())
> > {
> > sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
> > reader.Name + "\r\nValue: " + reader.Value;
> >
> > Debug.WriteLine(sInfo);
> > Debug.WriteLine("----------");
> >
> > }
> > Debug.WriteLine("Validation Finished.");
> >
> > } // try
> > catch (Exception ex)
> > {
> >
> > Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
> > ex.StackTrace);
> >
> > } // catch (Exception ex)
> >
> > } // public void ReadXml(string sSchema)
> >
> >
> > --
> > tym, Eskimo

Nov 12 '05 #7

P: n/a
I cannot find anything about TargetNameSpace vs. URI

Why is it such a cryptic methodology when it's only a link-list struct in a
text file?

and why can't there be an solid example?! I used the quick starts and
followed booksSchema.xml and schema.xsd and the code works.
When I send my xml and the xsd I inherited I start getting these errors.

The attribute targetNamespace does not match the designated namespace URI.

where do i begin to fix the friggin problem is the frustrating part

"Phil Hobgen" wrote:
I certainly empathise with you. Some of these large sets of schemas seem to
be written without any real consideration of how they will be used. But then
again the authors probably believe that they bend over backwards to
accommodate the developers.

In reality it should be fairly simple, here is how I think of it (there are
probably far better explanations available):

"For any one message that you need to validate, there will be a single
schema that defines the starting point for that message. The starting point
is the root element."

If your root element is <manifest> then somewhere you should have a schema
with an element that starts something like:
<xs:element name="manifest"
This is the schema you need to load into the XmlSchemaCollection. This
schema will have a targetNamespace (a uri). This is the uri that should be
used in the "xmlns" attribute of your root element.

The schema may "import" and/or "include" other schemas, and from the number
of xsd files you have I would think these features are being used. Once you
have your starting point you can look up references on "import" and "include"
and their usage should start to make some sense.

There is a very good reference/tutorial site for all things xml at
http://www.zvon.org


"Eskimo" wrote:
I have no clue if there's an link in the schema to include another schema...

I inherited 400 +/- xml files and the xsd's give me this error. It should
be simple...

"Phil Hobgen" wrote:
The schema doesn't have a manifest element defined within it. I guess that
the validating parser is loading the whole element and then looking for a
definition of "an identifier attribute within a manifest element" - when it
can't find it then you get your error message (thats just my guess - someone
else may correct me).

Is there perhaps another schema that imports or includes the one you are
using and defines the manifest element? If so then that would be the schema
to add to the XmlSchemaCollection. The include or import element would have a
schemaLocation attribute that would point to the schema you are currently
using.

Or perhaps you should be using an entirely separate schema that happens to
be in the same targetNamespace?
"Eskimo" wrote:

> top of the schema from
> http://www.adlnet.org/index.cfm?fuse...id=41&bc=false
>
> <?xml version = "1.0"?>
> <xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
> xmlns:xs = "http://www.w3.org/2001/XMLSchema"
> xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
> elementFormDefault = "qualified"
> version = "1.0">
>
> I modified the top of my xml file:
>
> <?xml version="1.0"?>
> <!--Generated on 2-5-2004 11:47:41 AM-->
> <manifest identifier="EK-1869" version="1.5"
> xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
> <metadata>
> <schema>ADL SCORM</schema>
> <schemaversion>1.2</schemaversion>
> </metadata>
>
> but I still get
>
> The attribute targetNamespace does not match the designated namespace URI.
>
> "Phil Hobgen" wrote:
>
> > Hi Eskimo,
> >
> > This sounds like either the xmlns for the root element of your instance
> > document doesn't match the targetNamespace of your schema or perhaps your
> > instance document isn't formed according to the rules of the schema (look at
> > <schema attributeFormDefault=? )
> > Try posting the first few lines of the instance document and the schema, if
> > you can.
> >
> > Cheers
> > Phil
> >
> > "Eskimo" wrote:
> >
> > >
> > > I get "The attribute targetNamespace does not match the designated namespace
> > > URI" and nothing else.
> > >
> > > I have an xml file, that was pre-existing.
> > > I have to validate against the schema provided, I downloaded it, and was
> > > attempting to use (where FILENAME = the .xml and sSchema is the
> > > path+filename.xsd):
> > >
> > > public void ReadXml(string sSchema)
> > > {
> > >
> > > string sInfo = "";
> > > XmlValidatingReader reader = null;
> > > XmlSchemaCollection xsc = new XmlSchemaCollection();
> > >
> > > try
> > > {
> > > xsc.Add(sSchema, new XmlTextReader(sSchema));
> > > reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
> > > reader.Schemas.Add(xsc);
> > > reader.ValidationType = ValidationType.Schema;
> > > reader.ValidationEventHandler += new
> > > ValidationEventHandler(ValidationReaderHandler);
> > >
> > > while (reader.Read())
> > > {
> > > sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
> > > reader.Name + "\r\nValue: " + reader.Value;
> > >
> > > Debug.WriteLine(sInfo);
> > > Debug.WriteLine("----------");
> > >
> > > }
> > > Debug.WriteLine("Validation Finished.");
> > >
> > > } // try
> > > catch (Exception ex)
> > > {
> > >
> > > Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
> > > ex.StackTrace);
> > >
> > > } // catch (Exception ex)
> > >
> > > } // public void ReadXml(string sSchema)
> > >
> > >
> > > --
> > > tym, Eskimo

Nov 12 '05 #8

P: n/a
Had another look at the code:
xsc.Add(sSchema, new XmlTextReader(sSchema));

The first parameter (which you are passing sSchema into), should be the
namespace i.e. "http://www.adlnet.org/xsd/adlcp_v1p3" or null (in which case
the schemas' targetNamespace will be used, amounting to the same thing).

That should change the error message you are getting. But the schema you
linked to doesn't contain the elements within your document, which should
still cause an error, I think.
"Eskimo" wrote:
I cannot find anything about TargetNameSpace vs. URI

Why is it such a cryptic methodology when it's only a link-list struct in a
text file?

and why can't there be an solid example?! I used the quick starts and
followed booksSchema.xml and schema.xsd and the code works.
When I send my xml and the xsd I inherited I start getting these errors.

The attribute targetNamespace does not match the designated namespace URI.

where do i begin to fix the friggin problem is the frustrating part

"Phil Hobgen" wrote:
I certainly empathise with you. Some of these large sets of schemas seem to
be written without any real consideration of how they will be used. But then
again the authors probably believe that they bend over backwards to
accommodate the developers.

In reality it should be fairly simple, here is how I think of it (there are
probably far better explanations available):

"For any one message that you need to validate, there will be a single
schema that defines the starting point for that message. The starting point
is the root element."

If your root element is <manifest> then somewhere you should have a schema
with an element that starts something like:
<xs:element name="manifest"
This is the schema you need to load into the XmlSchemaCollection. This
schema will have a targetNamespace (a uri). This is the uri that should be
used in the "xmlns" attribute of your root element.

The schema may "import" and/or "include" other schemas, and from the number
of xsd files you have I would think these features are being used. Once you
have your starting point you can look up references on "import" and "include"
and their usage should start to make some sense.

There is a very good reference/tutorial site for all things xml at
http://www.zvon.org


"Eskimo" wrote:
I have no clue if there's an link in the schema to include another schema...

I inherited 400 +/- xml files and the xsd's give me this error. It should
be simple...

"Phil Hobgen" wrote:

> The schema doesn't have a manifest element defined within it. I guess that
> the validating parser is loading the whole element and then looking for a
> definition of "an identifier attribute within a manifest element" - when it
> can't find it then you get your error message (thats just my guess - someone
> else may correct me).
>
> Is there perhaps another schema that imports or includes the one you are
> using and defines the manifest element? If so then that would be the schema
> to add to the XmlSchemaCollection. The include or import element would have a
> schemaLocation attribute that would point to the schema you are currently
> using.
>
> Or perhaps you should be using an entirely separate schema that happens to
> be in the same targetNamespace?
>
>
> "Eskimo" wrote:
>
> > top of the schema from
> > http://www.adlnet.org/index.cfm?fuse...id=41&bc=false
> >
> > <?xml version = "1.0"?>
> > <xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
> > xmlns:xs = "http://www.w3.org/2001/XMLSchema"
> > xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
> > elementFormDefault = "qualified"
> > version = "1.0">
> >
> > I modified the top of my xml file:
> >
> > <?xml version="1.0"?>
> > <!--Generated on 2-5-2004 11:47:41 AM-->
> > <manifest identifier="EK-1869" version="1.5"
> > xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
> > <metadata>
> > <schema>ADL SCORM</schema>
> > <schemaversion>1.2</schemaversion>
> > </metadata>
> >
> > but I still get
> >
> > The attribute targetNamespace does not match the designated namespace URI.
> >
> > "Phil Hobgen" wrote:
> >
> > > Hi Eskimo,
> > >
> > > This sounds like either the xmlns for the root element of your instance
> > > document doesn't match the targetNamespace of your schema or perhaps your
> > > instance document isn't formed according to the rules of the schema (look at
> > > <schema attributeFormDefault=? )
> > > Try posting the first few lines of the instance document and the schema, if
> > > you can.
> > >
> > > Cheers
> > > Phil
> > >
> > > "Eskimo" wrote:
> > >
> > > >
> > > > I get "The attribute targetNamespace does not match the designated namespace
> > > > URI" and nothing else.
> > > >
> > > > I have an xml file, that was pre-existing.
> > > > I have to validate against the schema provided, I downloaded it, and was
> > > > attempting to use (where FILENAME = the .xml and sSchema is the
> > > > path+filename.xsd):
> > > >
> > > > public void ReadXml(string sSchema)
> > > > {
> > > >
> > > > string sInfo = "";
> > > > XmlValidatingReader reader = null;
> > > > XmlSchemaCollection xsc = new XmlSchemaCollection();
> > > >
> > > > try
> > > > {
> > > > xsc.Add(sSchema, new XmlTextReader(sSchema));
> > > > reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
> > > > reader.Schemas.Add(xsc);
> > > > reader.ValidationType = ValidationType.Schema;
> > > > reader.ValidationEventHandler += new
> > > > ValidationEventHandler(ValidationReaderHandler);
> > > >
> > > > while (reader.Read())
> > > > {
> > > > sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
> > > > reader.Name + "\r\nValue: " + reader.Value;
> > > >
> > > > Debug.WriteLine(sInfo);
> > > > Debug.WriteLine("----------");
> > > >
> > > > }
> > > > Debug.WriteLine("Validation Finished.");
> > > >
> > > > } // try
> > > > catch (Exception ex)
> > > > {
> > > >
> > > > Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
> > > > ex.StackTrace);
> > > >
> > > > } // catch (Exception ex)
> > > >
> > > > } // public void ReadXml(string sSchema)
> > > >
> > > >
> > > > --
> > > > tym, Eskimo

Nov 12 '05 #9

P: n/a
I get:
The same table (metadata) cannot be the child table in two nested relations.
I used a dataset to inferschema from my xml file
and then asked it to write the schema out, but I only get so far...

This should be much easier to do than the way it's turning out. If you
throw the error then you should also be able to add the relationship
automatically as we're in the middle of a project that inherited 400 +/- xml
files and there is no schema available <grr />
"Phil Hobgen" wrote:
Had another look at the code:
xsc.Add(sSchema, new XmlTextReader(sSchema));

The first parameter (which you are passing sSchema into), should be the
namespace i.e. "http://www.adlnet.org/xsd/adlcp_v1p3" or null (in which case
the schemas' targetNamespace will be used, amounting to the same thing).

That should change the error message you are getting. But the schema you
linked to doesn't contain the elements within your document, which should
still cause an error, I think.
"Eskimo" wrote:
I cannot find anything about TargetNameSpace vs. URI

Why is it such a cryptic methodology when it's only a link-list struct in a
text file?

and why can't there be an solid example?! I used the quick starts and
followed booksSchema.xml and schema.xsd and the code works.
When I send my xml and the xsd I inherited I start getting these errors.

The attribute targetNamespace does not match the designated namespace URI.

where do i begin to fix the friggin problem is the frustrating part

"Phil Hobgen" wrote:
I certainly empathise with you. Some of these large sets of schemas seem to
be written without any real consideration of how they will be used. But then
again the authors probably believe that they bend over backwards to
accommodate the developers.

In reality it should be fairly simple, here is how I think of it (there are
probably far better explanations available):

"For any one message that you need to validate, there will be a single
schema that defines the starting point for that message. The starting point
is the root element."

If your root element is <manifest> then somewhere you should have a schema
with an element that starts something like:
<xs:element name="manifest"
This is the schema you need to load into the XmlSchemaCollection. This
schema will have a targetNamespace (a uri). This is the uri that should be
used in the "xmlns" attribute of your root element.

The schema may "import" and/or "include" other schemas, and from the number
of xsd files you have I would think these features are being used. Once you
have your starting point you can look up references on "import" and "include"
and their usage should start to make some sense.

There is a very good reference/tutorial site for all things xml at
http://www.zvon.org


"Eskimo" wrote:

> I have no clue if there's an link in the schema to include another schema...
>
> I inherited 400 +/- xml files and the xsd's give me this error. It should
> be simple...
>
> "Phil Hobgen" wrote:
>
> > The schema doesn't have a manifest element defined within it. I guess that
> > the validating parser is loading the whole element and then looking for a
> > definition of "an identifier attribute within a manifest element" - when it
> > can't find it then you get your error message (thats just my guess - someone
> > else may correct me).
> >
> > Is there perhaps another schema that imports or includes the one you are
> > using and defines the manifest element? If so then that would be the schema
> > to add to the XmlSchemaCollection. The include or import element would have a
> > schemaLocation attribute that would point to the schema you are currently
> > using.
> >
> > Or perhaps you should be using an entirely separate schema that happens to
> > be in the same targetNamespace?
> >
> >
> > "Eskimo" wrote:
> >
> > > top of the schema from
> > > http://www.adlnet.org/index.cfm?fuse...id=41&bc=false
> > >
> > > <?xml version = "1.0"?>
> > > <xs:schema targetNamespace = "http://www.adlnet.org/xsd/adlcp_v1p3"
> > > xmlns:xs = "http://www.w3.org/2001/XMLSchema"
> > > xmlns = "http://www.adlnet.org/xsd/adlcp_v1p3"
> > > elementFormDefault = "qualified"
> > > version = "1.0">
> > >
> > > I modified the top of my xml file:
> > >
> > > <?xml version="1.0"?>
> > > <!--Generated on 2-5-2004 11:47:41 AM-->
> > > <manifest identifier="EK-1869" version="1.5"
> > > xmlns="http://www.adlnet.org/xsd/adlcp_v1p3">
> > > <metadata>
> > > <schema>ADL SCORM</schema>
> > > <schemaversion>1.2</schemaversion>
> > > </metadata>
> > >
> > > but I still get
> > >
> > > The attribute targetNamespace does not match the designated namespace URI.
> > >
> > > "Phil Hobgen" wrote:
> > >
> > > > Hi Eskimo,
> > > >
> > > > This sounds like either the xmlns for the root element of your instance
> > > > document doesn't match the targetNamespace of your schema or perhaps your
> > > > instance document isn't formed according to the rules of the schema (look at
> > > > <schema attributeFormDefault=? )
> > > > Try posting the first few lines of the instance document and the schema, if
> > > > you can.
> > > >
> > > > Cheers
> > > > Phil
> > > >
> > > > "Eskimo" wrote:
> > > >
> > > > >
> > > > > I get "The attribute targetNamespace does not match the designated namespace
> > > > > URI" and nothing else.
> > > > >
> > > > > I have an xml file, that was pre-existing.
> > > > > I have to validate against the schema provided, I downloaded it, and was
> > > > > attempting to use (where FILENAME = the .xml and sSchema is the
> > > > > path+filename.xsd):
> > > > >
> > > > > public void ReadXml(string sSchema)
> > > > > {
> > > > >
> > > > > string sInfo = "";
> > > > > XmlValidatingReader reader = null;
> > > > > XmlSchemaCollection xsc = new XmlSchemaCollection();
> > > > >
> > > > > try
> > > > > {
> > > > > xsc.Add(sSchema, new XmlTextReader(sSchema));
> > > > > reader = new XmlValidatingReader(new XmlTextReader(FILENAME));
> > > > > reader.Schemas.Add(xsc);
> > > > > reader.ValidationType = ValidationType.Schema;
> > > > > reader.ValidationEventHandler += new
> > > > > ValidationEventHandler(ValidationReaderHandler);
> > > > >
> > > > > while (reader.Read())
> > > > > {
> > > > > sInfo = "NodeType: " + reader.NodeType + "\r\nName: " +
> > > > > reader.Name + "\r\nValue: " + reader.Value;
> > > > >
> > > > > Debug.WriteLine(sInfo);
> > > > > Debug.WriteLine("----------");
> > > > >
> > > > > }
> > > > > Debug.WriteLine("Validation Finished.");
> > > > >
> > > > > } // try
> > > > > catch (Exception ex)
> > > > > {
> > > > >
> > > > > Debug.WriteLine(ex.Message + "\r\n" + ex.Source + "\r\n" +
> > > > > ex.StackTrace);
> > > > >
> > > > > } // catch (Exception ex)
> > > > >
> > > > > } // public void ReadXml(string sSchema)
> > > > >
> > > > >
> > > > > --
> > > > > tym, Eskimo

Nov 12 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.