473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Validation Problem

I have a schema file PDDSch.xsd which validates the PDD.xml file. the
rootnodes are as shown below

PDD.xml
<PDD xmlns="http://tempuri.org/PDDSch.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >

PDDSch.xsd
<xs:schema id="PDD"
targetNamespace="http://tempuri.org/PDDSch.xsd"
xmlns="http://tempuri.org/PDDSch.xsd"
xmlns:mstns="http://tempuri.org/PDDSch.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

now with the above mentioned namespaces and other attributes the validation
works properly. But I'm not able to read the child nodes through
XPathNavigator and XPathNodeIterator.

If the above rootnodes changed as shown below.

PDD.xml
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

PDDSch.xsd
<xs:schema id="PDD"
xmlns:mstns="http://tempuri.org/PDDSch.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

With the above rootnode attributes theXPathNavigator and XPathNodeIterator
will read the child nodes. but the validation is not correct.

Could someone tell me What is the mistake I'm making here.

Thanks and regards,
Harry

Nov 12 '05 #1
6 1810
Could you share the code and the data that you are using. You should be able
to walk the child nodes in both cases.
"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
I have a schema file PDDSch.xsd which validates the PDD.xml file. the
rootnodes are as shown below

PDD.xml
<PDD xmlns="http://tempuri.org/PDDSch.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >
PDDSch.xsd
<xs:schema id="PDD"
targetNamespace="http://tempuri.org/PDDSch.xsd"
xmlns="http://tempuri.org/PDDSch.xsd"
xmlns:mstns="http://tempuri.org/PDDSch.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

now with the above mentioned namespaces and other attributes the validation works properly. But I'm not able to read the child nodes through
XPathNavigator and XPathNodeIterator.

If the above rootnodes changed as shown below.

PDD.xml
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

PDDSch.xsd
<xs:schema id="PDD"
xmlns:mstns="http://tempuri.org/PDDSch.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

With the above rootnode attributes theXPathNavigator and XPathNodeIterator
will read the child nodes. but the validation is not correct.

Could someone tell me What is the mistake I'm making here.

Thanks and regards,
Harry

Nov 12 '05 #2
This is the Code:

I have not assigned any namespaceManager or ParserContext for the rootNode

XmlDocument doc = new XmlDocument();
doc.Load("PDD.xml");
XmlNode rootNode = doc.DocumentElement;
XPathNavigator nav = rootNode.CreateNavigator();
XPathExpression exp = nav.Compile("//PD/*"); //PD is the child node of PDD
XPathNodeIterator it = (XPathNodeIterator) nav.Evaluate(exp);

while(iterator.MoveNext())
{

}

not entering the while loop itself.

Regards,
Harry

"Zafar Abbas" wrote:
Could you share the code and the data that you are using. You should be able
to walk the child nodes in both cases.
"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
I have a schema file PDDSch.xsd which validates the PDD.xml file. the
rootnodes are as shown below

PDD.xml
<PDD xmlns="http://tempuri.org/PDDSch.xsd"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >

PDDSch.xsd
<xs:schema id="PDD"
targetNamespace="http://tempuri.org/PDDSch.xsd"
xmlns="http://tempuri.org/PDDSch.xsd"
xmlns:mstns="http://tempuri.org/PDDSch.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

now with the above mentioned namespaces and other attributes the

validation
works properly. But I'm not able to read the child nodes through
XPathNavigator and XPathNodeIterator.

If the above rootnodes changed as shown below.

PDD.xml
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

PDDSch.xsd
<xs:schema id="PDD"
xmlns:mstns="http://tempuri.org/PDDSch.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

With the above rootnode attributes theXPathNavigator and XPathNodeIterator
will read the child nodes. but the validation is not correct.

Could someone tell me What is the mistake I'm making here.

Thanks and regards,
Harry


