473,688 Members | 3,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Schema and document in Visual Studio

I'm trying to create a simple Schema and associated document in Visual
Studio that will store information regarding units and conversion (meters,
feet, inches, degrees C, F, K, etc.)

I create a schema and then add a new XML document, set the reference to the
schema and start typing in the data in Visual Studio's "data view" window
which seems to work fine. But then I view the document in XML view and
Visual Studio indicates an error in the root node of the document saying the
active schema doesnt support the element 'xsUnits'. What gives with this? I
would expect errors if I had manually changed something :-) but not just
from creating the schema and creating the dataset using VS tools. I've
attached the schema and xml data below.

Thanks

Dave

<?xml version="1.0" encoding="utf-8" ?>

<xs:schema id="xsUnits" targetNamespace ="http://tempuri.org/xsUnits.xsd"
elementFormDefa ult="qualified"

xmlns="http://tempuri.org/xsUnits.xsd"
xmlns:mstns="ht tp://tempuri.org/xsUnits.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">

<xs:simpleTyp e name="nameType" >

<xs:restricti on base="xs:string ">

<xs:maxLength value="50" />

<xs:minLength value="1" />

</xs:restriction>

</xs:simpleType>

<xs:element name="quantity" >

<xs:complexType >

<xs:sequence>

<xs:element name="name" type="nameType" />

<xs:element name="baseUnit" type="nameType" />

<xs:element name="unit">

<xs:complexType >

<xs:sequence>

<xs:element name="uid" type="xs:ID" msdata:AutoIncr ement="true"
msdata:AutoIncr ementSeed="1"

msdata:AutoIncr ementStep="1" />

<xs:element name="name" type="nameType" />

<xs:element name="abbrev" type="xs:string " />

<xs:element name="factor" type="xs:float" />

<xs:element name="offset" type="xs:float" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

<?xml version="1.0" encoding="utf-8" ?>

<xsUnits xmlns="http://tempuri.org/xsUnits.xsd"> ***** ERROR HERE *****

<quantity xmlns="http://tempuri.org/xsUnits.xsd">

<name>length</name>

<baseUnit>meter </baseUnit>

<unit>

<uid>1</uid>

<name>meter</name>

<abbrev>m</abbrev>

<factor>1</factor>

<offset>0</offset>

</unit>

<unit>

<uid>2</uid>

<name>foot</name>

<abbrev>ft</abbrev>

<factor>3.28</factor>

<offset>0</offset>

</unit>

<unit>

<uid>3</uid>

<name>inch</name>

<abbrev>in</abbrev>

<factor>39.37 </factor>

<offset>0</offset>

</unit>

<unit>

<uid>4</uid>

<name>centimete r</name>

<abbrev>cm</abbrev>

<factor>100</factor>

<offset>0</offset>

</unit>

</quantity>

<quantity>

<name>temperatu re</name>

<baseUnit>celsi us</baseUnit>

<unit>

<uid>5</uid>

<name>celsius </name>

<abbrev>°C</abbrev>

<factor>1</factor>

<offset>0</offset>

</unit>

<unit>

<uid>6</uid>

<name>farenheit </name>

<abbrev>°F</abbrev>

<factor>1.8</factor>

<offset>32</offset>

</unit>

</quantity>

</xsUnits>
Nov 12 '05 #1
1 3114
You don't have a top-level element xsUnits defined in your schema. According
to the schema you posted only <quantity> top-level elements are allowed..

Your instance document has an <xsUnits> root element.

--
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor

"Dave Taylor" <no*********@pr ocesseng.com> wrote in message
news:uT******** ******@TK2MSFTN GP12.phx.gbl...
I'm trying to create a simple Schema and associated document in Visual
Studio that will store information regarding units and conversion (meters,
feet, inches, degrees C, F, K, etc.)

I create a schema and then add a new XML document, set the reference to the schema and start typing in the data in Visual Studio's "data view" window
which seems to work fine. But then I view the document in XML view and
Visual Studio indicates an error in the root node of the document saying the active schema doesnt support the element 'xsUnits'. What gives with this? I would expect errors if I had manually changed something :-) but not just
from creating the schema and creating the dataset using VS tools. I've
attached the schema and xml data below.

Thanks

Dave

<?xml version="1.0" encoding="utf-8" ?>

<xs:schema id="xsUnits" targetNamespace ="http://tempuri.org/xsUnits.xsd"
elementFormDefa ult="qualified"

xmlns="http://tempuri.org/xsUnits.xsd"
xmlns:mstns="ht tp://tempuri.org/xsUnits.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">

<xs:simpleTyp e name="nameType" >

<xs:restricti on base="xs:string ">

<xs:maxLength value="50" />

<xs:minLength value="1" />

</xs:restriction>

</xs:simpleType>

<xs:element name="quantity" >

<xs:complexType >

<xs:sequence>

<xs:element name="name" type="nameType" />

<xs:element name="baseUnit" type="nameType" />

<xs:element name="unit">

<xs:complexType >

<xs:sequence>

