473,729 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing schemas: Cannot resolve the name to a(n) 'element declaration

4 New Member
Hi all,

I'm fairly new to XML, however already I have studied myself stupid without being able to solve this problem. Basically, I have an XML file/Schema about a CD catalog that I've created that I want to combine with an XML/Schema that a friend has created. Both XML files/Schema validate individually.

Now comes the tricky part, combining them. I've created a new XML file and schema, called catalog.xml and catalog.xsd. Into the catalog.xml file has gone all the XML from both files, using namespaces to seperate each of them (the overall catalog, the cd catalog and the dvd catalog). Because this new file is a combination of two existing files, I want to simply reference the schemas for each, minimising code reproduction. Therefore, my schema for catalog looks like this:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1" ?>
  2. <xs:schema targetNamespace="http://www.carlpaynephotography.com/catalog"
  3.   xmlns:cat="http://www.carlpaynephotography.com/catalog" 
  4.   xmlns:xml="http://www.w3.org/XML/1998/namespace" 
  5.   xmlns:cd="http://www.carlpaynephotography.com/cdcatalog"
  6.   xmlns:dvd="http://www.carlpaynephotography.com/dvdcatalog"
  7.   xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  8.   elementFormDefault="qualified"
  9.   attributeFormDefault="unqualified">
  10.   <xs:import namespace="http://www.carlpaynephotography.com/cdcatalog"
  11.   schemaLocation="cdcatalog.xsd"/>
  12.   <xs:import namespace="http://www.carlpaynephotography.com/dvdcatalog"
  13.   schemaLocation="filmstore.xsd"/>
  14.  
  15.   <xs:element name="catalog" type="cat:catType" />
  16.   <xs:complexType name="catType">
  17.       <xs:sequence>
  18.         <xs:element ref="cd:cdcatalog"  maxOccurs="1"/>
  19.         <xs:element ref="dvd:film_store" maxOccurs="1"/>
  20.       </xs:sequence>
  21.     </xs:complexType>
  22. </xs:schema>
  23.  
Essentially, I am trying to say that this new overall catalog contains an instance of cdcatalog and an instance of film_store. However, using the decisionsoft online validator, I get the following problems:

Validation 25, 56 src-resolve: Cannot resolve the name 'cd:cdcatalog' to a(n) 'element declaration' component.
Validation 27, 57 src-resolve: Cannot resolve the name 'dvd:film_store ' to a(n) 'element declaration' component.
Validation 7, 68 cvc-complex-type.2.4.d: Invalid content was found starting with element 'cdcatalog'. No child element is expected at this point.

Any ideas what I can do to fix all of this? I feel like I am so close to making everything work. The rest of my code is below:

catalog.xml
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <?xml-stylesheet type="text/xsl" href="catalog.xslt"?>
  3.  
  4. <catalog xmlns="http://www.carlpaynephotography.com/catalog">
  5.   <cdcatalog xmlns="http://www.carlpaynephotography.com/cdcatalog">
  6.         <album>
  7.             <title>Are You Experienced</title>
  8.             <artist>Jimi Hendrix</artist>
  9.             <country>UK</country>
  10.             <release>1997-04-28</release>
  11.             <label>MCA</label>
  12.             <genre>Blues Rock</genre>
  13.             <price>9.99</price>
  14.             <tracks>
  15.                 <track>
  16.                     <number>1</number>
  17.                     <title>Foxy Lady</title>
  18.                 </track>
  19.                 <track>
  20.                     <number>2</number>
  21.                     <title>Manic Depression</title>
  22.                 </track>
  23.                 <track>
  24.                     <number>3</number>
  25.                     <title>Red House</title>
  26.                 </track>
  27.                 <track>
  28.                     <number>4</number>
  29.                     <title>Can You See Me</title>
  30.                 </track>
  31.             </tracks>
  32.             </tracks>
  33.         </album>
  34. </cdcatalog>
  35.     <dvdcatalog xmlns="http://www.carlpaynephotography.com/dvdcatalog">
  36.         <dvd>
  37.             <title>A Beautiful Mind</title>
  38.             <director>Ron Howard</director>
  39.             <run_time>135 mins</run_time>
  40.             <cert>12</cert>
  41.             <studio>Dreamworks</studio>
  42.             <year>2001</year>
  43.             <rent_info>
  44.                 <rent_cost>£2.50</rent_cost>
  45.                 <copies>2</copies>
  46.                 <available>Yes</available>
  47.             </rent_info>
  48.         </dvd>
  49. </dvdcatalog>
  50. </catalog>
  51.  


