473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

XSD Restricting Anytype behaviour

Can anyone explain how I can do the following correctly:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="e"/>
<xs:complexType name="ct1">
<xs:choice>
<xs:any namespace="##any"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="ct2">
<xs:complexContent>
<xs:restriction base="ct1">
<xs:choice>
<xs:element name="e1"/>
<xs:element name="e2"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

This actually validates ok within XMLSpy within itself, it is just when I
try to validate the following document against it I get the error: "The
content model of complex type ct2 is not a valid restriction of the content
model of complex type ct1

<?xml version="1.0" encoding="UTF-8"?>
<e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="RestrictingAnytype. xsd"/>

What I would ultimately like to do is express that children of ct1 will only
be of a certain type (in another namespace), but there could be a varying
amount of children. I suppose in programming terms I am looking to express a
typed container.

Is there no way to do this using XSD?

Thanks for any help!
-=- Brett
Jul 20 '05 #1
1 1421
Sorry I copied the wrong version, please make the ct1\anyType unbounded to
see the problem as in the following.

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:element name="e"/>

<xs:complexType name="ct1">

<xs:choice>

<xs:any namespace="##any" maxOccurs="unbounded"/>

</xs:choice>

</xs:complexType>

<xs:complexType name="ct2">

<xs:complexContent>

<xs:restriction base="ct1">

<xs:choice>

<xs:element name="e1"/>

<xs:element name="e2"/>

</xs:choice>

</xs:restriction>

</xs:complexContent>

</xs:complexType>

</xs:schema>
"Brett Gerhardi" <br************@nildram.net> wrote in message
news:fO********************@pipex.net...
Can anyone explain how I can do the following correctly:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="e"/>
<xs:complexType name="ct1">
<xs:choice>
<xs:any namespace="##any"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="ct2">
<xs:complexContent>
<xs:restriction base="ct1">
<xs:choice>
<xs:element name="e1"/>
<xs:element name="e2"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

This actually validates ok within XMLSpy within itself, it is just when I
try to validate the following document against it I get the error: "The
content model of complex type ct2 is not a valid restriction of the
content model of complex type ct1

<?xml version="1.0" encoding="UTF-8"?>
<e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="RestrictingAnytype. xsd"/>

What I would ultimately like to do is express that children of ct1 will
only be of a certain type (in another namespace), but there could be a
varying amount of children. I suppose in programming terms I am looking to
express a typed container.

Is there no way to do this using XSD?

Thanks for any help!
-=- Brett

Jul 20 '05 #2

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

Similar topics

1
by: Igor Akkerman | last post by:
Hi, why does <xs:element name="any" type="xs:anyType" /> not validate <any><foo><bar>blah</bar></foo></any> ?
0
by: Sonna Nach | last post by:
Hi All, I am writing a doc/lit web services, in which the elements under SOAPBody is unknown. That is, these two message are acceptable. 1. <SOAP-ENV:Body><Tag1>It is ok</Tag1></SOAP-ENV:Body>...
0
by: maersa | last post by:
Hi all, i'm serializing an arraylist like the following with an "Role" object as it's item. ----------------------------------------------------- ---- ArrayList ar = new ArrayList();...
1
by: Achim Domma (SyynX Solutions GmbH) | last post by:
Hi, I have a data structure which is serialzied into an xml like this: <?xml version="1.0" encoding="utf-8"?> <Storage xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
1
by: Sebastian Mark | last post by:
Did anyone got error like that? When I'm trying to Update WebReference in my project this is an error I'm getting "Custom tool error: Failed to generate dataset. Undefined data type:...
0
by: lonnie.lewis | last post by:
Hi all, I'm a consumer of a web service which is defining an output parameter as an "xsd:anyType": <message name="MyTransaction.IsWebServicesDataValid"> ... <part name="varDisplayMessage"...
1
by: JonBeatty | last post by:
I am trying to serialize a class derived from ArrayList called JobQueue that contains an array of objects of the class Job. Using XmlSerializer I can get this to serialize successfully, but I am...
3
by: Rotsey | last post by:
Hi, I am ceating a xml file from SQL data using VS2003. I want to then use xslt to transform xml to my web page. But the xml file when after serialisation has some nodes like this <anyType...
2
by: WittyGuy | last post by:
Hi My class looks something like this: class Base { public: Base () {} ~Base () {} // No virtual dtor in the base class private: };
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.