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:sysapex-com:customer"
elementFormDefault="qualified"
    xmlns="urn:xmlns:sysapex-com:customer"
xmlns:mstns="urn: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="##targetNamespace" processContents="strict"
       minOccurs="0" maxOccurs="unbounded" />
       <xs:any namespace="##any" processContents="lax" minOccurs="0"
        maxOccurs="unbounded" />
     </xs:sequence>
     <xs:attribute name="customerID" type="xs:integer" />
         <xs:anyAttribute namespace="##any" processContents="skip" />
        </xs:complexType>
    </xs:element>
</xs:schema>

cust1.xsd - schema
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
targetNamespace="urn:xmlns:sysapex-com:address"
elementFormDefault="qualified"
xmlns="urn:xmlns:sysapex-com:address"
xmlns:mstns="urn: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:Customer customerID="12345" numPurchases="17"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:cust="urn:xmlns:sysapex-com:customer"
xsi:noNamespaceSchemaLocation="file://c:/per/Schemas_nn/new1/cust.xsd"

xsi:schemaLocation="urn:xmlns:sysapex-com:address
file://c:/per/Schemas_nn/new1/cust1.xsd"
xmlns:addr="urn:xmlns:sysapex-com:address">


    <cust:FirstName  >Dare</cust:FirstName>
    <cust:LastName >Obasanjo</cust:LastName>
    <cust:PhoneNumber >425-555-1234</cust:PhoneNumber>

    <addr:Address>2001 Beagle Drive</addr:Address>
    <addr:City>Redmond</addr:City>
    <addr:State>WA</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:syspaex-com:address:Adress element is not declared".


I have suspicion that the xsi:schemaLocation 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.

0
vihrao (3)
1/20/2007 4:46:38 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
599 Views

Similar Articles

[PageSpeed] 57

vhrao wrote:

> cust.xsd - schema
> <?xml version="1.0" encoding="utf-8" ?>
> <xs:schema targetNamespace="urn:xmlns:sysapex-com:customer"
> elementFormDefault="qualified"
>     xmlns="urn:xmlns:sysapex-com:customer"
> xmlns:mstns="urn:xmlns:sysapex-com:customer"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">

So this schema defines elements in the namespace 
urn:xmlns:sysapex-com:customer.

> cust1.xsd - schema
> <?xml version="1.0" encoding="utf-8" ?>
> <xs:schema
> targetNamespace="urn:xmlns:sysapex-com:address"
> elementFormDefault="qualified"
> xmlns="urn:xmlns:sysapex-com:address"
> xmlns:mstns="urn:xmlns:sysapex-com:address"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">

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


> <cust:Customer customerID="12345" numPurchases="17"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xmlns:cust="urn:xmlns:sysapex-com:customer"
> xsi:noNamespaceSchemaLocation="file://c:/per/Schemas_nn/new1/cust.xsd"
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

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


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
1/21/2007 1:24:24 PM
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:Customer customerID="12345" numPurchases="17"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:cust="urn:xmlns:sysapex-com:customer"
 xmlns:addr="urn:xmlns:sysapex-com:address"
xsi:schemaLocation="urn:xmlns:sysapex-com:customer
file:///f:/per/pats/new1/cust.xsd
urn:xmlns:sysapex-com:address
file:///f:/per/pats/new1/cust1.xsd" >

	<cust:FirstName  >Dare</cust:FirstName>
	<cust:LastName >Obasanjo</cust:LastName>
  <addr:Address>2001 Beagle Drive</addr:Address>
  <addr:City>Redmond</addr:City>
  <addr:State>WA</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:sysapex-com:customer"
> > elementFormDefault="qualified"
> >     xmlns="urn:xmlns:sysapex-com:customer"
> > xmlns:mstns="urn:xmlns:sysapex-com:customer"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> So this schema defines elements in the namespace
> urn:xmlns:sysapex-com:customer.
>
> > cust1.xsd - schema
> > <?xml version="1.0" encoding="utf-8" ?>
> > <xs:schema
> > targetNamespace="urn:xmlns:sysapex-com:address"
> > elementFormDefault="qualified"
> > xmlns="urn:xmlns:sysapex-com:address"
> > xmlns:mstns="urn:xmlns:sysapex-com:address"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> The second schema defines elements in the namespace
> urn:xmlns:sysapex-com:address.
>
>
> > <cust:Customer customerID="12345" numPurchases="17"
> >  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >  xmlns:cust="urn:xmlns:sysapex-com:customer"
> > xsi:noNamespaceSchemaLocation="file://c:/per/Schemas_nn/new1/cust.xsd"
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Why are you using noNamespaceSchemaLocation although cust.xsd defines
> elements in a namespace? You need to provide the locations of the
> schemas with schemaLocation, not with noNamespaceSchemaLocation e.g.
>
>    xsi:schemaLocation="urn:xmlns:sysapex-com:address
> file:///c:/per/Schemas_nn/new1/cust1.xsd urn:xmlns:sysapex-com:customer
> file:///c:/per/Schemas_nn/new1/cust.xsd"
>
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/