I know this is a LOT to read through but if anyone could offer any suggestions then please do!

Many thanks guys,

Carl
Apr 26 '07 #1
5 40930
carlpayne1984
4 New Member
The XML for cdcatalog.xml and film_store.xml is identical to the above, the schemas for each are:

cdcatalog.xsd
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1" ?>
  2. <xs:schema targetNamespace="http://www.carlpaynephotography.com/cdcatalog" 
  3.   xmlns:xml="http://www.w3.org/XML/1998/namespace" 
  4.   xmlns:cd="http://www.carlpaynephotography.com/cdcatalog" 
  5.   xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  6.   elementFormDefault="qualified"
  7.   attributeFormDefault="qualified">
  8.  
  9.   <xs:element name="title" type="xs:string"/>
  10.   <xs:element name="artist" type="xs:string"/>
  11.   <xs:element name="country" type="xs:string"/>
  12.   <xs:element name="release">
  13.     <xs:simpleType>
  14.       <xs:restriction base="xs:date">
  15.         <xs:minInclusive value="1900-01-01"/>
  16.       </xs:restriction>
  17.     </xs:simpleType>
  18.   </xs:element>
  19.   <xs:element name="label" type="xs:string"/>
  20.   <xs:element name="genre" type="xs:string"/>
  21.   <xs:element name="price">
  22.     <xs:simpleType>
  23.       <xs:restriction base="xs:decimal">
  24.         <xs:maxInclusive value="99.99"/>
  25.         <xs:fractionDigits value="2" />
  26.       </xs:restriction>
  27.     </xs:simpleType>
  28.   </xs:element>
  29.   <xs:element name="number" type="xs:positiveInteger"/>
  30.  
  31.   <xs:element name="track">
  32.     <xs:complexType>
  33.       <xs:sequence>
  34.         <xs:element ref="cd:number"/>
  35.         <xs:element ref="cd:title"/>
  36.         <xs:element ref="cd:artist" minOccurs="0"/>
  37.       </xs:sequence>
  38.     </xs:complexType>
  39.   </xs:element>
  40.  
  41.   <xs:element name="tracks">
  42.     <xs:complexType>
  43.       <xs:sequence>
  44.         <xs:element ref="cd:track" maxOccurs="unbounded"/>
  45.       </xs:sequence>
  46.     </xs:complexType>
  47.   </xs:element>
  48.  
  49.   <xs:element name="album">
  50.     <xs:complexType>
  51.       <xs:sequence>
  52.         <xs:element ref="cd:title"/>
  53.         <xs:element ref="cd:artist"/>
  54.         <xs:element ref="cd:country"/>
  55.         <xs:element ref="cd:release"/>
  56.         <xs:element ref="cd:label"/>
  57.         <xs:element ref="cd:genre"/>
  58.         <xs:element ref="cd:price"/>
  59.         <xs:element ref="cd:tracks"/>
  60.       </xs:sequence>
  61.     </xs:complexType>
  62.   </xs:element>
  63.  
  64.   <xs:element name="cdcatalog" type="cd:cdType" />
  65.   <xs:complexType name="cdType">
  66.       <xs:sequence>
  67.         <xs:element ref="cd:album" maxOccurs="unbounded"/>
  68.       </xs:sequence>
  69.     </xs:complexType>
  70. </xs:schema>
  71.  
