473,387 Members | 3,801 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,387 software developers and data experts.

XML Schema with unnkown Element names

Hi,

I need to validate a XML document where some of the element names are
unnknown.

<xs:any processContents="lax"/> or "skip" allows me to do so.

But: I want to validate those elements - the only thing unknown is the
name of the elements. Especially the attributes are well-known and
need to be validated.

a) Is there any option to use regExp with the name attribute?

b) Or any other way to describe elements with unnkonw names?

I cannot change the XML instance document.

Thanks! Mark

Example data:

<?xml version="1.0"?>
<root>
<WellKnown Type="TypeFromList" Name="anyName">
<UnknownA Type="TypeFromList" Width="200">
<UnknownChildA Type="String"/>
<UnknownChildB Type="String"/>
</UnknownA>
<UnknownB Type="TypeFromList" Width="200">
<UnknownChildC Type="Date"/>
<UnknownChildD Type="Currency"/>
</UnknownB>
</WellKnown>
<WellKnown Type="TypeFromList" Name="anyOtherName"/>
</root>

- how do I validate those Type-attributes of the Unnkown* elements?
Mar 20 '06 #1
2 1301
You can do it by using xsi:type in the instance as shown below:
<WellKnown xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UnknownA xsi:type="unKnownTypeWithAtt" Type="123">
<UnknownChildA Type="String" xsi:type="unKnownTypeWithAtt"/>
<UnknownChildB Type="345" xsi:type="unKnownTypeWithAtt"/>
</UnknownA>
</WellKnown>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="WellKnown" type="unKnownTypeWithAtt">
</xs:element>

<xs:complexType name="unKnownTypeWithAtt">
<xs:sequence>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Type" type="xs:int"/>
</xs:complexType>
</xs:schema>

There is no other way in XML Schema to describe elements with unknown names
except xs:any.

Thanks,
Priya

"Mark Doerbandt" <sp**********@doerbandt.de> wrote in message
news:dv**********@dit8.doerbandt.de...
Hi,

I need to validate a XML document where some of the element names are
unnknown.

<xs:any processContents="lax"/> or "skip" allows me to do so.

But: I want to validate those elements - the only thing unknown is the
name of the elements. Especially the attributes are well-known and
need to be validated.

a) Is there any option to use regExp with the name attribute?

b) Or any other way to describe elements with unnkonw names?

I cannot change the XML instance document.

Thanks! Mark

Example data:

<?xml version="1.0"?>
<root>
<WellKnown Type="TypeFromList" Name="anyName">
<UnknownA Type="TypeFromList" Width="200">
<UnknownChildA Type="String"/>
<UnknownChildB Type="String"/>
</UnknownA>
<UnknownB Type="TypeFromList" Width="200">
<UnknownChildC Type="Date"/>
<UnknownChildD Type="Currency"/>
</UnknownB>
</WellKnown>
<WellKnown Type="TypeFromList" Name="anyOtherName"/>
</root>

- how do I validate those Type-attributes of the Unnkown* elements?

Mar 20 '06 #2
Thanks, Priya,

Priya Lakshminarayanan:
You can do it by using xsi:type in the instance
for your response.
I cannot change the XML instance document.


Unfortonately I'd have to change the instance for that - and I'm not
able to do so.
There is no other way in XML Schema to describe elements
with unknown names except xs:any.


OK - so I'll have to talk to my customer so /they'll/ change the
schema.

Mark
Mar 22 '06 #3

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

Similar topics

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...
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...
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: Mike | last post by:
Hi! I have an Excel 2003 Schema I need to parse to extract elements names. I am puzzled with the System.Xml.Schema object. Here's the example of my schema: I need to get a collection of element...
16
by: Brad Wood | last post by:
I'm using a 2.0 XmlReaderSettings object with setting.ValidationType set to ValdationType.Schema to validate a document against a schema. Following is a schema fragment (names altered):...
0
by: ruediger | last post by:
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...
1
by: Ganesh Muthuvelu | last post by:
Hello, I have a simple schema as shown below. When I validate it, I get the error "Type 'http://www.w3.org/2001/XMLSchema:emptype' is not declared. An error occurred at , (6, 12)." ...
1
by: mflll | last post by:
How does one say in one schema that one wants an element defined in another schema. For example, I want to include in the Employee definition, an Address element defined in the schema...
1
by: Nichino | last post by:
Hello, I'm trying to define my first Xml Schema and have a problem. The XML I'd like to define through the Schema is the following one. Can you help me please? I don't know how to insert the 3...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.