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 22598 - Implement XSLT code completion
Summary: Implement XSLT code completion
Status: RESOLVED DUPLICATE of bug 20421
Alias: None
Product: xml
Classification: Unclassified
Component: Text-Edit (show other bugs)
Version: 3.x
Hardware: PC All
: P3 blocker (vote)
Assignee: _ pkuzel
Depends on:
Blocks: 21881 22657
  Show dependency tree
Reported: 2002-04-18 14:11 UTC by _ pkuzel
Modified: 2007-09-25 01:33 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description _ pkuzel 2002-04-18 14:11:33 UTC
Details to come ...
Comment 1 _ pkuzel 2002-04-18 14:31:53 UTC wrote:
> Hi.
> I was investigating the text-edit code to see how code completion
for XSLT
> might be implemented.  If I want to reuse XMLCompletion and
> query, there no way for me to add support for a new GrammarQuery. 
To add
> this support, the following has to be done:
> 1.  Create a new interface: GrammarParser which should be defined
> public interface GrammarParser {
>     GrammarQuery parse(InputSource in);
> }
> DTDParser should implement this interface.  I could create a
> XSLTGrammarParser which implements this interface.  When the parse
> of XSLTGrammarParser is called, it will return a XSLTGrammarQuery if
> root element in the InputSource XML is <xsl:stylesheet>, otherwise
it will
> return null.

Look at current sources, there is also a need for grammar invalidation
means. It is not probably required by XSLT grammar provider but it is
must for DTD grammar provider. I was not able to generalize it so 
I deferred it (hardcoded the logic) until really needed.
Besides basic XSLT completion can be delivered by any XML Schema aware
grammar provider.

> ----
> 2.  Add a static method to XMLCompletionQuery which allows any class
to add
> a GrammarParser:
> public static void addGrammarParser(GrammarParser parser) {
>      ..
> }
> This method should add a GrammarParser to a static list of

Mind dependencies! It is better to use org.openide.util.Lookup style
registrations i.e. let providers register themselves at their module
layer and let XMLCompletionQuery lookup for them.
> ----
> 3.  Change the XMLCompletion.GrammarCache.loadParser() method to
make it
> look through the list of registered GrammarParser objects.  For each
> GrammarParser object, the parse method is called.  If the method
> non-null GrammarQuery, that particular query will be used.  If all
> registered GrammarParser object's parse methods return null, the
> is used (which means unchanged behavior).

Searching a list of registered grammars may be very expensive if
every grammar tries to parse. Well it may return lazy initialized
GrammarQuery (an implementation will finish parsing on the first
> -----------
> Do you accept those changes?  If so, I will implement them.

Yes, we need to get rid of hardcoded logic now. It blocks you.
Another interfaces draft:

 * Factory registered in Lookup under Services/XML/text-completion.
public abstract class GrammarManagerFactory {

  GrammarManager createGrammarManager(Document or InputSource ???);
  // identity of InputSource etc,


 * Takes care of grammar creating and notifies if it is still
 * able to serve properly.
public interface GrammarManager {

  GrammarQuery getGrammarQuery();

  // it must be able to decide, how???

  final String PROP_VALID;

  boolean isValid();

I hope you get some idea how to improve them.
> Where should I put the XSLTGrammarParser and XSLTGrammarQuery
> XSLT support is becomming a standard part of most XML editors.  I
> thus like to include them in the "xml-text-edit" module in the
> "org.netbeans.modules.xml.text.completion.xslt".  Do you agree?

I makes sense to me. Let others speak up (I heard that some people
need very lightweight XML editing support, it probably does not
cover XSLT).
Comment 2 Marek Grummich 2002-07-19 16:58:30 UTC
Target milestone was changed from not determined to TBD
Comment 3 _ pkuzel 2002-08-14 16:56:55 UTC
Feature positively influences user 
Comment 4 _ pkuzel 2002-08-14 16:57:04 UTC
Feature positively influences user 
Comment 5 _ pkuzel 2002-08-14 17:01:09 UTC

*** This issue has been marked as a duplicate of 20421 ***