Apr 26 '07 #2
carlpayne1984
4 New Member
filmstore.xsd
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1" ?>
  2. <xs:schema targetNamespace="http://www.carlpaynephotography.com/dvdcatalog" 
  3.   xmlns:xml="http://www.w3.org/XML/1998/namespace" 
  4.   xmlns:dvd="http://www.carlpaynephotography.com/dvdcatalog" 
  5.   xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  6.   elementFormDefault="qualified"
  7.   attributeFormDefault="qualified">
  8.  
  9. <!-- simple element definitions -->
  10. <xs:element name="title" type="xs:string" /> 
  11. <xs:element name="director" type="xs:string" /> 
  12. <xs:element name="run_time" type="dvd:run_time" /> 
  13. <xs:element name="cert" type="dvd:cert_type" /> 
  14. <xs:element name="studio" type="xs:string" /> 
  15. <xs:element name="year" type="dvd:year" /> 
  16. <xs:element name="rent_cost" type="dvd:rent_cost" />
  17. <xs:element name="copies" type="xs:positiveInteger" /> 
  18. <xs:element name="available" type="dvd:available" /> 
  19.  
  20. <xs:simpleType name="run_time">
  21.     <xs:restriction base="xs:string">
  22.         <xs:pattern value="\d+(\s)?(mins)" />
  23.     </xs:restriction>
  24. </xs:simpleType>
  25.  
  26. <xs:simpleType name="cert_type">
  27.     <xs:restriction base="xs:string">
  28.         <xs:enumeration value="Uc" />
  29.         <xs:enumeration value="U" />
  30.         <xs:enumeration value="PG" />
  31.         <xs:enumeration value="12A" />
  32.         <xs:enumeration value="12" />
  33.         <xs:enumeration value="15" />
  34.         <xs:enumeration value="18" />
  35.         <xs:enumeration value="18r" />
  36.     </xs:restriction>
  37. </xs:simpleType>
  38.  
  39. <xs:simpleType name="year">
  40.     <xs:restriction base="xs:integer">
  41.         <xs:pattern value="\d{4}" />
  42.     </xs:restriction>
  43. </xs:simpleType>
  44.  
  45. <xs:simpleType name="rent_cost">
  46.     <!-- based on type integer -->
  47.     <xs:restriction base="xs:string">
  48.         <xs:pattern value="£\d+.\d{2}" />
  49.     </xs:restriction>
  50. </xs:simpleType>
  51.  
  52. <xs:simpleType name="available">
  53.     <!-- based on type string -->
  54.     <xs:restriction base="xs:string">
  55.         <xs:enumeration value="No" />
  56.         <xs:enumeration value="no" />
  57.         <xs:enumeration value="Yes" />
  58.         <xs:enumeration value="yes" />
  59.     </xs:restriction>
  60. </xs:simpleType>
  61.  
  62. <xs:element name="rent_info">
  63.     <xs:complexType>
  64.         <xs:sequence>
  65.             <xs:element ref="dvd:rent_cost" /> 
  66.             <xs:element ref="dvd:copies" /> 
  67.             <xs:element ref="dvd:available" /> 
  68.         </xs:sequence>
  69.     </xs:complexType>
  70. </xs:element>
  71.  
  72. <xs:element name="dvd">
  73.     <xs:complexType>
  74.         <xs:sequence>
  75.             <xs:element ref="dvd:title" />
  76.             <xs:element ref="dvd:director" /> 
  77.             <xs:element ref="dvd:run_time" /> 
  78.             <xs:element ref="dvd:cert" /> 
  79.             <xs:element ref="dvd:studio" /> 
  80.             <xs:element ref="dvd:year" /> 
  81.             <xs:element ref="dvd:rent_info" />
  82.         </xs:sequence>
  83.     </xs:complexType>
  84. </xs:element>
  85.  
  86.   <xs:element name="film_store" type="dvd:dvdType" />
  87.   <xs:complexType name="dvdType">
  88.         <xs:sequence>
  89.             <xs:element ref="dvd:dvd" maxOccurs="unbounded" />
  90.         </xs:sequence>
  91.     </xs:complexType>
  92. </xs:schema>
  93.  
