Posted 12 years ago by Colin Blakey - Application Development Manager, Vertex Inc
Avatar
I have two questions/comments which may or may not be considered bugs i.e it may just be the way the Microsoft XML code works.

1) When using a multi file schema (lots of includes) it is necessary to set the current directory to the schema location prior to loading the schema into the schema resolver otherwise you get schema loading errors.

2) With the above mentioned multi file schema, when passing to the editor control a part of the XML that has a schema for it (in our case an IRS1120 XML chunk has a matching IRS1120.XSD schema file) then I set the default namespace in the schema resolver to get the intellisense working but the schema validation does not work because I do not have a namespace element specified in the root node i.e. xmlns="http://www.irs.gov/efile" of the chunk because it's not there in the text.

Any help would be appreciated.

Thanks

Colin Blakey

Comments (5)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Colin,

1) Hmm, I'm not sure if that can be avoided. Does anyone else have any ideas on this?

2) We're using an XmlReader with XmlReaderSettings that specifies a ValidationEventHandler for validation. Any idea how to set a default namespace there? I'm unable to find a way so far.


Actipro Software Support

Posted 12 years ago by Colin Blakey - Application Development Manager, Vertex Inc
Avatar
I have a couple of ideas for solutions to the issues above

For issue 1) I notice in the code that you can specify the path for DTD files and this is used to set the current directory, would it be possible to add something similar for schema files?

For issue 2) create an overrideable method to fetch the data from the editor context prior to loading in the XmlReader, that way the namespace could be added prior to validation

Thanks
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
1) Couldn't you just set the directory in your code, then load the XmlSchemaSet yourself, reset the old default directory, and then load the XmSchemaSet you loaded into the schema resolver?

2) The issue with this is that it will throw off all the error results since they will be based on different text than what is visible to the end user.


Actipro Software Support

Posted 12 years ago by Colin Blakey - Application Development Manager, Vertex Inc
Avatar
1) I do now, it just took me some time to figure out what the issue was when it first occurred. It's not really an issue it would just be a nice to have.

2) I agree that the text against which the errors are shown would be different to that in the text, but it's the only way I could think of to add the namespace on the fly. Without this the only solution is to show add the namespace to the xml prior to loading into the editor control, this unfortunately changes what the xml is that the user is i.e. they look at the whole xml file with only the namespace in the root node and now we show them a part of the xml and it suddenly sprouts a namespace as well. Not ideal but the only possibility for us at this point.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
For #2, I think you are right and the only way to really do this is figure out where the root tag is, check it for an xmlns attribute and if one isn't found then insert it in the XML that is sent to be validated (not affecting text in the document). Then in that case all the errors found need to be adjusted per the inserted text. I'll add this to the TODO list, although if this is something that you absolutely require immediately, you can visit this link for more assistance:
http://www.actiprosoftware.com/Purchase/ConsultingServices.aspx


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 10 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.