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
- <?xml version="1.0" encoding="iso-8859-1" ?>
- <xs:schema targetNamespace="http://www.carlpaynephotography.com/catalog"
- xmlns:cat="http://www.carlpaynephotography.com/catalog"
- xmlns:xml="http://www.w3.org/XML/1998/namespace"
- xmlns:cd="http://www.carlpaynephotography.com/cdcatalog"
- xmlns:dvd="http://www.carlpaynephotography.com/dvdcatalog"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified">
- <xs:import namespace="http://www.carlpaynephotography.com/cdcatalog"
- schemaLocation="cdcatalog.xsd"/>
- <xs:import namespace="http://www.carlpaynephotography.com/dvdcatalog"
- schemaLocation="filmstore.xsd"/>
- <xs:element name="catalog" type="cat:catType" />
- <xs:complexType name="catType">
- <xs:sequence>
- <xs:element ref="cd:cdcatalog" maxOccurs="1"/>
- <xs:element ref="dvd:film_store" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
- </xs:schema>
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
- <?xml version="1.0" encoding="iso-8859-1"?>
- <?xml-stylesheet type="text/xsl" href="catalog.xslt"?>
- <catalog xmlns="http://www.carlpaynephotography.com/catalog">
- <cdcatalog xmlns="http://www.carlpaynephotography.com/cdcatalog">
- <album>
- <title>Are You Experienced</title>
- <artist>Jimi Hendrix</artist>
- <country>UK</country>
- <release>1997-04-28</release>
- <label>MCA</label>
- <genre>Blues Rock</genre>
- <price>9.99</price>
- <tracks>
- <track>
- <number>1</number>
- <title>Foxy Lady</title>
- </track>
- <track>
- <number>2</number>
- <title>Manic Depression</title>
- </track>
- <track>
- <number>3</number>
- <title>Red House</title>
- </track>
- <track>
- <number>4</number>
- <title>Can You See Me</title>
- </track>
- </tracks>
- </tracks>
- </album>
- </cdcatalog>
- <dvdcatalog xmlns="http://www.carlpaynephotography.com/dvdcatalog">
- <dvd>
- <title>A Beautiful Mind</title>
- <director>Ron Howard</director>
- <run_time>135 mins</run_time>
- <cert>12</cert>
- <studio>Dreamworks</studio>
- <year>2001</year>
- <rent_info>
- <rent_cost>£2.50</rent_cost>
- <copies>2</copies>
- <available>Yes</available>
- </rent_info>
- </dvd>
- </dvdcatalog>
- </catalog>
I know this is a LOT to read through but if anyone could offer any suggestions then please do!
Many thanks guys,
Carl