473,394 Members | 1,679 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.

Difficulty seeing error

If I try to validate this xml...
<?xml version="1.0" encoding="utf-8" ?>
<a:FuncalcParameters xmlns:a="http://www.somewhere.fun.com/Funcalc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.somewhere.fun.com/Funcalc
http://localhost/FuncalcService/FuncalcParameters.xsd">
<TransId>D-288</TransId>
<CalcType>CalculateARM</CalcType>
<SR>5</SR>
<RRT></RRT>
<RRQ></RRQ>
<B_Indicator>y</B_Indicator>
<ReferenceYYYYMMDD>1998-05-12</ReferenceYYYYMMDD>
<ARM>lala</ARM>
<SRMP>136.26</SRMP>
<ResponseYYYYMMDD>2003-06-30</ResponseYYYYMMDD>
</a:FuncalcParameters>
....against this schema...
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.somewhere.fun.com/Funcalc"
targetNamespace="http://www.somewhere.fun.com/Funcalc">
<xs:element name="FuncalcParameters" nillable="true"
type="FuncalcParameters" />
<xs:complexType name="FuncalcParameters">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="TransId" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="CalcType"
type="CalculationType"/>
<xs:element minOccurs="1" maxOccurs="1" name="SR" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="RRT" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="RRQ" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="B_Indicator"
type="BackType" />
<xs:element minOccurs="0" maxOccurs="1" name="ReferenceYYYYMMDD"
type="xs:date" />
<xs:element minOccurs="1" maxOccurs="1" name="ARM" type="xs:float" />
<xs:element minOccurs="1" maxOccurs="1" name="SRMP" type="xs:float" />
<xs:element minOccurs="0" maxOccurs="1" name="ResponseYYYYMMDD"
type="xs:date" />
</xs:sequence>
</xs:complexType>
<xs:simpleType name="CalculationType">
<xs:restriction base="xs:string">
<xs:enumeration value="CalculateARM" />
<xs:enumeration value="CalculateSRMP" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BackType">
<xs:restriction base="xs:string">
<xs:enumeration value="b" />
<xs:enumeration value="B" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
....the validation complains that...
Element 'http://www.somewhere.fun.com/Funcalc:FuncalcParameters' has invalid
child element 'TransId'. Expected
'http://www.somewhere.fun.com/Funcalc:TransId
http://www.somewhere.fun.com/Funcalc:CalcType'...
Why does it mention "CalcType"? Altering the schema so that "CalcType" is
further down results in the validation complaining about
'http://www.somewhere.fun.com/Funcalc:TransId
http://www.somewhere.fun.com/Funcalc:SR'. Can anyone see what's going on?
Thanks

Nov 11 '05 #1
3 1423
I think I found my error. By simply adding the namespace "a:" to all of the
instance doc's elements, everything behaves as I would expect. It was not
just a "TransId" or "CalcType" problem - in fact all of the elements needed
to be qualified in the "a:" namespace. But still I wonder why if all of the
elements needed "a:", why did the error message only complain about the
first two? Oh well...

"Marty McDonald" <mc******@wsdot.wa.gov> wrote in message
news:#C**************@TK2MSFTNGP09.phx.gbl...
If I try to validate this xml...
<?xml version="1.0" encoding="utf-8" ?>
<a:FuncalcParameters xmlns:a="http://www.somewhere.fun.com/Funcalc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.somewhere.fun.com/Funcalc
http://localhost/FuncalcService/FuncalcParameters.xsd">
<TransId>D-288</TransId>
<CalcType>CalculateARM</CalcType>
<SR>5</SR>
<RRT></RRT>
<RRQ></RRQ>
<B_Indicator>y</B_Indicator>
<ReferenceYYYYMMDD>1998-05-12</ReferenceYYYYMMDD>
<ARM>lala</ARM>
<SRMP>136.26</SRMP>
<ResponseYYYYMMDD>2003-06-30</ResponseYYYYMMDD>
</a:FuncalcParameters>
...against this schema...
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.somewhere.fun.com/Funcalc"
targetNamespace="http://www.somewhere.fun.com/Funcalc">
<xs:element name="FuncalcParameters" nillable="true"
type="FuncalcParameters" />
<xs:complexType name="FuncalcParameters">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="TransId" type="xs:string"/> <xs:element minOccurs="1" maxOccurs="1" name="CalcType"
type="CalculationType"/>
<xs:element minOccurs="1" maxOccurs="1" name="SR" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="RRT" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="RRQ" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="B_Indicator"
type="BackType" />
<xs:element minOccurs="0" maxOccurs="1" name="ReferenceYYYYMMDD"
type="xs:date" />
<xs:element minOccurs="1" maxOccurs="1" name="ARM" type="xs:float" />
<xs:element minOccurs="1" maxOccurs="1" name="SRMP" type="xs:float" />
<xs:element minOccurs="0" maxOccurs="1" name="ResponseYYYYMMDD"
type="xs:date" />
</xs:sequence>
</xs:complexType>
<xs:simpleType name="CalculationType">
<xs:restriction base="xs:string">
<xs:enumeration value="CalculateARM" />
<xs:enumeration value="CalculateSRMP" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BackType">
<xs:restriction base="xs:string">
<xs:enumeration value="b" />
<xs:enumeration value="B" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
...the validation complains that...
Element 'http://www.somewhere.fun.com/Funcalc:FuncalcParameters' has invalid child element 'TransId'. Expected
'http://www.somewhere.fun.com/Funcalc:TransId
http://www.somewhere.fun.com/Funcalc:CalcType'...
Why does it mention "CalcType"? Altering the schema so that "CalcType" is
further down results in the validation complaining about
'http://www.somewhere.fun.com/Funcalc:TransId
http://www.somewhere.fun.com/Funcalc:SR'. Can anyone see what's going on?
Thanks

