473,396 Members | 2,036 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,396 software developers and data experts.

Ignoring Elements in XSD

How do I write a schema that is only validating elements: 1,4,7,8,9 and

ignores every other element? I also need to not to care about the order

of the elements or how many are in between elements that I am trying to

validate.
XML:
<root>
<element1 />
<element2 />
<element3 />
<element4 />
<element5 />
<element6 />
<element7 />
<element8 />
<element9 />
</root>
XSD:
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="element1">
<xs:element name="element4">
<xs:element name="element7">
<xs:element name="element8">
<xs:element name="element9">
</xs:sequence>
</xs:complexType>
</xs:element>
Basically I need it to ignore ANY elements outside of my Schema
declaration and I may not know where they are located in the XML doc.
Thanks.
Jody

Nov 12 '05 #1
3 3470
If you do not require ALL of the elements defined by your schema to be
present in the instance then you can construct a choice of all these
elements as well as an element wildcard (xs:any) in the content model. Let
me know if you need examples for how to do it.

"Jody Greening" <jo**********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
How do I write a schema that is only validating elements: 1,4,7,8,9 and

ignores every other element? I also need to not to care about the order

of the elements or how many are in between elements that I am trying to

validate.
XML:
<root>
<element1 />
<element2 />
<element3 />
<element4 />
<element5 />
<element6 />
<element7 />
<element8 />
<element9 />
</root>
XSD:
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="element1">
<xs:element name="element4">
<xs:element name="element7">
<xs:element name="element8">
<xs:element name="element9">
</xs:sequence>
</xs:complexType>
</xs:element>
Basically I need it to ignore ANY elements outside of my Schema
declaration and I may not know where they are located in the XML doc.
Thanks.
Jody

Nov 12 '05 #2
I do need all of the Elements described in my Schema. :-(

I can't beleive this is so hard to accomplish. The problem is that I
need to validate XML that is used to intergrate with our App, but I am
only concerned with a portion of this XML, and I have absolutely no
control over it.

I have reverted to a custom application for validation that use XPath
and generates a report based on what is found and what is missing.

Nov 12 '05 #3
There is no way in Xml Schema to define such a content model where you want
to impose no order and also mandate the occurence of elements and at the
same time allow other elements which should not be validated.

xsd:all is the contruct normally used to construct content model which
contain element without enforcing any order. But an xsd:all can not contain
an element wildcard (xsd:any), so you do not have the option to not validate
any element.

You could construct a <xsd:choice> containing an element wildcard, as well
as define all elements that you want, and let your application do the
checking that all mandatory elements occur atleast once.

Zafar
"Jody Greening" <jo**********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I do need all of the Elements described in my Schema. :-(

I can't beleive this is so hard to accomplish. The problem is that I
need to validate XML that is used to intergrate with our App, but I am
only concerned with a portion of this XML, and I have absolutely no
control over it.

I have reverted to a custom application for validation that use XPath
and generates a report based on what is found and what is missing.

Nov 12 '05 #4

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

Similar topics

0
by: Jody Greening | last post by:
How do I write a schema that is only validating elements: 1,4,7,8,9 and ignores every other element? I also need to not to care about the order of the elements or how many are in between elements...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
10
by: lac | last post by:
Hello all, I am trying to make horizontal bars of different lengths. I tought either SPAN or DIV would work but it only works for IE. I have a small example at: http://sedivy.com/test.htm Let...
0
by: eSapient | last post by:
For the following XSD: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">...
1
by: Taco | last post by:
The code below will serialize the Catalog object something like: <Catalog> <CatalogTitle>MyCatalog</CatalogTitle> <Books> <Book> <Title>Book1</Title> </Book> <Book> <Title>Book2</Title>...
4
by: David | last post by:
I'm using an XPathNodeIterator to select an element in an XML document that contains text I am going to put in a label on an aspx page. I want to be able to include HTML tags in the text read...
0
by: Ryan B | last post by:
Hi there, I've been searching the posts in this group and haven't been able to find anything that suitably solves my problem.. anyway... I am attempting to deserialize a class which I do not...
5
by: BACON | last post by:
I'm just starting the process of reorganising my modest little website and cleaning up all the HTML, and the logical place to begin was with the homepage. I made a simple little ASP.NET control...
9
by: jufemaiz: jc | last post by:
Is there any information out there on ignoring the desktop oriented conventions of ASP.NET and developing web app's more in line with traditional web app development. I need far more control over...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.