0
vihrao (3)
1/21/2007 8:10:42 PM
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:Customer customerID="12345" numPurchases="17"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xmlns:cust="urn:xmlns:sysapex-com:customer"
>  xmlns:addr="urn:xmlns:sysapex-com:address"
> xsi:schemaLocation="urn:xmlns:sysapex-com:customer
> file:///f:/per/pats/new1/cust.xsd
> urn:xmlns:sysapex-com:address
> file:///f:/per/pats/new1/cust1.xsd" >
> 
> 	<cust:FirstName  >Dare</cust:FirstName>
> 	<cust:LastName >Obasanjo</cust:LastName>
>   <addr:Address>2001 Beagle Drive</addr:Address>
>   <addr:City>Redmond</addr:City>
>   <addr:State>WA</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/
0
mahotrash (1777)
1/22/2007 4:06:03 PM
Reply:

Similar Artilces:

Want use results of Drop down list to look up a value
I am using Excel 2002 and I have a multisheet workbook and on the first sheet I have created a series of 6 drop down lists pulling from predefined named ranges. I also have limited subsequent choices based on what is selected in the other lists. The end result is the user will be selecting parameters that identify a product and now I am stuck with an easy way to look up the associated part number based on the parameters they selected. Essentially, once they have chosen the parameters in the list, I would like to create a macro that uses those values to locate the associated part...

Compressing xml file
I am using sharpziplib ti compress & zip an XML file. But the compression ration is very bad for this utility compared to that i do with winzip. Any idea how to integrate winzip with our VB.net application to compress xml files. Or is there any other utility to do the kob Devesh "Devesh Aggarwal" <solutions@unieme.com> schreef in bericht news:#TwLpW8kDHA.1708@TK2MSFTNGP12.phx.gbl... > I am using sharpziplib ti compress & zip an XML file. But the compression > ration is very bad for this utility compared to that i do with winzip. Any > idea how to integrate...

Nested schemas
I have a schema that references a child schema via a "xs:import" node. In that child schema it references several other grand children schemas. Is there an object in the VS 2K5 suite which will allow me to consolidate all the nested schemas into one giant schema? I've tried using the XmlSchemaSet object, but I cannot find a way to serialize the compile schema. I'd appreciate any help or advice. If you are using <xs:import>, these schemas are in different namespaces. You can only have one namespace per file. So unless you want to remove/merge namespaces, you cannot...

How to used HOOK in OutLook Express
Hello All : I want to use hook control .When outlook express received new mail and remove the new eamil to myself mailbox . PS:Use C++ or HOOK .(not outlook express rule) Thanks Stiwin Lee ...

Using the "IF" function?
I setup a worksheet like below A B 1 Jan 123 2 Feb 543 3 Mar 654 4 Apr 456 5 May 645 6 Jun 543 7 Jul 0 8 Aug 0 9 Sep 0 10 Oct 0 11 Nov 0 12 Dec 0 13 When the end of the month, the user will enter some value in the B column, And now I would to setup a formula at A13, if the user enter the value in the B7, then the A13 will show Jul, when the user carry on to enter the value in the B8, then the A13 will change to show Aug, is it possible to setup a if formula or other formula rather than use the macro to doing this? Many Thanks. Ruff Try this: =INDEX...

Shared use of excel work books
Hi, Can anyone tell me "if I have an excel workbook (with multiple worksheets that report to the first worksheet) on a shared drive whether it can be set up for multiple users to access it and use it at the same time?" These users will be accessing their single worksheet to update it periodically with the first worksheet being the project leaders sheet where he gets to see all the other worksheets on his one sheet. -- Ian Hi Ian, You can do this by selcting "shareworkbook" from the tools menu and checking the 'allow changes by more than one use'. Beware th...

multiple outlets centralized Inventory needs POS solution
One of our customer has multiple outlets. Selling is conducted through the outlets. they have a centralized warehouse. A POS solution is required Contact your local RMS dealer he can help. Store ops in each location then HQ in warehouse. "Haresh_ahuja" <Haresh_ahuja@discussions.microsoft.com> wrote in message news:21B3A81A-2CDC-42A0-9327-9722661FAA41@microsoft.com... > One of our customer has multiple outlets. Selling is conducted through the > outlets. they have a centralized warehouse. A POS solution is required Haresh, You need a HQ for the warehouse and store op...