Nov 11 '05 #2
Hi Marty,

While I can't answer your question myself, I have sent it on to the team
that supports XML in developer Support. I'll get an answer to you ASAP.

Brett Keown
Microsoft Support
br*****@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 11 '05 #3
Here is what I see.

1> Xsd seems simple enough. You have an element called "FuncalcParameters"
which has 10 child nodes (some of which may be present and others are
required).
2> Required items are CalcType, SR, ARM and SRMP.
3> All can only occur once in sequence.

From the Xml, I see the following.

1> We are associating the prefix "a" with
"http://www.somewhere.fun.com/Funcalc"
2> FuncalcParameters is associated to the prefix (and therefore namespace)
"a"
3> Funcalc does not have ANY children to validate against and should fail
on the "CalcType".
4> Because the first child HAS to be TransID, it should also fail because
there is no a:TransID. (remember that TransID and a:TransID are totally
different.)
TransID internally is TransID
a:TransID internally is
TransID:http://www.somewhere.fun.com/Funcalc
So, there are a few ways to workaround this.

1> Remove the "a" from the xmlns:a="http://www.somewhere.fun.com/Funcalc".
If you choose to leave the prefix "a", then you will have to prefix ALL
elements belonging to that namespace with "a". Also, remember, when you
place a sequence into the element, you are basically saying that the
elements will be in that order and any other order is incorrect.
2> Prefix all elements with "a" and associate it with the namespace.

It would always be best to do #2, however, many use #1 for ease.

Let us know if you need additional clarification.

Thanks

Bruce Taimana

Microsoft Developer Support XML WebData Group

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.

© 2001 Microsoft Corporation. All rights reserved.
Nov 11 '05 #4

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

Similar topics

2
by: toto4UK | last post by:
Hello, One of my queries running with Oracle 8.1.7.4 on a SPARC machine with SunOS 5.8 has been traced and TKPROF gave me the following result for PEF stats : Need to say that query is a...
9
by: Adam | last post by:
Hey, I'm trying to write a script with two standard drop down boxes. One contains days one contains the month. I want to update the options in the days box everytime the month is changed......
1
by: Tim Marshall | last post by:
I've just received a new computer with Win XP Version 5.1.2600. I want to have Access 2003 and Access 97 running on this, so I did some googling on cdma and it seems I must install these versions...
3
by: wheresjim | last post by:
I am trying this project out: http://www.codeproject.com/useritems/javacsharp.asp I am having difficulty building parts of it with Visual Studio .NET 2003 because of a post-build step that...
1
by: Piyush Trivedi | last post by:
I am experiencing difficulty to access a mapped network drive in an ASP.NET application. While using the .Net framework v 1.1 implementation of System.IO.Directory.Exists() to check if the...
6
by: Brian Link | last post by:
Panicked, as usual. Who says it's great being a sole proprietor? Using MS-SQLServer: Three tables: A_Appointment, AX_Appointment_Entity and E_Entity. AX_Appointment_Entity is an...
5
by: Rico | last post by:
Hello, I'm trying to create a simple back up in the SQL Maintenance Plan that will make a single back up copy of all database every night at 10 pm. I'd like the previous nights file to be...
1
by: Kevin Walzer | last post by:
I'm trying to create a custom Tkinter widget class, and I'm having some difficulty getting it set up properly. The class is called MacToolbar, saved in its own module MacToolbar.py, and imported...
12
by: ibloom | last post by:
I've been trying for a couple days to build a program using pyObjC on a mac, I'm stuck on this error: <string>: inconsistent use of tabs and spaces in indentation Traceback (most recent call...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.