473,722 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

validating xml doc with multiple schemas using wildcards

I am trying to validate a xml file with two schema files cust.xsd and
cust1.xsd. The schema file cust.xsd allows addition of elements from
another schema cust1.xsd by using xs:any wildcard.

cust.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="urn:xmlns:sys apex-com:customer"
elementFormDefa ult="qualified"
xmlns="urn:xmln s:sysapex-com:customer"
xmlns:mstns="ur n:xmlns:sysapex-com:customer"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Customer" >
<xs:complexType >
<xs:sequence>
<xs:element name="FirstName " type="xs:string " />
<xs:element name="LastName" type="xs:string " />

<xs:any namespace="##ta rgetNamespace" processContents ="strict"
minOccurs="0" maxOccurs="unbo unded" />
<xs:any namespace="##an y" processContents ="lax" minOccurs="0"
maxOccurs="unbo unded" />
</xs:sequence>
<xs:attribute name="customerI D" type="xs:intege r" />
<xs:anyAttribut e namespace="##an y" processContents ="skip" />
</xs:complexType>
</xs:element>
</xs:schema>

cust1.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
targetNamespace ="urn:xmlns:sys apex-com:address"
elementFormDefa ult="qualified"
xmlns="urn:xmln s:sysapex-com:address"
xmlns:mstns="ur n:xmlns:sysapex-com:address"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Customer" >
<xs:complexType >
<xs:sequence>
<xs:element name="Address" type="xs:string " />
<xs:element name="City" type="xs:string " />
<xs:element name="State" type="xs:string " />
<xs:element name="Zip" type="xs:string " />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

cust.xml - This has to be validated against both cust.xsd and
cust1.xsd

<cust:Custome r customerID="123 45" numPurchases="1 7"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:cust="urn :xmlns:sysapex-com:customer"
xsi:noNamespace SchemaLocation= "file://c:/per/Schemas_nn/new1/cust.xsd"

xsi:schemaLocat ion="urn:xmlns: sysapex-com:address
file://c:/per/Schemas_nn/new1/cust1.xsd"
xmlns:addr="urn :xmlns:sysapex-com:address">
<cust:FirstNa me >Dare</cust:FirstName>
<cust:LastNam e >Obasanjo</cust:LastName>
<cust:PhoneNumb er >425-555-1234</cust:PhoneNumbe r>

<addr:Address>2 001 Beagle Drive</addr:Address>
<addr:City>Redm ond</addr:City>
<addr:State>W A</addr:State>
<addr:Zip>98052 </addr:Zip>

</cust:Customer>

Both schemas validate OK. However when I validate cust.xml with the
schemas, I get the following error in MSXML parser using VS Studio
2003. "Although this XML document is well-formed it contains a
structure that data view cannot display. The
urn:xmlns:syspa ex-com:address:Adr ess element is not declared".
I have suspicion that the xsi:schemaLocat ion syntax in my cust.xml
referring to the path location of my schema file on the c drive as
file://c:/per/Schemas_nn/new1/cust1.xsd is causing the error. I know
the cust1.xsd is in the right location.

I don't know any better.

Please advise.

Jan 20 '07 #1
3 3237
vhrao wrote:
cust.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="urn:xmlns:sys apex-com:customer"
elementFormDefa ult="qualified"
xmlns="urn:xmln s:sysapex-com:customer"
xmlns:mstns="ur n:xmlns:sysapex-com:customer"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
So this schema defines elements in the namespace
urn:xmlns:sysap ex-com:customer.
cust1.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
targetNamespace ="urn:xmlns:sys apex-com:address"
elementFormDefa ult="qualified"
xmlns="urn:xmln s:sysapex-com:address"
xmlns:mstns="ur n:xmlns:sysapex-com:address"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
The second schema defines elements in the namespace
urn:xmlns:sysap ex-com:address.

<cust:Custome r customerID="123 45" numPurchases="1 7"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:cust="urn :xmlns:sysapex-com:customer"
xsi:noNamespace SchemaLocation= "file://c:/per/Schemas_nn/new1/cust.xsd"
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^

Why are you using noNamespaceSche maLocation although cust.xsd defines
elements in a namespace? You need to provide the locations of the
schemas with schemaLocation, not with noNamespaceSche maLocation e.g.

xsi:schemaLocat ion="urn:xmlns: sysapex-com:address
file:///c:/per/Schemas_nn/new1/cust1.xsd urn:xmlns:sysap ex-com:customer
file:///c:/per/Schemas_nn/new1/cust.xsd"
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 21 '07 #2
Thank you. It took care of the original error I had. But a new error
comes up.
Here is the revised cust.xml and error message.

cust.xml
<?xml version="1.0" encoding="utf-8" ?>
<cust:Custome r customerID="123 45" numPurchases="1 7"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:cust="urn :xmlns:sysapex-com:customer"
xmlns:addr="urn :xmlns:sysapex-com:address"
xsi:schemaLocat ion="urn:xmlns: sysapex-com:customer
file:///f:/per/pats/new1/cust.xsd
urn:xmlns:sysap ex-com:address
file:///f:/per/pats/new1/cust1.xsd" >

<cust:FirstNa me >Dare</cust:FirstName>
<cust:LastNam e >Obasanjo</cust:LastName>
<addr:Address>2 001 Beagle Drive</addr:Address>
<addr:City>Redm ond</addr:City>
<addr:State>W A</addr:State>
<addr:Zip>98052 </addr:Zip>
</cust:Customer>

Error Message:
The given name Customer matches at least two names in the collection
object with different namespaces.

How can I fix this problem.

