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

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 4405
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.Exception: Validate: Error validating xml file against
embedded schema. ---> System.InvalidOperationException: There is an
error in the XML document. ---> System.Exception: 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="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="Child11"
minOccurs="0">
<xs:complexType>
<xs:attribute name="A"
form="unqualified" type="xs:nonNegativeInteger" />
<xs:attribute name="C"
form="unqualified" type="xs:nonNegativeInteger" />
<xs:attribute name="D"
form="unqualified" type="xs:nonNegativeInteger" />
</xs:complexType>
</xs:element>
<xs:element name="Child12"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element
name="Child121" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element
name="Child1211" minOccurs="0">

<xs:complexType>

<xs:sequence>

<xs:element name="Child12111" minOccurs="0" maxOccurs="unbounded">

<xs:complexType>

<xs:attribute name="C" form="unqualified" type="xs:nonNegativeInteger"
/>

<xs:attribute name="V" form="unqualified" 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="unqualified" type="xs:nonNegativeInteger"
/>

<xs:attribute name="y" form="unqualified" type="xs:nonNegativeInteger"
/>

<xs:attribute name="w" form="unqualified" type="xs:nonNegativeInteger"
/>

<xs:attribute name="h" form="unqualified" type="xs:nonNegativeInteger"
/>

</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="Ct"
form="unqualified" 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.Exception: Validate: Error validating xml file against
embedded schema. ---> System.InvalidOperationException: There is an
error in the XML document. ---> System.Exception: 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="unbounded" 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*****@bc3tech.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="unbounded">
...
</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="unbounded".

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.Exception: Validate: Error validating xml file against
embedded schema. ---> System.InvalidOperationException: There is an
error in the XML document. ---> System.Exception: 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
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...
2
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...
2
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....
1
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...
2
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...
1
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...
0
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...
0
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...
2
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.