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 200129 - XML CC missing for no namespace schema
Summary: XML CC missing for no namespace schema
Status: NEW
Alias: None
Product: xml
Classification: Unclassified
Component: Schema Tools (show other bugs)
Version: 7.0
Hardware: PC Windows 7 x64
: P2 normal with 2 votes (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-14 01:15 UTC by Oloko
Modified: 2011-09-21 08:23 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oloko 2011-07-14 01:15:30 UTC
I am making a module to add a specific code completion to XML files.
I can't add attributes to the schema in my XML, because the parser that read the XML does not support it.

I created a simple XML and XSD file to test it out.
The XML file:

<note>
  <from>Me</from>
  <to>You</to>
  <content>I want some help.</content>
</note>

The XSD file:

<xs:schema>
<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="content" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
</xs:schema>


So what I tried to do was to use the addCompletionModel method of CompletionContextImpl to add my completion model but I don't get code completion.
I looked at the source code of CompletionContextImpl and I found out that for completion models that have no namespace, I need to have the "noNamespaceSchemaLocation" attribute set in my XML document for the model to be set as the default "noNamespaceModel" of the CompletionContextImpl. I can clearly see that during "initModels", the line 

if(noNamespaceSchemaLocation != null && noNSModels.size() == 1)

stop it from setting my "no namespace model" if I don't have the "noNamespaceSchemaLocation" in my XML.

I tried it out and simply by changing my XML file to:

<note noNamespaceSchemaLocation="">
  <from>Me</from>
  <to>You</to>
  <content>I want some help.</content>
</note>

I will finally get code completion, but since I can't add the "noNamespaceSchemaLocation" in my XML, I can't use that solution.
Comment 1 Oloko 2011-07-19 21:33:33 UTC
Rather than using the addCompletionModel method directly, I created a CompletionModelProvider based on the code from MetaSchemaModelProvider.
As expected, the result is still the same: no code completion unless I write down 'noNamespaceSchemaLocation=""'.

The best solution for now that I was able to find is to create my own CompletionUtil class. In it, I changed my findAXIElementAtContext method to use getNoNamespaceModels rather than getActiveNoNSModel.

By doing this I can get code completion like I need, but I doubt this is the right way to do it.
Comment 2 Svata Dedic 2011-09-21 08:23:51 UTC
Marking as enhancement. 

Option #1: is to allow a extension module to specify the noNamespaceModel - if there's > 1 no namespace model, then the implementation cannot decide and simply ignores no namespaces. 

Option #2: allow the user to assign no namespace schema to any XML file; this will help when there's no specific module handling the file, but restrictions on contents are similar (e.g. nonstandard parser, which does not recognize standard attributes)