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

XML Schema: How to put restrictions on element names

Hi there,

I want to set up an XML Schema for documents of the following
structure:

The <root> node contains
- an optional <message> element with a text attribute, and
- arbitrary further content.

To make the parts unique, the top-level element of the further content
must not have the name "message". Therefore, this further content is
not completely arbitrary, but there is a restriction on the element
name.

Examples:

<root>
<message text="Hi there"/>
<purchaseOrder number="4711">
<item number="10" matnr="4033871" qty="10"/>
</purchseOrder>
</root>

<root>
<message text="Only message"/>
</root>

<root>
<!-- only further content -->
<part number="10">
<option key="10" text="First option"/>
<option key="20" text="Second option"/>
</part>
</root>

In an imagined, non-existing XML Schema syntax, the further
content should be defined somehow like

<xs:restriction refType="xs:any">
<xs:condition test="local-name()!='message'"/>
</xs:restriction>

Since I don't know how to do such a thing in the existing
XML-Schema language, I tried to use <xs:any> without restrictions.
But this didn't pass the XSD Validator, due to the non-uniqueness
of a possible message element:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="message" minOccurs="0" maxOccurs="1">
<xs:complexType>
<!-- leaving out attribute definitions for simplicity... -->
</xs:complexType>
</xs:element>
<xs:any minOccurs="0" processContents="skip"/>
<!-- ^^^^^ For this part, we need a restriction on the element
name!!! -->
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Any suggestion how to define arbitrary elements
with restricted element name in XML Schema???

Thanks
Ruediger

May 6 '06 #1
0 1308

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

Similar topics

3
by: Kimmo J?rvikangas | last post by:
Dear XML (Schema) experts, As an example I have the following schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"...
0
by: Joyce | last post by:
The XML Schema design problem to solve is as follows: We have 2 combo boxes to populate from schema data, let's say: 1. States 2. Cities (and this one gets populated depending on the choice of...
1
by: obsolete_5 | last post by:
is it possible? more specifically, a simple example: i want a 'table' element to have a sequence of 'entry' elements. i know you can use minOccur = maxOccur = x, to enforce table to have x...
3
by: Andrew Ducker | last post by:
I have an XML document and a schema. It validates fine, but when I try to switch to data view there's a problem. So I tried "Create Schema" and got the error: An error occurred while loading the...
0
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
1
by: shakuf | last post by:
hi i would like to define a type with restrictions, i used the following schema but i get an error <xs:element name="Latitude"> <xs:complexType> <xs:simpleContent> <xs:extension...
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
2
by: Mike | last post by:
Hi! I have an Excel 2003 Schema I need to parse to extract elements names. I am puzzled which System.Xml object can help me. Here's the example of my schema: I need to get a collection of...
1
by: Robert Mago | last post by:
I have an xml document instance in C# which loads an xml schema. I would like to load the restrictions for a complex type in the schema so that the user will choose one, from a drop down list for...
1
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.