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

Apply Embedded XSD schema to specific element in an XmlDocument

I'm creating a system that uses XML to store an audit trail of the
steps that it has been through in the system.

The way the schema is defined, there is a "Tag" for every application
that performs modifications to any data, and "Fields" inside the tag
that outline the changes that were made.

Applications in the flow of the system read in these XML files and will
"overlay" these tags in order to obtain data for all fields that were
modified from a certain point on to act on that data and post their
results.

By the end of the system, as you can see, there are many, many Tags in
these XML files, and using an XSD schema to validate the file when it's
read in is horribly inefficient. Rather, I would like to define the
schema in such a way that it will be a validator for only the Tags and
their contents, and apply that schema to the tags that are written in.

Currently, I have tried to do this 2 ways, one way using a validating
reader and trying to .Skip() tags that are not needed at the current
point, and the other was to use an XmlDocument to perform validation on
fragments of XML.

The problem I saw, however, was that according to MSDN documentation,
..Skip() on a validating reader validates the XML that it is skipping!
(Doesn't make much sense, huh). So I had to modify how I used the
ValidatingReader:

.. Create an XmlValidatingReader for the xml file to be read in
.. If a tag is found that should not be validated (not needed by the
current application), valReader.MoveToNextAttribute() and
valReader.MoveToElement() until the tag is complete.

The second way, using an XmlDocument and fragment validation, was
attempted like this:

.. Create an XmlTextReader for the xml file to be read in
.. Create an XmlDocument from the text reader
.. Get all "Tags" from the element list of the document
.. Loop through the resulting list and if the Name of the tag is one we
need to validate, create an XmlValidatingReader for the .OuterXml of
the node and .Read() on the ValidatingReader.

The problem with both of these algorithms is that the overhead of
creating the reader and document, moving the cursor manually, and all
the other manual operations proved to negate any benefit (according to
Durations set in the code to time the sections) versus just creating a
ValidatingReader and passing that to the Deserialize function.
Currently this is what I'm doing, and the hit for Validating while
Deserializing is huge. So I want to do my own small validation, and
pass just an XmlTextReader to the Deserialize function.

Any Ideas?

Thanks!

Nov 17 '05 #1
0 1821

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

Similar topics

0
by: marcum williams | last post by:
Below I'm generating an updategram via xslt and currently referencing schema via <updg:sync mapping-schema="hpXSD.xsd"> .... </updg:sync> But I would like to LOAD the .xsd schema into memory...
1
by: Michael Palmer | last post by:
I'm reading xml from SQL Server 2K with VB.net using an XSD schema file and SQLXML 3.0. I have the below code working fine, but I'd like to change the code from reading the schema file from a...
2
by: Edward Diener | last post by:
I could not find an example of an inline XSD schema for an XML document which has no namespaces. Could someone supply one ? When I tried validating my XML with an inline XSD schema, using...
12
by: Stefano | last post by:
Hi all, what is the correct use of the "default" attribute in XML Schema? For example: <xs:element name="myProperty" type="xs:string" default="myDefaultValue"/> What can I do with it? What...
0
by: kamii47 | last post by:
I am creating in memory xmldocument.Previously I were validating my file against a dtd file and then by the help of GetElementByID read my needed node. i.e. XmlDocumentType doctype = null; ...
5
by: Norsoft | last post by:
How can I convert an existing schema to an xml document. I have a series of schema documents that validate xml documents that describe metadata. Normally the metadata is first defined in a database,...
4
by: Jethro | last post by:
I've tried to find the simplest demonstration of my issue. I have source XML that looks like this (not a real XSD schema, but it doesn't matter at this point): (in var xmlStr:) <xsd:element...
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...
1
by: Mikus Sleiners | last post by:
I have a task to create xml document from c# code. I have example of that document should look like and also a xml schema. I wonder if i can use this xml schema somehow ? This is schema: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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.