Forna
Forna

Reputation: 189

Adding schemas to my Xml document takes long time to complete

I have a program that I use to edit xmls.

I start with adding base schemas to my Xml like this

    Sub Initialize()
        document.Schemas.Add("http://www.w3.org/2000/09/xmldsig#",
                             ".\XSD\xmlsig.xsd")
        ' Dummy data here
        document.Schemas.Add("http://needed.url.org/docs/xsd/v1.2/", 
                             ".\XSD\myxsd_v1.2.xsd")
        initialized = True
    End Sub

Tho problem is that the second schema addition takes long time to complete, over 60 seconds vs the 13ms of the first one.

I already noticed:

Am I doing something wrong? How can I speed up this piece of code? Cause waiting for 70+ seconds for the application to initialize the document is not really ideal.

Edit 1: Analizing network packets I found out that a GET request for the xmldsig-core-schema.xsd it's fired but if I try to add the schema locally I get an exception about DTD not allowed in my document, no idea on how I can work around this though

Edit 2: Modified the xsd that requests the above mentioned schema, now the program correctly load the local version

Upvotes: 0

Views: 136

Answers (1)

Michael Kay
Michael Kay

Reputation: 163625

The W3C deliberately delays responses to requests for commonly-used schemas and DTDs in order to encourage users to access a local copy in preference; they started doing this a few years ago because they couldn't handle the thousands of requests coming in per second.

Do some network monitoring to see which resources are being requested (it may not be the ones that are directly named in your application, but others that are referenced indirectly); and then make sure your XmlResolver responds to these requests using local copies.

Upvotes: 1

Related Questions