Nov 12 '05 #3
Associate a context to your XPathExpression and pass a NamespaceManager
which has the namespace http://tempuri.org/PDDSch.xsd mapped to a prefix
which you then should use in your query. The method you should use:

exp.SetContext ( NamespaceManager);

"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
This is the Code:

I have not assigned any namespaceManager or ParserContext for the rootNode

XmlDocument doc = new XmlDocument();
doc.Load("PDD.xml");
XmlNode rootNode = doc.DocumentElement;
XPathNavigator nav = rootNode.CreateNavigator();
XPathExpression exp = nav.Compile("//PD/*"); //PD is the child node of PDD XPathNodeIterator it = (XPathNodeIterator) nav.Evaluate(exp);

while(iterator.MoveNext())
{

}

not entering the while loop itself.

Regards,
Harry

"Zafar Abbas" wrote:
Could you share the code and the data that you are using. You should be able to walk the child nodes in both cases.
"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
I have a schema file PDDSch.xsd which validates the PDD.xml file. the
rootnodes are as shown below

PDD.xml
<PDD xmlns="http://tempuri.org/PDDSch.xsd"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >

PDDSch.xsd
<xs:schema id="PDD"
targetNamespace="http://tempuri.org/PDDSch.xsd"
xmlns="http://tempuri.org/PDDSch.xsd"
xmlns:mstns="http://tempuri.org/PDDSch.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

now with the above mentioned namespaces and other attributes the

validation
works properly. But I'm not able to read the child nodes through
XPathNavigator and XPathNodeIterator.

If the above rootnodes changed as shown below.

PDD.xml
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

PDDSch.xsd
<xs:schema id="PDD"
xmlns:mstns="http://tempuri.org/PDDSch.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">

With the above rootnode attributes theXPathNavigator and XPathNodeIterator will read the child nodes. but the validation is not correct.

Could someone tell me What is the mistake I'm making here.

Thanks and regards,
Harry


Nov 12 '05 #4
nope not entering the while loop yet.
could you please tell me what the follwing error means

The 'http://www.w3.org/2001/XMLSchema-Instance:noNamespaceSchemaLocation'
attribute is not declared.

I have specified the rootnode of PDD.xml as below.
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

Is it the problem that it is not able to link to PDDSch.xsd file.

what it means by "attribute not declared"

Thank you,
Harry
"Zafar Abbas" wrote:
Associate a context to your XPathExpression and pass a NamespaceManager
which has the namespace http://tempuri.org/PDDSch.xsd mapped to a prefix
which you then should use in your query. The method you should use:

exp.SetContext ( NamespaceManager);

"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
This is the Code:

I have not assigned any namespaceManager or ParserContext for the rootNode

XmlDocument doc = new XmlDocument();
doc.Load("PDD.xml");
XmlNode rootNode = doc.DocumentElement;
XPathNavigator nav = rootNode.CreateNavigator();
XPathExpression exp = nav.Compile("//PD/*"); //PD is the child node of

PDD
XPathNodeIterator it = (XPathNodeIterator) nav.Evaluate(exp);

while(iterator.MoveNext())
{

}

not entering the while loop itself.

Regards,
Harry

"Zafar Abbas" wrote:
Could you share the code and the data that you are using. You should be able to walk the child nodes in both cases.
"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
> I have a schema file PDDSch.xsd which validates the PDD.xml file. the
> rootnodes are as shown below
>
> PDD.xml
> <PDD xmlns="http://tempuri.org/PDDSch.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >
>
> PDDSch.xsd
> <xs:schema id="PDD"
> targetNamespace="http://tempuri.org/PDDSch.xsd"
> xmlns="http://tempuri.org/PDDSch.xsd"
> xmlns:mstns="http://tempuri.org/PDDSch.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> attributeFormDefault="qualified"
> elementFormDefault="qualified">
>
> now with the above mentioned namespaces and other attributes the
validation
> works properly. But I'm not able to read the child nodes through
> XPathNavigator and XPathNodeIterator.
>
> If the above rootnodes changed as shown below.
>
> PDD.xml
> <PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
> xsi:noNamespaceSchemaLocation="PDDSch.xsd">
>
> PDDSch.xsd
> <xs:schema id="PDD"
> xmlns:mstns="http://tempuri.org/PDDSch.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> attributeFormDefault="qualified"
> elementFormDefault="qualified">
>
> With the above rootnode attributes theXPathNavigator and XPathNodeIterator > will read the child nodes. but the validation is not correct.
>
> Could someone tell me What is the mistake I'm making here.
>
> Thanks and regards,
> Harry
>