<xs:element name="uid" type="xs:ID" msdata:AutoIncr ement="true"
msdata:AutoIncr ementSeed="1"

msdata:AutoIncr ementStep="1" />

<xs:element name="name" type="nameType" />

<xs:element name="abbrev" type="xs:string " />

<xs:element name="factor" type="xs:float" />

<xs:element name="offset" type="xs:float" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

<?xml version="1.0" encoding="utf-8" ?>

<xsUnits xmlns="http://tempuri.org/xsUnits.xsd"> ***** ERROR HERE *****

<quantity xmlns="http://tempuri.org/xsUnits.xsd">

<name>length</name>

<baseUnit>meter </baseUnit>

<unit>

<uid>1</uid>

<name>meter</name>

<abbrev>m</abbrev>

<factor>1</factor>

<offset>0</offset>

</unit>

<unit>

<uid>2</uid>

<name>foot</name>

<abbrev>ft</abbrev>

<factor>3.28</factor>

<offset>0</offset>

</unit>

<unit>

<uid>3</uid>

<name>inch</name>

<abbrev>in</abbrev>

<factor>39.37 </factor>

<offset>0</offset>

</unit>

<unit>

<uid>4</uid>

<name>centimete r</name>

<abbrev>cm</abbrev>

<factor>100</factor>

<offset>0</offset>

</unit>

</quantity>

<quantity>

<name>temperatu re</name>

<baseUnit>celsi us</baseUnit>

<unit>

<uid>5</uid>

<name>celsius </name>

<abbrev>°C</abbrev>

<factor>1</factor>

<offset>0</offset>

</unit>

<unit>

<uid>6</uid>

<name>farenheit </name>

<abbrev>°F</abbrev>

<factor>1.8</factor>

<offset>32</offset>

</unit>

</quantity>

</xsUnits>

Nov 12 '05 #2

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

Similar topics

2
1613
by: Dan Shookowsky | last post by:
I'm trying to write a schema that allows me to substitute entensions for a base type. The schema (included below) defines a StepType and an AnnouncementStepType that is an extension of the base type. Unfortunately, my XML example fails validation. When I omit PromptID, the Visual Studio Taskpane reads: "The element 'urn:Test:Step' has incomplete content. Expected 'urn:Test:PromptID'. An error occurred at , (11, 7).". If I add in...
2
10754
by: Vagabond Software | last post by:
I have translated a DTD to an XML Schema (XSD) file by hand, and the Schema View in Visual Studio .NET 2003 seems to diplay everything properly. However, when I specify the schemalocation in my xml files, VS.NET still reports that no schema could be located. Here are the relevant (maybe) portions of the files: FROM THE SCHEMA FILE (mydoc-v2.xsd) <?xml version="1.0" encoding="utf-8" ?> <xs:schema...
4
2499
by: Iain A. Mcleod | last post by:
Hi I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema: project and projectCollection. A projectcollection is just a set of projects. Therefore, I wish to include the project customType in the projectCollection namespace. I therefore have declared two xsd documents: project.xsd and projectcollection.xsd
2
1889
by: David Slinn | last post by:
I have created a simple XML document, generated a schema from it (which Visual Studio makes everything a string element). I then went through and changed all fields that are dates to the Date data type. Now, when I use the datagrid to edit the data in the XML file and then switch back to the raw XML text date, the dates are formatted like this "1973-10-27T00:00:00.0000000-06:00" and not as I expected, which are supposed to be a simple...
6
4430
by: LesleyW | last post by:
Hi Apologies if this is a really dumb question, but being new to XML and Schemas, I wonder if giving the namespace for eg xsd or xsi as a website address means that the user has to be online when they run the app? If so, what should I do if I can't guarantee that they will be? Can I bring all these files into the app? Is that desirable? I'm about to write an app that takes an XML file as input, using Visual Studio 2005 Express and SQL...
0
1574
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema' referenced in this document. The value for the 'base' attribute is invalid - 'xsd:string' is an invalid value for the 'base' attribute. An error occured at the file:///C:Program Files/Microsoft Visual Studio .NET 2003...
1
376
by: Chris Lieb | last post by:
I am new to XML Schema and am running into a bit of a snag. I have defined an XML-based scripting language for an updater program that I am working on. I would like to make a schema for this language since malformed XML documents break the updater. (I did not have time to add good error-handling code, so run-time errors can abound if the document is malformed.) A sample doc might look something like this: <manifest>
0
1473
by: jackfrancy | last post by:
Hi , When I tried to create web reference (Proxy Class) from WSDL.EXE or Visual Studio 2003 web Reference Tool Following error has occurred . “The error message from each known type may help you fix the problem: - A schema with the namespace 'http://www.opentravel.org/OTA/2003/05' has alre ady been added. - The document format is not recognized. - Report from 'XML Schema' is 'Expected Schema root. Make sure that the root ele ...
6
4000
by: Andy B | last post by:
I have the following schema. I need to know how to make an xml document based from it. The main worry I have is the DateTime field. <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="NewsArticle">
0
8590
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
9072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8786
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
7621
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
6453
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
5807
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
4321
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
4547
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2215
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.