Apr 26 '07 #3
dorinbogdan
839 Recognized Expert Contributor
Welcome to TheScripts TSDN....

The code looks fine on a short overview (excepting that the XML file contains twice the </tracks> element, so one should be removed).

The Decision Soft Validator seems to load just one XSD schema (provided as input, catalog.xsd), and it simply doesn't load the other 2 (cdcatalog.xsd and filmstore.xsd).
Apr 27 '07 #4
carlpayne1984
4 New Member
Hi!

Thanks a lot for the reply, I was beginning to think I was going a bit nuts. The double </tracks> tag is just from me deleting out comments to make my post here shorter and leaving that by mistake, in the actual code it only exists once. Glad to hear that it's not my code which is at fault. Are there any better validation tools out there (either software or online) which do allow multiple schemas?

Nevertheless, thanks for the help, it's a big relief!

Carl
Apr 28 '07 #5
dorinbogdan
839 Recognized Expert Contributor
I didn't use it, but it's free and seems helpful: AltovaXml.
Apr 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
1504
by: Michael Mair | last post by:
Hello, in C89 (at least in the last public draft), "3.6.2 Compound statement, or block", we have ,--- | Syntax | | compound-statement: | { declaration-list<opt> statement-list<opt> }
1
6358
by: Random | last post by:
I don't understand why this error is happening when I try to load my xml into my DataSet. "Cannot add a nested relation or an element column to a table containing a SimpleContent column." Can anyone help direct me towards figuring out the cause. Yes, the xml is big, but not too complex.
1
4962
by: Hennesey | last post by:
Hello all, I am developing a Visual Studio .Net 2005 application that consumes an Axis 1.3 web service. Importing the WSDL file generates an error "cannot resolve apachesoap:Map type" What's wrong? Does the JAVA guy has to correct something?
5
7586
by: effendi | last post by:
I am trying to write a simple routine multiplying one value of a field to another. i.e cost1 multiple by cost2.. But since I have many lines of these, I want to write a function by accessing the "fieldname" and passing it to the function in the onChange event. For example, if I am in the cost1 field, I would like the onChange event to "retrieve" the field name so that I can pass it to the function.Besides feld names, each field also have...
5
2429
by: Bosconian | last post by:
I'm attempting to submit a form via a function which dynamically creates a hidden input: function submitLocation(theForm) { var e = document.createElement('input'); e.setAttribute('type', 'hidden'); e.setAttribute('name', 'location'); e.setAttribute('value', '1'); var f = document.getElementById(theForm); f.appendChild(e);
1
5997
by: ivanet | last post by:
Hello everyone, I am trying to use the following Schema but I get the error "src- resolve: Cannot resolve the name 'ValuesList' to a(n) 'element declaration' component." at line 144. I have been reading http://www.w3.org/TR/xmlschema-1/#src-resolve, but I don't get what is wrong. Can anyone give me a hint? Thanks in advance.
4
11233
by: Walton | last post by:
checkout: (3rd paragraph under 'Remarks' section) http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/name_2.asp from the page: "The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method." to work around this you have to code:
3
2273
by: vincentshiu | last post by:
I need to dynamic create input element in some cases, and I use javascript to do that, like the following code: .... var inputElement = document.createElement("input"); this.inputElement.name= "fieldName"; this.inputElement.type = "text"; this.inputElement.value = "somevalue"; ....
0
2657
by: mansooralia | last post by:
Hi, While reading an XML with DTD, I get the "Cannot add a nested relation or an element column to a table containing a SimpleContent column." error. Can anyone help me resolve this issue. I am running out of time. Thanks.
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9280
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...
0
8144
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
6722
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
6016
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
4525
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
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.