This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 212972 - XSD editor does not auto complete schema file if the imports are not downloaded
Summary: XSD editor does not auto complete schema file if the imports are not downloaded
Status: RESOLVED WONTFIX
Alias: None
Product: xml
Classification: Unclassified
Component: Retriever (show other bugs)
Version: 7.1.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-24 19:02 UTC by Michel Graciano
Modified: 2015-09-17 13:21 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample xsd (17.83 KB, text/plain)
2012-05-24 19:11 UTC, Michel Graciano
Details
Thread dump (11.04 KB, text/plain)
2012-05-24 19:12 UTC, Michel Graciano
Details
Log file (72.35 KB, text/x-log)
2012-05-29 16:32 UTC, Michel Graciano
Details
Log file using xsi:schemaLocation workaround (70.14 KB, text/x-log)
2012-05-29 16:44 UTC, Michel Graciano
Details
Sample XSD with xsi:schemaLocation workaround (17.99 KB, application/xml)
2012-05-29 16:55 UTC, Michel Graciano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2012-05-24 19:02:40 UTC
[ JDK VERSION : 1.7.4 ]

We have some schema files but I am not able to use the code completion because
the XML download never finishes. I will attach a sample schema soon.
Comment 1 Michel Graciano 2012-05-24 19:11:52 UTC
Created attachment 119841 [details]
Sample xsd

If I call code completion, in this particular schema, I can see that some UIs are opened to confirm the download of some schemas (probably official ones), but the retriever never ends and the only thing I can see at Retriever Output is:

May 24, 2012 3:58:04 PM : Retrieving Location: http://www.riobranco.com.br/schemas/tipos_basicos

I will attach a thread dump, maybe it can help you too.
Comment 2 Michel Graciano 2012-05-24 19:12:18 UTC
Created attachment 119842 [details]
Thread dump
Comment 3 Michel Graciano 2012-05-24 19:15:18 UTC
I have tested with 7.0.1, 7.1.2 and 7.2 ans I can confirm that it is present since 7.1.2 (I don't have 7.1 and 7.1.1 here to test it right now).

Product Version: NetBeans IDE Dev (Build 20120523-da4743d1f776)
Java: 1.7.0_04; Java HotSpot(TM) Client VM 23.0-b21
System: Linux version 3.0.0-17-generic-pae running on i386; UTF-8; en_US (nb)
Comment 4 Jiri Kovalsky 2012-05-29 11:50:15 UTC
I can reproduce it too.

Product Version: NetBeans IDE Dev (Build 201205280002)
Java: 1.7.0_04; Java HotSpot(TM) 64-Bit Server VM 23.0-b21
System: Linux version 3.0.0-12-generic running on amd64; UTF-8; cs_CZ (nb)
User directory: /home/cesilko/.netbeans/dev
Cache directory: /home/cesilko/.cache/netbeans/dev
Comment 5 Svata Dedic 2012-05-29 12:17:47 UTC
There appears to be some redirect loop; try to run the IDE with
-J-Dorg.netbeans.modules.xml.retriever.impl.level=100 
and check the ide log file.

According to my testing, the site's SSO creates an infinite redirect loop when the user agent does not accept & use cookies - the Retriever is an example.

An easy fix is to stop downloading a resource after certain amount of redirects. More elaborate fix would require to properly use cookies + all the cookie management (expiration, ...) as in user agents.
Comment 6 Svata Dedic 2012-05-29 12:19:11 UTC
As a workaround for buggy site, please download the schema manually, then use XML catalog (Tools | DTD and XML Schemas) to define local mapping from the NS URI to downloaded file.
Comment 7 Michel Graciano 2012-05-29 12:23:20 UTC
I think you have not understand the issue here. If you take a look at the import, the schema location is locally defined. Actually the imported schema is stored at local drive, at the same folder. We have others examples, where the path is relative too.

<import namespace="http://www.riobranco.com.br/schemas/tipos_basicos" schemaLocation="tiposBasicos_v1.1.xsd"/>

IMHO, the CC should be able to find this schemas since it has the correct path where to find it, and if it is not located, the search should be aborted.
Comment 8 Svata Dedic 2012-05-29 13:56:55 UTC
Hm, apparently I did not. I was focused on the 'download problem' and forgot about the reported scenario, sorry. 

I would bet that the IDE tries to download the http://www.riobranco.com.br/schemas/tipos_basicos because it tries to fill in the b: namespace prefix for CC dropdown box - this is not strictly necessary, as I guess in the context you invoke CC, only xsd: elements are allowed. If this is the case, then either http://www.riobranco.com.br/schemas/tipos_basicos is in the NB Catalog, or basic XML completion does not have a clue where to find the resource except the NS URI itself.

The XML CC (which suggests schema contents) does not actually understand the schema, it works because of schema for schemas :)