Nov 12 '05 #5
The correct namespace declaration is:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

note the small 'i' in the instance.

"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
nope not entering the while loop yet.
could you please tell me what the follwing error means

The 'http://www.w3.org/2001/XMLSchema-Instance:noNamespaceSchemaLocation'
attribute is not declared.

I have specified the rootnode of PDD.xml as below.
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

Is it the problem that it is not able to link to PDDSch.xsd file.

what it means by "attribute not declared"

Thank you,
Harry
"Zafar Abbas" wrote:
Associate a context to your XPathExpression and pass a NamespaceManager
which has the namespace http://tempuri.org/PDDSch.xsd mapped to a prefix
which you then should use in your query. The method you should use:

exp.SetContext ( NamespaceManager);

"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
This is the Code:

I have not assigned any namespaceManager or ParserContext for the rootNode
XmlDocument doc = new XmlDocument();
doc.Load("PDD.xml");
XmlNode rootNode = doc.DocumentElement;
XPathNavigator nav = rootNode.CreateNavigator();
XPathExpression exp = nav.Compile("//PD/*"); //PD is the child node of
PDD
XPathNodeIterator it = (XPathNodeIterator) nav.Evaluate(exp);

while(iterator.MoveNext())
{

}

not entering the while loop itself.

Regards,
Harry

"Zafar Abbas" wrote:

> Could you share the code and the data that you are using. You should
be able
> to walk the child nodes in both cases.
>
>
> "Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
> news:B1**********************************@microsof t.com...
> > I have a schema file PDDSch.xsd which validates the PDD.xml file.

the > > rootnodes are as shown below
> >
> > PDD.xml
> > <PDD xmlns="http://tempuri.org/PDDSch.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >
> >
> > PDDSch.xsd
> > <xs:schema id="PDD"
> > targetNamespace="http://tempuri.org/PDDSch.xsd"
> > xmlns="http://tempuri.org/PDDSch.xsd"
> > xmlns:mstns="http://tempuri.org/PDDSch.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > attributeFormDefault="qualified"
> > elementFormDefault="qualified">
> >
> > now with the above mentioned namespaces and other attributes the
> validation
> > works properly. But I'm not able to read the child nodes through
> > XPathNavigator and XPathNodeIterator.
> >
> > If the above rootnodes changed as shown below.
> >
> > PDD.xml
> > <PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
> > xsi:noNamespaceSchemaLocation="PDDSch.xsd">
> >
> > PDDSch.xsd
> > <xs:schema id="PDD"
> > xmlns:mstns="http://tempuri.org/PDDSch.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > attributeFormDefault="qualified"
> > elementFormDefault="qualified">
> >
> > With the above rootnode attributes theXPathNavigator and

XPathNodeIterator
> > will read the child nodes. but the validation is not correct.
> >
> > Could someone tell me What is the mistake I'm making here.
> >
> > Thanks and regards,
> > Harry
> >
>
>
>


Nov 12 '05 #6
Well it was a stupid error, I was working with visual studio and could not
make out the error, When I checked it in XML spy which said "xml file not
well formed".
It was a great help from your side.
Thanks a lot Abbas

Regards,
Harry

"Zafar Abbas" wrote:
The correct namespace declaration is:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

note the small 'i' in the instance.

"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
nope not entering the while loop yet.
could you please tell me what the follwing error means

