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

using embedded .xsd vs file based .xsd

I am thinking of embedding my schemas as embedded resources instead of
reading it using URI at run-time.
I came across some snags while trying to do just that such as, previously
unknown to me, XmlValidatingReader.Schemas.Add was using
XmlValidatingReader.Resolver to resolve my schemas using the URI method.
Resolver property was never set, so the reader simply ignored any external
references even though one of the schema explicitly imports the other one.
I verified this by removing the referred schema from the schema collection,
and the code chugged along fine.

But when I changed the code to read schemas from the assembly, a couple of
things happened:
1. It became important that I add schemas in a certain order; that is add
the one that is being referred first, so that the one that is referring can
find it later.
2. Apparently Resolver property is not used since all the schemas are loaded
from the assembly; No parser context with XmlNamespaceManager was necessary
contrary to my initial assumption.

My question is then to confirm that #2 is indeed correct and also, whether I
should be specifying a Resolver were I to use file based schema addition.

Thanks very much.
Jiho
Nov 12 '05 #1
1 3926
A little update to the whole thing. I've measured the performance of each
method using a very small sample set.
And as expected, using the resource-based loading is faster. I guess that's
because the assembly is already in memory as opposed to reading from the
file system every time.
I then went back to the file system based loading and instead cached the
schemas via Context.Cache.Insert. Needless to say it is as fast if not
faster than loading from the assembly. Not initially but on subsequent
requests, using the cache seems to be faster on every count. Initially
though loading from the assembly was faster still.

For 10 consecutive requests, (obviously a small set, nonetheless useful)

Assembly [vReader.Schemas.Add(null, new
XmlTextReader(Assembly.GetExecutingAssembly().GetM anifestResourceStream("xsd
..myschema.xsd")));]
Initial: 10.3 ms
Subsequent Avg: 6.5 ms

File-based [vReader.Schemas.Add(null, Server.MapPath("xsd/myschema.xsd"));]
Initial: 13 ms
Subsequent Avg: 8.2 ms

Cache [myschema= XmlSchema.Read(new
XmlTextReader(Server.MapPath("xsd/myschema.xsd")), null);
Context.Cache.Insert("xsd.myschema.xsd", myschema, null,
DateTime.MaxValue, TimeSpan.FromMinutes(20));]
Initial: 12.6 ms
Subsequent Avg: 4.3 ms

I guess I could read from the resource and cache it to be optimal. My
wanting to embed schemas in the assembly is not so much for the performance
reasons but for organization reasons by the way.

Feel free to comment on the results above and let me know if you have any
insights.
Thanks much!
Jiho

"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:uf*************@tk2msftngp13.phx.gbl...
I am thinking of embedding my schemas as embedded resources instead of
reading it using URI at run-time.
I came across some snags while trying to do just that such as, previously
unknown to me, XmlValidatingReader.Schemas.Add was using
XmlValidatingReader.Resolver to resolve my schemas using the URI method.
Resolver property was never set, so the reader simply ignored any external
references even though one of the schema explicitly imports the other one.
I verified this by removing the referred schema from the schema collection, and the code chugged along fine.

But when I changed the code to read schemas from the assembly, a couple of
things happened:
1. It became important that I add schemas in a certain order; that is add
the one that is being referred first, so that the one that is referring can find it later.
2. Apparently Resolver property is not used since all the schemas are loaded from the assembly; No parser context with XmlNamespaceManager was necessary contrary to my initial assumption.

My question is then to confirm that #2 is indeed correct and also, whether I should be specifying a Resolver were I to use file based schema addition.

Thanks very much.
Jiho

Nov 12 '05 #2

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

Similar topics

4
by: Phil Powell | last post by:
http://www.php.net/array_filter I went there at first for my information on filtering mySQL query results using PHP, to no avail. This is more of a Vignette construct (my native environment)...
2
by: David Muoio | last post by:
I am trying to validate an XML file against an XSD that is stored in the assembly as an embedded resource. I can get it to work as long as the XSD does not include other XSDs. After a fair amount...
35
by: David Mathog | last post by:
Every so often one of my fgets() based programs encounters an input file containing embedded nulls. fgets is happy to read these but the embedded nulls subsequently cause problems elsewhere in...
59
by: Jeff Bowden | last post by:
For ease of configuration and other reasons, I would like for my single-user GUI app to be able to use postgresql in-process as a library accessing a database created in the users home directory. ...
5
by: Captain Dondo | last post by:
I am working on an embedded platform which will serve a small number of dynamic webpages. Right now we are looking at php+javascript with apache as the webserver. Do we need to compile the...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
3
by: doomsday123 | last post by:
Is there an easy way to copy an Embedded Resource file to the file system? I have a config file that is an Embedded Resource in my project that I want to copy to a location in the file system but...
20
by: salmanjavaheri | last post by:
Hi we have a piece of php based (i think) software that exports to an rtf file, these files contain an image, this image makes the rtfs too large...so the solution is to reduce the...
16
by: Michael Brennan | last post by:
I guess this question only applies to programming applications for UNIX, Windows and similiar. If one develops something for an embedded system I can understand that wchar_t would be unnecessary. ...
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
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
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...
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.