Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing local schema

Status
Not open for further replies.

fawkes

Technical User
Sep 12, 2003
343
GB
I'm struggling with referencing a schema from an xml file.

I must admit that, no matter how much I read on namespaces I don't get it all, quite often there is too much information missing, to high a level of assumption on the readers knowledge and a lack of real world examples.

What I have is as below:

Schema

Code:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="[URL unfurl="true"]http://www.mycompany.com"[/URL] elementFormDefault="qualified" xmlns="[URL unfurl="true"]http://www.mycompany.com"[/URL]         xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
	<xs:element name="TopLevelElement">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="LowLevelElement">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Item1" type="xs:double" />
							<xs:element name="Item2" type="xs:double" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>

XML

Code:
<?xml version="1.0" encoding="utf-8" ?>
<TopLevelElement xmlns="[URL unfurl="true"]http://www.mycompany.com/myschema.xsd">[/URL]
</TopLevelElement>
 
Just one other point, the schema and xml file are in the same directory/folder location.
 
[ponder][sad][ponder][sad][ponder]

I could do with some help with this, most of the information I can find takes the view that you understand what they're saying and they don't really offer enough real examples to see how things work in practice.

[ponder][sad][ponder][sad][ponder]
 
I'm suffering exactly the same problem.
All I want to do is use my local copy of my .XSD Schema file. Not on a server, not at any Namespace, here on my local C; Drive. I can find nothing on the internet or in books to spell out how to do this for me.

Everything is all about namespaces which I'm not completley following.
If anyone can help me and fawkes out, that would be useful.
Fawkes if you've solved or solve your problem would you be kind enough to post, I'll return the favour.

Many Thanks


Martin King
 
Just been through the Tek-tips XML Faqs although I haven't found a direct solution there is a very good one on Namespaces faq426-5637. I think I may have enough now to solve, Tek Tips do it again :) I'll post if I find my solution.

Martin
 
Luther,

I did solve it.

Here's an example from a site I'm writing

Code:
<?xml version="1.0" encoding="UTF-8"?>
<CountryCodes xmlns="[URL unfurl="true"]http://www.mountainbike.host.sk"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xsi:schemaLocation="[URL unfurl="true"]http://www.mountainbike.host.sk[/URL] countryCodes.xsd ">

It's the schemaLocation attribute that tells your xml file where it is.

The location goes
Code:
[red]xsi:schemaLocation=[/red]"[blue]namespace[/blue] {leave a blank space between sections} [green]filepath[/green]"
 
My apologies for not replying to my own post.

[blush][wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top