The 'http://www.w3.org/2001/XMLSchema-Instance:noNamespaceSchemaLocation'
attribute is not declared.

I have specified the rootnode of PDD.xml as below.
<PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:noNamespaceSchemaLocation="PDDSch.xsd">

Is it the problem that it is not able to link to PDDSch.xsd file.

what it means by "attribute not declared"

Thank you,
Harry
"Zafar Abbas" wrote:
Associate a context to your XPathExpression and pass a NamespaceManager
which has the namespace http://tempuri.org/PDDSch.xsd mapped to a prefix
which you then should use in your query. The method you should use:

exp.SetContext ( NamespaceManager);

"Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
> This is the Code:
>
> I have not assigned any namespaceManager or ParserContext for the rootNode >
> XmlDocument doc = new XmlDocument();
> doc.Load("PDD.xml");
> XmlNode rootNode = doc.DocumentElement;
> XPathNavigator nav = rootNode.CreateNavigator();
> XPathExpression exp = nav.Compile("//PD/*"); //PD is the child node of PDD
> XPathNodeIterator it = (XPathNodeIterator) nav.Evaluate(exp);
>
> while(iterator.MoveNext())
> {
>
> }
>
> not entering the while loop itself.
>
> Regards,
> Harry
>
>
>
> "Zafar Abbas" wrote:
>
> > Could you share the code and the data that you are using. You should be able
> > to walk the child nodes in both cases.
> >
> >
> > "Harry_Crow" <Ha*******@discussions.microsoft.com> wrote in message
> > news:B1**********************************@microsof t.com...
> > > I have a schema file PDDSch.xsd which validates the PDD.xml file. the > > > rootnodes are as shown below
> > >
> > > PDD.xml
> > > <PDD xmlns="http://tempuri.org/PDDSch.xsd"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >
> > >
> > > PDDSch.xsd
> > > <xs:schema id="PDD"
> > > targetNamespace="http://tempuri.org/PDDSch.xsd"
> > > xmlns="http://tempuri.org/PDDSch.xsd"
> > > xmlns:mstns="http://tempuri.org/PDDSch.xsd"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > > attributeFormDefault="qualified"
> > > elementFormDefault="qualified">
> > >
> > > now with the above mentioned namespaces and other attributes the
> > validation
> > > works properly. But I'm not able to read the child nodes through
> > > XPathNavigator and XPathNodeIterator.
> > >
> > > If the above rootnodes changed as shown below.
> > >
> > > PDD.xml
> > > <PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
> > > xsi:noNamespaceSchemaLocation="PDDSch.xsd">
> > >
> > > PDDSch.xsd
> > > <xs:schema id="PDD"
> > > xmlns:mstns="http://tempuri.org/PDDSch.xsd"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > > attributeFormDefault="qualified"
> > > elementFormDefault="qualified">
> > >
> > > With the above rootnode attributes theXPathNavigator and
XPathNodeIterator
> > > will read the child nodes. but the validation is not correct.
> > >
> > > Could someone tell me What is the mistake I'm making here.
> > >
> > > Thanks and regards,
> > > Harry
> > >
> >
> >
> >


Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
41
by: Gérard Talbot | last post by:
Cross-posted to: comp.infosystems.www.authoring.html and alt.html Followup-to: comp.infosystems.www.authoring.html 1- One day, I stumbled across a website that offers to validate webpages. What...
3
by: Kent Ogletree | last post by:
I am porting a Java XML Validation class over to C# and I am having a problem finding exactly what I need to acomplish the task. First I need to test for well formedness. I know this is usually...
4
by: | last post by:
Hello Guys, I am using the validation controls to validate my data. But the problem is "The page is still being posted to server". I want to get rid of the round trips to server. Are there...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
3
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
9
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected......
2
by: dustbort | last post by:
I recently had a problem where my required field validator stopped working. But, the page still posted back and tried to insert a record into the database without performing server-side validation....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.