Thanks for your help!

Martin Honnen wrote:
vhrao wrote:
cust.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="urn:xmlns:sys apex-com:customer"
elementFormDefa ult="qualified"
xmlns="urn:xmln s:sysapex-com:customer"
xmlns:mstns="ur n:xmlns:sysapex-com:customer"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

So this schema defines elements in the namespace
urn:xmlns:sysap ex-com:customer.
cust1.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
targetNamespace ="urn:xmlns:sys apex-com:address"
elementFormDefa ult="qualified"
xmlns="urn:xmln s:sysapex-com:address"
xmlns:mstns="ur n:xmlns:sysapex-com:address"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

The second schema defines elements in the namespace
urn:xmlns:sysap ex-com:address.

<cust:Custome r customerID="123 45" numPurchases="1 7"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:cust="urn :xmlns:sysapex-com:customer"
xsi:noNamespace SchemaLocation= "file://c:/per/Schemas_nn/new1/cust.xsd"
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^

Why are you using noNamespaceSche maLocation although cust.xsd defines
elements in a namespace? You need to provide the locations of the
schemas with schemaLocation, not with noNamespaceSche maLocation e.g.

xsi:schemaLocat ion="urn:xmlns: sysapex-com:address
file:///c:/per/Schemas_nn/new1/cust1.xsd urn:xmlns:sysap ex-com:customer
file:///c:/per/Schemas_nn/new1/cust.xsd"
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 21 '07 #3
vhrao wrote:
But a new error
comes up.
Here is the revised cust.xml and error message.

cust.xml
<?xml version="1.0" encoding="utf-8" ?>
<cust:Custome r customerID="123 45" numPurchases="1 7"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:cust="urn :xmlns:sysapex-com:customer"
xmlns:addr="urn :xmlns:sysapex-com:address"
xsi:schemaLocat ion="urn:xmlns: sysapex-com:customer
file:///f:/per/pats/new1/cust.xsd
urn:xmlns:sysap ex-com:address
file:///f:/per/pats/new1/cust1.xsd" >

<cust:FirstNa me >Dare</cust:FirstName>
<cust:LastNam e >Obasanjo</cust:LastName>
<addr:Address>2 001 Beagle Drive</addr:Address>
<addr:City>Redm ond</addr:City>
<addr:State>W A</addr:State>
<addr:Zip>98052 </addr:Zip>
</cust:Customer>

Error Message:
The given name Customer matches at least two names in the collection
object with different namespaces.
What exactly do you want to achieve? Do you know about xs:import and
then xs:element ref to import and reference elements from a different
namespace? I don't think you need xs:any to use elements from different
namespaces.

As for the error message, which tool exactly do you use for validation
that gives that error message?


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 22 '07 #4

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

Similar topics

3
4977
by: Mats | last post by:
It's good practice to validate input, not only where it should be coming from, but from anywhere it's possible to change or add input for a "client". If all user input is transfered using "post" you can be pretty tough on querystrings, if you use them at all. But user input could have a name like Mc'Donald, and we would not like quotes (wether single or double) in input to a database or an asp script. Though I beleive more dangerous in...
0
1276
by: Sean Keplinger | last post by:
I have a document that has a reference to two XSD schemas. I'm looking for a tool (in Perl) that will validate the document against both schemas. I've tried using XML::Checker, but it fails checking one of the XSD's. Any suggestions? Thanks, Sean --
6
2426
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting is not absolutely wonderful. So what I want to do is to validate it before I upload it. When I try and do this I get MILLIONS of errors (well lots) complaining about elements like ROOT which are part of the
1
5984
by: Brendon | last post by:
I have 2 Xsd's The one contains basic type definitions <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:simpleType name="TrueFalse"> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="true"/>
4
2290
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all works with SPY, but when I pick "Validate Schema" from the .NET 2003 menu, it fails with message: "Type XType is not declared." As I hinted at in my subject line, I suspect that it has to do with including another schema multiple times.
0
1438
by: wolf_y | last post by:
I'm a newbie to XML and primarily program in SAS, so even though I've consulted documentation, I can't translate into language I understand. I hope I can explain the problem clearly. The project I'm currently on starts with XML files (say, 10 as an example) that, after validation, are reconfigured via SAS for Teradata loading. Since we're in development, the location of needed schemas isn't fixed, often moving as phases are completed...
2
3084
by: Darrell Plank | last post by:
I'm a real XML novice, but my ultimate goal here is to get a workable schema for the GEDCOM XML format as spec'ed out here: http://www.familysearch.org/GEDCOM/GedXML60.pdf It's a proposed XML format for genealogical records. They include a DTD in the spec but sadly its incomplete in that the spec allows for "html" (unlimited HTML or a subset they don't say) in certain elements to allow for formatting. There is also a sample GEDCOM...
0
3600
by: Patrick Brunmayr | last post by:
Hello I have a big Problem with validating a Soap Envelope. I have downloaded the xsd for a soap envelope from http://schemas.xmlsoap.org/soap/envelope/ The validation succeeds as lonng as i don't use elements in body with a xsi:type attribute! The Problem is that foo:person is an abstract type and foo:driver is dervived from it. So using a foo:person is not allowed until specifing
4
5743
by: agda.karlberg | last post by:
Hello, I need to remove the DTD reference from an xml document, the reason for this is that we want to validate against a schema instead (which we have locally). It takes up to a minute to fetch all documents referred to in the DTD, and as we have no use for them I want to remove the reference. I'm using XmlReaderSettings to pass in the xml document and the schema, but when I loop through the reader it goes and tries to get
0
9238
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.