473,804 Members | 3,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Partial XML Schema Validation?

I want to speed up the validation of some of my fairly large and
detailed XML files.

In particular there is a set of child elements and attributes that does
not to be validated after it has completed a certain point in the
system, but that will still be present in the file. At points later in
the system, when these files are read in, I do not want to validate
this section as it has already been validated much earlier, but still
need the data in the file for History.

The files are currently validated by an XSD (XML Schema) file that
specifies the valid types for every element and attribute. But what I'd
ideally like to do is change this schema for later applications so that
it will still accept these files, but ignore the child elements. So an
element entry in the schema like

<element name="foo" type="*" />

which would allow the "foo" element to be present in the XML file with
all its children and normal data, but for the XML Schema validation to
just see that it's there and skip it.

I've tried using the xs:any element for XSD as well as the above
scenario but to no avail.

Thank you for any and all comments!

Jul 23 '05 #1
9 4441
For further detail it is well to note that I am using this in a .NET/C#
environment

Jul 25 '05 #2
Hi,

Try just:

<element name="foo"/>

If no type is specified, it should allow anything (including mixed
content.)

Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Jul 26 '05 #3
This did not resolve the issue:
The error I receive upon doing this is:
---> System.Exceptio n: Validate: Error validating xml file against
embedded schema. ---> System.InvalidO perationExcepti on: There is an
error in the XML document. ---> System.Exceptio n: valHandler:
Validation failure: The 'http://lmco.com/DataCapture:W' element is not
declared.

The element that I adjusted per your instructions has child elements W
which in turn have Chrs and Chr elements (word, chars, char).
Apparently it needs to see these elements defined in the schema,
however I don't want them validated. I would just like it to see that
the 'foo' element is there, and ignore its contents and children and
move on.

Jul 26 '05 #4
br*****@bc3tech .net writes:
... what I'd
ideally like to do is change this schema for later applications so that
it will still accept these files, but ignore the child elements. So an
element entry in the schema like
...
which would allow the "foo" element to be present in the XML file with
all its children and normal data, but for the XML Schema validation to
just see that it's there and skip it.

I've tried using the xs:any element for XSD ... but to no avail.


The XSD 'any' element with processContents ="skip" should do just what
you need. Can you show us a short example showing how you tried to
use it, and tell us what you expected it to do and what it did do?

--C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 26 '05 #5
Schema before (takes too long during validation):

<xs:element name="Elt1" minOccurs="0">
<xs:complexType >
<xs:sequence>
<xs:element name="Child1"
minOccurs="0" maxOccurs="unbo unded">
<xs:complexType >
<xs:all>
<xs:element name="Child11"
minOccurs="0">
<xs:complexType >
<xs:attribute name="A"
form="unqualifi ed" type="xs:nonNeg ativeInteger" />
<xs:attribute name="C"
form="unqualifi ed" type="xs:nonNeg ativeInteger" />
<xs:attribute name="D"
form="unqualifi ed" type="xs:nonNeg ativeInteger" />
</xs:complexType>
</xs:element>
<xs:element name="Child12"
minOccurs="0">
<xs:complexType >
<xs:sequence>
<xs:element
name="Child121" minOccurs="0" maxOccurs="unbo unded">
<xs:complexType >
<xs:all>
<xs:element
name="Child1211 " minOccurs="0">

<xs:complexType >

<xs:sequence>

<xs:element name="Child1211 1" minOccurs="0" maxOccurs="unbo unded">

<xs:complexType >

<xs:attribute name="C" form="unqualifi ed" type="xs:nonNeg ativeInteger"
/>

<xs:attribute name="V" form="unqualifi ed" type="xs:string " />

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>
</xs:element>
<xs:element
name="Child1212 " minOccurs="0">

<xs:complexType >

<xs:attribute name="x" form="unqualifi ed" type="xs:nonNeg ativeInteger"
/>

<xs:attribute name="y" form="unqualifi ed" type="xs:nonNeg ativeInteger"
/>

<xs:attribute name="w" form="unqualifi ed" type="xs:nonNeg ativeInteger"
/>

<xs:attribute name="h" form="unqualifi ed" type="xs:nonNeg ativeInteger"
/>

</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="Ct"
form="unqualifi ed" type="xs:string " use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Attempted Schema

<xs:element name="Elt1" minOccurs="0">
<xs:complexType >
<xs:sequence>
<xs:any processContents ="skip" />
</xs:sequence>
</xs:complexType>
</xs:element>
Error received:

---> System.Exceptio n: Validate: Error validating xml file against
embedded schema. ---> System.InvalidO perationExcepti on: There is an
error in the XML document. ---> System.Exceptio n: valHandler:
Validation failure: The element 'Elt1' has incomplete content.

Thanks for your responses!

Jul 27 '05 #6
Hi,