XML Deserialization #3
Hi all Im building an object model so I can deserialize my incoming XML and Ive got a wee problem My incoming XML looks like this .... <Surnames> <Surname>Kelly</Surname> <AlternativeSurnames> <AlternativeSurname>Hill</AlternativeSurname> <AlternativeSurname>Bell</AlternativeSurname> </AlternativeSurnames> </Surnames> .... Have 3 classes - AlternativeSurname, AlternativeSurnamesCollection and Surnames. namespace PROMOD { using System; using System.Xml; using System.Xml.Serialization; [Syste...

Bluetooth: After pair without using a code, CreateFile asks for co
I am trying to use a Bluetooth device in Vista Home Premium. The device does not have a pairing code or any way to enter one. I use "Add Wireless device" in the Bluetooth Devices control panel. My device is found and I choose "pair without using a code". The device pairs OK and its properties show under Services, Serial port ( SPP) 'AT Serial' COM4 But when I call CreateFile to open COM4, Vista shows a "click here" box informing me that a device is trying to connect. When I click the box, I get a dialog asking for the pairing code. How ca...

multiple or conditions
I have written syntax that doesn't seem to be picking up all my or conditions thus leaving me with an inaccurate answer. What am I doing wrong? =IF($I5>2.5,1,0)*OR($K5>2.5,1,0)*OR($M5>2.5,1,0)*OR($O5>2.5,1,0) *OR($Q5>2.5,1,0)*OR($J5>5,1,0)*OR($L5>5,1,0)*OR($N5>5,1,0) *OR($P5>5,1,0)*OR($R5>5,1,0) Look in HELP index for the proper syntax for OR -- Don Guillett SalesAid Software donaldb@281.com "lschuh" <lschuh@discussions.microsoft.com> wrote in message news:E3DCD1CE-4350-40E8-B1C5-0A1CEFCD5B27@microsoft.com... > I have written syntax ...

Example using MFC WinInet classes with POST of FILE and other INPUT data
I am looking for a good example for POSTing both FILE and other INPUT data to a URL. I understand that the FILE must use a multi-part encoding but I do not understand how the atcual file contents get POSTed or how the INPUT data gets POSTed also. I am guessing the INPUT data can be added as part of the query parameters to the URL. ...

Writing XML File from Dataset
Read many of the posting but still doen't understand the process. I have a dataset with child records. I have a specific XML "Account.XSD" format that I need to write this out to. How do I marry these (2) items to create the output file. Dim dataSet As DataSet = New DataSet("AccountRecord") PremisesAdapter.Fill(dataSet, "Premises") SupAdapter.Fill(dataSet, "Supplemental") cn.Close() Dim AccountRecord As DataRelation = dataSet.Relations.Add("Prem_Species", _ data...

Data Validation in XL2007 suddenly stops functioning
I created a workbook in XL2003 that included some named ranges on Sheet2 that fed some data validation lists on Sheet1. Everything worked as expected. My colleague opened up the workbook in XL2007 and used it several times, and everything worked as expected. Then she called me, saying that it was broken. Of the 6 named ranges and related data validation columns on the other sheet, none of them were working anymore. I went over to her PC, and checked everything I could think of- I could set up working data validation test cells on Sheet2, but could not get the ones on Sheet1 to...

in what order should i place multiple brochure pages?
i am wondering in what order should i lay out my pages in my brochure so it will print correctly . . . I would use one of the brochure templates, create, print it out and edit to my liking. -- Don Vancouver, USA "critic" <critic@discussions.microsoft.com> wrote in message news:BB2EA24A-EC9F-44EB-AB02-209FF66A1F77@microsoft.com... >i am wondering in what order should i lay out my pages in my brochure so it > will print correctly . . . ...

Can multiple cell results be displayed in a single cell?
Is it possible to display the contents of multiple separate cells in another single cell? If the results of several cells say B1, B2, and B3 are the amounts $10, $15 and $20, I would like to display them in cell A1 as follows: $10 $15 $20 I could do this statically by using text and the 'Alt|Enter' function within the cell. However, these amounts will change from time to time so I'd like a link. Is this possible or not? Thanks for any help. Brett Brett One way: In A1: ="$"&B1&CHAR(10)&"$"&B2&CHAR(10)&"$"&B3&am...

Using Custom Properties
I want to use custom properties to capture process task data while documenting business processes. I am having problems understanding how to make it work. The desired outcome is that I define 8-10 fields in the shape on the stencil so that anytime I drag that shape to the drawing it has all 8-10 fields to be filled in. Currently I can drag a shape to the page, define fields FOR THAT ONE INSTANCE OF THE SHAPE, but I cannot figure out how to change the custom properties on the master shape in a way that ANY TIME I drag the shape to the page the custom properties come with it. Please Help! ...

Importing vcalendar data to multiple users
I'm running Exchange 5.5. Several times a year I have to create a large group of users. I'd like to be able to pre-populate each user's calendar with pertinent calendar events. Is there a way to import this type of data in batch mode? See if http://www.slipstick.com/calendar/holidays.htm#company helps. ME wrote: > I'm running Exchange 5.5. Several times a year I have to create a > large group of users. I'd like to be able to pre-populate each user's > calendar with pertinent calendar events. > > Is there a way to import this type of data in batch...

Worksheet Change Event log for multiple cells
Dear All, I have a spreadsheet that is available here: http://www.filefactory.com/file/b02e5h4/n/Worksheet_change_event.zip (although I scanned it for viruses please make sure you do it again prior to opening it as I cannot guarantee it's worm free). I would like to create a log file in an additional sheet (hidden probably) that would record every activity from column E after clicking a button assigned to a cell in that column and show these records in a worksheet Totals in a specific row. For example: Column A from a worksheet „Totals” corresponds with column A in ...

XML Schema Validation Question
Hello, How can I use XSD to ignore certain nodes of an XML document. Specifically, we have an event that I want to define using XSD. I then want to validate incoming XML events with that XSD. However, I want the payload section of the event to be freeform and thus, *NOT* validated. Is there a way to define a node (and all of it's contents) in an XSD so that the validator requires that the node exists, but does not attempt to validate the contents of the node? Example of the event: <MyEvent> <Header attribute1="true" attribute2="23"/> <Payl...

How move multiplicity labels in UML diagrams?
How can you move the multiplicity labels on lines in UML diagrams? Also, is it possible to move the name labels? ...

Using Excel error #N/A in a formula
I would like to capture the error message #N/A in an IF statement Would like to use IF(MATCH(C1,Range,0)=#N/A,"OK","STOP") but it does not seem to work. What is the correct syntax to capture the #N/A error message and display "OK" instead of #N/A? =IF(ISNA(MATCH(C1,Range,0)),"OK","STOP") HTH Jason Atlanta, GA >-----Original Message----- >I would like to capture the error message #N/A in an IF statement. > >Would like to use IF(MATCH(C1,Range,0)=#N/A,"OK","STOP") but it does not seem to work. What is the...

Fonts name using CDC
Hello, I am drawing text using CDC (MFC control). How can I know all the Fonts available? does anyone know the font list available (if so please, and it is not so long, please write it, or at least tell me how to get it) thanks! Mathieu "Mathieu Fregeau" <mathieu.fregeau@polymtl.ca> wrote in message news:fAg0b.670$HB4.154408@news20.bellglobal.com... > Hello, > > I am drawing text using CDC (MFC control). How can I know all the Fonts > available? does anyone know the font list available (if so please, and it is > not so long, please write it, or at least te...

Publisher should allow the deletion of multiple pages
I wish publisher would allow for the deletion of muliple pages much like the options available when printing pages. lejianzhong <lejianzhong@discussions.microsoft.com> was very recently heard to utter: > I wish publisher would allow for the deletion of muliple pages much > like the options available when printing pages. Suggestion: Try here: How to Contact the Microsoft Wish Program http://support.microsoft.com/default.aspx?scid=kb;en-us;Q114491 -- Ed Bennett - MVP Microsoft Publisher ...

How do I reformat a doc to eliminate an extra line between paras?
The document has an extra line between each para., and also the paras. are blocked. I want them indented. Creating and applying a new style does not solve the problem because the new style does not recognize [or "care"?] that these two aspects are different in the original format. I'm very frustrated @ this. Thank you for suggestions to try. mm If you click on the Show/Hide button ¶, do you see a ¶ between each of the paragraphs (in addition to the one at the end of the text) If so, use Edit>Replace to replace ^p^p by ^p That will get rid of the e...

How to Create a Grid using CEditView
Hello There, I have an MDI Application. one of the view need to be Editable that should display the contents in a grid format. The Grid should be editable and should also be a scrollable. how to do it. Plz Reply Me Fast Hi Sreeram, I had sent you a msg at codeguru.com informing you that i've made a sample for you. I think that you havent read that msg. yet. I'll send it to you now. Regards, V.Girish ...