BTW in my debugger, the model for the imported tipos_basicos WAS loaded from the local harddrive. Please run NB with the mentioned switch, and to be sure also add:
-J-Dorg.netbeans.modules.xml.schema.completion.util.level=100 -J-Dorg.netbeans.modules.xml.retriever.catalog.level=100 
so we get the real data on what's going on in your case. Please attach the logs here.

An additional workaround would be to define an attribute
xsi:schemaLocation="http://www.riobranco.com.br/schemas/tipos_basicos tiposBasicos_v1.1.xsd"
in the XSD's root element, to give further hint to XML parsing. I would recommend that anyway, since all XML processing tools would get this hint.

So the identified defects here are:

* the namespace contents are fetched/created eagerly. The models should be created (and possibly xsd for them retrieved) only if the namespace could be actually in scope - an element from the namespace is allowed in the current context.

* the XML CC core does not understand meaning of xsd:targetNamespace, and also tries to load contents of the target namespace itself. Naturally there's no schemaLocation for it, so it goes to the web.

* [an enhancement] the XML CC core should be hinted from xsd:import instructions; if xsd:import contains a schemaLocation, it should be used in namespace fetching, too. Not a standard behaviour, since the schema XML would not probably XML-validate without xmlns URI reachable or xsi:schemaLocation, but could be done.
Comment 9 Michel Graciano 2012-05-29 16:32:43 UTC
Created attachment 120009 [details]
Log file

The log has some timeout exceptions. I can see at the Retriever Output the follow text:

May 29, 2012 11:55:17 AM : Retrieving Location: http://www.riobranco.com.br/schemas/tipos_basicos 

Error: An I/O error occured. Connection timed out


May 29, 2012 11:59:12 AM : Retrieving Location: http://www.riobranco.com.br/wsdls/CotacaoService 

Error: An I/O error occured. Connection timed out
Comment 10 Michel Graciano 2012-05-29 16:44:00 UTC
Created attachment 120010 [details]
Log file using xsi:schemaLocation workaround

Now, the only thing I can see at Retriever Output is:

May 29, 2012 1:34:27 PM : Retrieving Location: http://www.riobranco.com.br/wsdls/CotacaoService 

Error: An I/O error occured. Connection timed out
Comment 11 Michel Graciano 2012-05-29 16:46:43 UTC
Do you need anything else? Just let me know if I can help with additional information.
Comment 12 Michel Graciano 2012-05-29 16:55:42 UTC
Created attachment 120012 [details]
Sample XSD with xsi:schemaLocation workaround

Just for the record.
Comment 13 Svata Dedic 2012-06-13 14:47:49 UTC
Implemented a workaround - schemaLocation attribute (if present) is used for fetching + targetNamespace URI is not fetched. But still, the fetching is quite eager and should be improved. However I think this fix is sufficient to make the defect P3.
Comment 14 Quality Engineering 2012-06-15 06:10:34 UTC
Integrated into 'main-golden', will be available in build *201206150001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/a6bf0360d183
User: Svata Dedic <sdedic@netbeans.org>
Log: #212972: partial fix: schemaLocation attribute is honoured when getting namespace definitions. NS mentioned in targetNamespace attribute ignored.
Comment 15 Martin Balin 2015-09-17 13:21:24 UTC
Report from old NetBeans version. Due to code changes since it was reported likely not reproducible now. Feel free to reopen if happens in 8.0.2 or 8.1.