473,320 Members | 1,916 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,320 software developers and data experts.

XSD: How to allow an element withjany name but require it to have certain attributes

I want to create a schema element that will allow any element as a child but
that child must contain specified attributes

This example doesn't work but it might give an idea of what I need to do.

<xs:element name="???">
<xs:complexType>
<xs:attribute name="attrOne" type="xs:string" use="required" />
<xs:attribute name"attrTwo" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="parent_element">
<xs:complexType>
<xs:sequence>
<xs:element ref="???" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

This file should be valid

<parent_element>
<hello attrOne="world" attrTwo="planet"/>
<kitty attrOne="cat" attrTwo="feline"/>
</parent_element>

This file should be invalid

<parent_element>
<hello/>
<kitty/>
</parent_element>

I can accomplish the any child element part

<xs:element name="parent_element">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

But this will not force the elements to have the attributes I need.

Robert Zurer
Jul 20 '05 #1
2 1748
<xs:complexType name="anyPlusAttrsType">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="att1" type="xs:string" use="required"/>
<xs:attribute name="att2" type="xs:string" use="required"/>
</xs:complexType>
<xs:element name="foo" type="anyPlusAttrsType"/>

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Robert Zurer" <ro**********@zurer.com> wrote in message
news:MP************************@news.speakeasy.net ...
I want to create a schema element that will allow any element as a child
but
that child must contain specified attributes

This example doesn't work but it might give an idea of what I need to do.

<xs:element name="???">
<xs:complexType>
<xs:attribute name="attrOne" type="xs:string" use="required" />
<xs:attribute name"attrTwo" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="parent_element">
<xs:complexType>
<xs:sequence>
<xs:element ref="???" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

This file should be valid

<parent_element>
<hello attrOne="world" attrTwo="planet"/>
<kitty attrOne="cat" attrTwo="feline"/>
</parent_element>

This file should be invalid

<parent_element>
<hello/>
<kitty/>
</parent_element>

I can accomplish the any child element part

<xs:element name="parent_element">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

But this will not force the elements to have the attributes I need.

Robert Zurer

Jul 20 '05 #2
In article <42********@news.microsoft.com>, sk***@microsoft.com says...
<xs:complexType name="anyPlusAttrsType">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="att1" type="xs:string" use="required"/>
<xs:attribute name="att2" type="xs:string" use="required"/>
</xs:complexType>
<xs:element name="foo" type="anyPlusAttrsType"/>

It's obvious that I need to do some more reading on the basics.

Thanks so much for your response.
Robert Zurer
Jul 20 '05 #3

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

Similar topics

2
by: Victor Engmark | last post by:
I am making an XML Schema for emails, and would like to specify that any elements from the XHTML2 namespace are allowed in the body/contents and signature/footer parts of the message (and _only_...
2
by: Stewart Johnson | last post by:
Hey All - I'm stuck while trying to write a schema, hoping someone can provide me with a flash of inspiration. One of the elements I'm writing has two attributes, both of which are optional....
2
by: monsterpot | last post by:
Hello, I have a document like this: <parameters> <param ptype="init">somedata</param> <param ptype="process">moredata</param> <param ptype="kill">alsodata</param> </parameters> <param> has...
1
by: harry | last post by:
Hello, not certain if this should go here or ado.net but I'm trying to create an XSD on the fly (due to the fact that our dataaccess component is a legacy component which returns data in an...
1
by: Steve Morrell | last post by:
Hi there, I have a C# object heirarchy and an XSD document to which I wish to match the serialized objects in that heirarchy. I have an abstract parent class called "Test" which has no...
3
by: man-in-nature | last post by:
Hello, I have already read several existing posts about xsd:extension, but do not find something useful to my test case. I have one xml file and one xsd file. I can use a simple command line...
0
by: vissuyk | last post by:
Hi, I am new to xsd, any help is greatly appreciated. I will have customers define xsd. In there they will designate an attribute to be of certian type (e.g some:transid). When I see this in...
6
by: RickH | last post by:
Hello, I would like to create a user XSD data type that inherits from the w3 standard data type called ID to make sure a certain repeated element always contains distinct values. The problem is...
4
by: BorisBoshond | last post by:
Hi all, Hope someone is able and willing to help me with following problem. I received a xsd file from another company, our company i supposed to return xml based on that xsd. Problem is that I...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.