Code Completion/Validation Issues

Having trouble installing Oxygen? Got a bug to report? Post it all here.
gnunn
Posts: 3
Joined: Thu Feb 24, 2011 9:47 pm

Code Completion/Validation Issues

Post by gnunn »

I'm trying to create an XML document that is a SOAP response for use in a mock service and I am having a devil of a time with getting validation and code completion to work with the schemas in play. In my project I have the response document, the schema for the SOAP envelope and my message specific schemas.

1. Does Oxygen automatically detect which schemas to use for code completion and validation based on what is in the project? It seems like it would be easy to see what namespaces various schemas in the project declare and then use them for code completion and validation based on the namespaces declared in the XML document. I'm asking about this to confirm but based on the docs and behavior I suspect not.

2. What's the best way to associate a schema with a document? I don't want to use the schema association that modifies the document with a location tag.

3. I tried the XML catalog by adding my schemas to here but it didn't seem to do anything.

4. There is the Document Association however this looks like a global option, I really just want to control the association at the project level since I may be working on different versions of the schema.

Thanks for any pointers, new to Oxygen and trying to work with it in the most efficient way possible.
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Code Completion/Validation Issues

Post by Radu »

Hi,

Please see some answers below:
1. Does Oxygen automatically detect which schemas to use for code completion and validation based on what is in the project? It seems like it would be easy to see what namespaces various schemas in the project declare and then use them for code completion and validation based on the namespaces declared in the XML document. I'm asking about this to confirm but based on the docs and behavior I suspect not.
No, Oxygen does not try to auto detect the schema to use for validation and content completion from the Project. But this might be an improvement which we'll make in a future version. Such a detection is not so simple as there might be several schemas with the searched namespace existing in the project. Also, if the project is very large this detection may take a lot of time and maybe it will be done only on demand.
2. What's the best way to associate a schema with a document? I don't want to use the schema association that modifies the document with a location tag.
Through the Oxygen Preferences->Document Type Association page.
At the bottom of the page there is a Project Options radio button which you can switch. After switching you can create a new Document Type Association with the association rules tuned for your specific XML files. This association will then be saved in the Oxygen Project projectName.xpr file.
3. I tried the XML catalog by adding my schemas to here but it didn't seem to do anything.
Another means is indeed to map through an XML catalog the XML's namespace to a location on disk where the schema is located.
Attention that the namespace must be mapped in the catalog file using the <uri> notation like:
<uri name="http://your/namespace/here" uri="a.xsd"/>

The catalog settings in Oxygen can also be saved at project level. Just make sure you are using the ${pdu} editor variable in all the specified locations, variable which will expand to the path of the current project's directory.

Then add this catalog in the Preferences->XML / XML Catalog page.
4. There is the Document Association however this looks like a global option, I really just want to control the association at the project level since I may be working on different versions of the schema.
See answer for (2).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gnunn
Posts: 3
Joined: Thu Feb 24, 2011 9:47 pm

Re: Code Completion/Validation Issues

Post by gnunn »

So I tried creating a catalog and it still does not seem to be picking things up as I would expect in certain cases. If I generate an XML document from a schema the code completion works even if I remove the schema location tag so that would indicate the catalog is working. However if I then switch to XQuery and import the schema via the following line:

import schema namespace types = "http://xxx.int.xxx.ca/customer/profile/types";

The XQuery editor shows errors when referencing specific types from that schema unless I explicitly include the at hint as follows:

import schema namespace types = "http://xxx.int.xxx.ca/customer/profile/types" at "CustomerProfileTypes.xsd";

Why doesn't the XQuery editor pickup the right schema from the Catalog?

Also, some other questions as follows:

- Does Oxygen support importing inline schemas from WSDLs? Some of the web services I deal with unfortunately inline their schemas and separating these out into distinct files for XQuery development would be a real pain.

- When generating an XML file from a schema and setting the default namespace the XML file generates elements with an empty xmlns, for example:

xmlns=""

Why does it do this, isn't this empty xmlns redundant?
gnunn
Posts: 3
Joined: Thu Feb 24, 2011 9:47 pm

Re: Code Completion/Validation Issues

Post by gnunn »

BTW, in the importing schema in XQuery case above when I say it shows errors I mean it indicates that it cannot find an associated schema:

Unable to locate requested schema ...
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Code Completion/Validation Issues

Post by adrian »

Hello,

The XQuery editor uses an XQuery engine for validation. You must have already manually set this engine to Saxon-EE XQuery(in Options -> Preferences -> XML -> XSLT-FO-XQuery -> XQuery, Engine used for XQuery validation) or you wouldn't have got as far as the error you are reporting. By default Oxygen uses the Saxon-PE XQuery engine that doesn't allow schema importing.

Note that you'll also have to enable another option(if you haven't already): Options -> Preferences -> XML -> XML Catalog, Process namespaces through URI mappings for XML Schema

The "at" hint seems to be a peculiarity of the Saxon-EE engine, possibly a bug.
I've tested and indeed something like this:
import schema namespace types = "http://xxx.int.xxx.ca/customer/profile/types";
doesn't work.

While this:
import schema namespace types = "http://xxx.int.xxx.ca/customer/profile/types" at "";
works fine.

Without the 'at' hint Saxon doesn't even attempt to resolve the namespace URI.


If on a parent element you have set a default namespace(xmlns="someNamespace"), then xmlns="" sets the default namespace to "no namespace". So it's not redundant, it overrides the previous default namespace.
If I misunderstood then please provide a sample of the XML file.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Code Completion/Validation Issues

Post by Radu »

Hi,
Does Oxygen support importing inline schemas from WSDLs? Some of the web services I deal with unfortunately inline their schemas and separating these out into distinct files for XQuery development would be a real pain.
So in a WSDL file you can either have XML Schemas in-lined or reference them using <import> statements.

I'm not sure what exactly you want. We do not have a specific tool which takes a WSDL <import> and inlines its content (or the other way around).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply