473,672 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating inherited types XML Schema

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 AnnouncementSte pType 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:Promp tID'. An error occurred at
, (11, 7).". If I add in <PromptID></PromptID> into the file, the
validation fails again, but this time with the message: "The active
schema does not support the element 'PromptID'." I've attempted to
add in <lh:PromptID /> with the same result.

Does anyone have any ideas on how I can get this to work in Visual
Studio? I've tried programmaticall y validating the document and that
fails horribly claiming that all elements are invalid.

Schema
-------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="urn:Test" xmlns:lh="urn:T est"
elementFormDefa ult="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="StepType" abstract="true" >
<xs:sequence>
<xs:element name="Type" />
<xs:element name="AssemblyL ocation" />
<xs:element name="Version" />
</xs:sequence>
</xs:complexType>
<xs:complexTy pe name="AnnounceS tepType">
<xs:complexCont ent>
<xs:extension base="lh:StepTy pe">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="PromptID"
type="xs:string " />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:element name="Module">
<xs:complexType >
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Name"
type="xs:string " />
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbo unded" name="Step"
type="lh:StepTy pe" />
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML Sample
-------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<Module xmlns:lh="urn:T est"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns="urn:Test ">
<Name>Test Module</Name>
<Step xsi:type="Annou nceStepType"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<Type>
</Type>
<AssemblyLocati on>
</AssemblyLocatio n>
<Version>
</Version>
</Step>
</Module>
Nov 12 '05 #1
2 1608
Dan,

The sample XML you posted validates fine for me in Visual Studio.

Did you add both, schema and document, to the Visual Studio project that you
have open?

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

"Dan Shookowsky" <sh*****@yahoo. com> wrote in message
news:c6******** *************** ***@posting.goo gle.com...
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 AnnouncementSte pType 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:Promp tID'. An error occurred at
, (11, 7).". If I add in <PromptID></PromptID> into the file, the
validation fails again, but this time with the message: "The active
schema does not support the element 'PromptID'." I've attempted to
add in <lh:PromptID /> with the same result.

Does anyone have any ideas on how I can get this to work in Visual
Studio? I've tried programmaticall y validating the document and that
fails horribly claiming that all elements are invalid.

Schema
-------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace ="urn:Test" xmlns:lh="urn:T est"
elementFormDefa ult="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="StepType" abstract="true" >
<xs:sequence>
<xs:element name="Type" />
<xs:element name="AssemblyL ocation" />
<xs:element name="Version" />
</xs:sequence>
</xs:complexType>
<xs:complexTy pe name="AnnounceS tepType">
<xs:complexCont ent>
<xs:extension base="lh:StepTy pe">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="PromptID"
type="xs:string " />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:element name="Module">
<xs:complexType >
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Name"
type="xs:string " />
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbo unded" name="Step"
type="lh:StepTy pe" />
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XML Sample
-------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<Module xmlns:lh="urn:T est"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns="urn:Test ">
<Name>Test Module</Name>
<Step xsi:type="Annou nceStepType"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<Type>
</Type>
<AssemblyLocati on>
</AssemblyLocatio n>
<Version>
</Version>
</Step>
</Module>

Nov 12 '05 #2
What version of Visual Studio.NET are you using? I'm confused because
when I choose "Validate XML Data" from the menu, the status text at the
bottom of the screen reads: "No Validation Errors were found" while the
PromptID tag is underlined in red and the task pane is saying that the
active schema doesn't recognize the element.

Both files are members of the same project.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

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

Similar topics

1
1798
by: Porthos | last post by:
Hello all, Is there a facet pattern that will allow for the inclusion of a newline or carriage return to occur within a tag? From the W3C schema document and from previous posts I've read that should take care of this situation, however when I include that pattern (and a newline\carriage return) I still recieve an error telling me that my data is an invalid value according to its data type. When I remove the returns and new lines the...
4
3088
by: billcoumbe | last post by:
any recommendations? I'm looking for something that will just run from the unix command line to validate large (20-50Mb) XML files against an XML DTD. Ideally something that is actively supported and has good documentation! If there's nothing suitable for Solaris a command line program for Windows might do - currently using XMetaL/XMLSpy parsers which aren't really suited to large files.
6
2416
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting is not absolutely wonderful. So what I want to do is to validate it before I upload it. When I try and do this I get MILLIONS of errors (well lots) complaining about elements like ROOT which are part of the
1
2970
by: Andy | last post by:
I am having some trouble validating XML using the XmlValidatingReader. I have created some xml and used the visual studio to generate the schema. So I am confident that the xml and schema match. The problem I am having is that the validation event fires for each node in the xml. It seems to be completely ignoring the schema that I have used. I'm wondering if I need to do something extra to tell the xml which schema to use.
2
2634
by: Joris Janssens | last post by:
I'm trying to write a program for validating XHTML 1.1-documents against the XHTML 1.1 DTD (which is actually the same as validating an XML-file) but I always get a "(404) Not found" error. This is the program itself : ******************************************************************** using System; using System.Xml; using System.Xml.Schema;
1
5982
by: Brendon | last post by:
I have 2 Xsd's The one contains basic type definitions <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:simpleType name="TrueFalse"> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="true"/>
1
4228
by: Craig Beuker | last post by:
Hello, I am experimenting with this XmlValidatingReader and have a question about how it is working (or not working as would be the case) The sample documents and code are included at the end of the post. I am using VS.net 2003, .Net 1.1, Win2k Server I have a simple schema and a simple XML document.
2
4490
by: Ian | last post by:
I've inherited some xml that doesn't have a namespace and doesn't have a reference to the schema. The schema doesn't have a targetNamespace attribute. I'm trying to build a test tool, in C#, which will send the xml to the server and then validate the response against the schema. When I try and do this I get a "The attribute targetNamespace does not match the designated namespace URI" error. Here's a snippet of the validation code: ...
0
3594
by: Patrick Brunmayr | last post by:
Hello I have a big Problem with validating a Soap Envelope. I have downloaded the xsd for a soap envelope from http://schemas.xmlsoap.org/soap/envelope/ The validation succeeds as lonng as i don't use elements in body with a xsi:type attribute! The Problem is that foo:person is an abstract type and foo:driver is dervived from it. So using a foo:person is not allowed until specifing
0
8486
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
8404
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
8931
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
8828
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
8680
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...
1
6238
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
4227
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...
2
2063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.