473,783 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="TypeFromL ist" Name="anyName">
<UnknownA Type="TypeFromL ist" Width="200">
<UnknownChild A Type="String"/>
<UnknownChild B Type="String"/>
</UnknownA>
<UnknownB Type="TypeFromL ist" Width="200">
<UnknownChild C Type="Date"/>
<UnknownChild D Type="Currency"/>
</UnknownB>
</WellKnown>
<WellKnown Type="TypeFromL ist" Name="anyOtherN ame"/>
</root>

- how do I validate those Type-attributes of the Unnkown* elements?
Mar 20 '06 #1
2 1321
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="unKno wnTypeWithAtt" Type="123">
<UnknownChild A Type="String" xsi:type="unKno wnTypeWithAtt"/>
<UnknownChild B Type="345" xsi:type="unKno wnTypeWithAtt"/>
</UnknownA>
</WellKnown>

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

<xs:complexTy pe name="unKnownTy peWithAtt">
<xs:sequence>
<xs:any processContents ="lax" minOccurs="0" maxOccurs="unbo unded"/>
</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**********@d oerbandt.de> wrote in message
news:dv******** **@dit8.doerban dt.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="TypeFromL ist" Name="anyName">
<UnknownA Type="TypeFromL ist" Width="200">
<UnknownChild A Type="String"/>
<UnknownChild B Type="String"/>
</UnknownA>
<UnknownB Type="TypeFromL ist" Width="200">
<UnknownChild C Type="Date"/>
<UnknownChild D Type="Currency"/>
</UnknownB>
</WellKnown>
<WellKnown Type="TypeFromL ist" Name="anyOtherN ame"/>
</root>

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

Mar 20 '06 #2
Thanks, Priya,

Priya Lakshminarayana n:
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
1676
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 the state) The event management is no problem, the question is, how do we build our XML Schema (that's going to contain the data for both states and
3
1511
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 schema with targetNameSpace "http://tempuri.org/XMLFile1.xsd" referenced in this document. Index (zero based) must be greater or equal to zero and less than the size of the argument list. I can't find any help on this error, or see any reason...
2
1702
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 element names(TemplateB62,TemplateC62 ......) <?xml version='1.0' encoding='UTF-8'?> <xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
1
23963
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 names(TemplateB62,TemplateC62 ......) <?xml version='1.0' encoding='UTF-8'?> <xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
16
6017
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): <xsd:element name="Stuff"> <xsd:complexType> <xsd:sequence> <xsd:element ref="RequiredSimpleThing1"/> <xsd:element ref="RequiredSimpleThing2"/> <xsd:element name="OptionalSimpleThing1" type="OptionalType"
0
1330
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 content. To make the parts unique, the top-level element of the further content
1
1444
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)." *************** <?xml version="1.0" encoding="utf-16"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="Employee">
1
1579
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 http://test.org.Address Here is the schema defining the Employee: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://test.org/emp" xmlns="http://test.org/emp"
1
373
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 final notes. Many thanks and my apologies for the trouble. Best, Nick <language>
0
10313
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
9946
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...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
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.