You need to put minOccurs="0" maxOccurs="unbo unded" on xs:any if you
want to allow any number of children. Also, if you want to allow Elt1
to have character data content, you should put mixed="true" on the
xs:complexType element.

But really, <xs:element name="Elt1"/> should work. It should not require
that the child element be declared. What processor are you using?

Hope that helps,
Priscilla
----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Jul 27 '05 #7
"BC3Tech" <br*****@bc3tec h.net> writes:
Schema before (takes too long during validation):

<xs:element name="Elt1" minOccurs="0">
<xs:complexType >
<xs:sequence>
<xs:element name="Child1" minOccurs="0" maxOccurs="unbo unded">
...
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Attempted Schema

<xs:element name="Elt1" minOccurs="0">
<xs:complexType >
<xs:sequence>
<xs:any processContents ="skip" />
</xs:sequence>
</xs:complexType>
</xs:element>
Why does the 'Attempted Schema' allow only one child of
Elt1? The base schema allows an unbounded number; I'd
expect the xs:any element to have maxOccurs="unbo unded".

And on the other pole of the spectrum, why does it require one child,
given that in the original schema Elt1 may be childless?
I'd expect minOccurs="0".
Error received:

---> System.Exceptio n: Validate: Error validating xml file against
embedded schema. ---> System.InvalidO perationExcepti on: There is an
error in the XML document. ---> System.Exceptio n: valHandler:
Validation failure: The element 'Elt1' has incomplete content.


Looks like your test example was a childless Elt1.

--C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 27 '05 #8
The processor I'm using is that of the .NET Framework 1.1 w/ sp1. I've
found that they plan to have some Partial Validation methods in the
next version of the Framework (v2, due out sept), but don't have until
then to wait, and we don't plan to integrate that into the project when
it does come out.

I just tried your solution to add the Mixed and min/max to the any
element and it worked!

I was confused when the /> element didn't work either, but what can ya
do.

Jul 27 '05 #9
Yes, a childless Elt1 was exactly what I wanted to be able to have and
have it skip over, which could then be inferred that I could have an
Elt1 that had children and those would also get skipped which is
exactly what I want.

However the solution was found by Priscilla and I greatly appreciate
both of your responses. Hopefully this will afford us quite a bit of
performance gain in our system since these are used greatly.

Thanks again!

Jul 27 '05 #10

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

Similar topics

4
5612
by: joes | last post by:
Hello there I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing wrong. Could somebody help me? I didn't find any full example working on the net. Thank you for any hints! If I run the examples below, the parsers parses the file well, no vlaidation is occuring although the schema and xml file does not
2
2154
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For example, using XPath or Java method. So is there a concept and/or standard for post-schema validation or application validation? Is there any hook in XML standards that allow me to hook up with my customized validation? Additionally and more...
2
9453
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the second reading attempt, and error description implies that reader is winded to the end of the XML and...
1
2327
by: Dan Bass | last post by:
There's an XML message I have, that has no namespace information. Then there is a XSD schema that is must validate against, but this has a targetNamespace and xmlns of "http://www.wbf.org/xml/b2mml-v02". How do I get this XML to validate against the Schema in C#? If I use XmlSpy (2005 home edition) to perform the validation, it first inserts namespace and schema information into the XML before validating. Validation then seems to work if...
2
7310
by: Ali | last post by:
I am having problem compiling schema contained in WSDL file when analyzing schema types contained in it (for example http://www.ebout.net/net/GoogleSearch.wsdl). Following code demonstrates my problem: using System.Diagnostics; using System.IO; using System.Xml; using System.Xml.Schema;
1
6411
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there should be getRateQuote, and QUOTEREQUEST, etc.
0
1417
by: Matt | last post by:
I have a problem when I select node elements from an xml file and validata each node againts the schema. I use XmlValidatingReader and it complains about elements not being declared. I have defined a schema for details of a particular service request. Below is a schema similar to the one that I defined: <?xml version="1.0" standalone="yes" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"...
0
2696
by: Mark Parter | last post by:
I'm trying convert an XML Schema (http://www.elframework.org/projects/xcri/efc_r1.0.xsd/view) to a VB.Net class using the XSD tool provided with the .NET 2 SDK. However, it's failing to generate the class and is outputting the following error(s); Schema validation warning: Undefined complexType 'http://purl.org/dc/elements/1.1/:SimpleLiteral' is used as a base for complex type extension. Line 433, position 5. Schema validation warning:...
2
3047
by: Mark | last post by:
Hi... I've been trying the .Validate() method on the XmlDocument to validate some xml against a schema, but one thing I noted was that unless the document explicitly declares the schema as a default namespace, Validate() just lets it slide through as a success. Is there a way to Validate() either a) mandating against a particular schema, or at the very least b) supplying a default namespace to be used even when not explicitly declared?
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10588
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...
1
10324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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
9161
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...
0
5527
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
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.