1 19 20 package org.netbeans.modules.xml.dtd.grammar; 21 22 import java.beans.FeatureDescriptor ; 23 import java.util.Enumeration ; 24 import org.netbeans.modules.xml.api.model.*; 25 import org.w3c.dom.Node ; 26 import org.xml.sax.InputSource ; 27 28 33 public class DTDGrammarQueryProvider extends GrammarQueryManager { 34 35 public Enumeration enabled(GrammarEnvironment ctx) { 36 Enumeration en = ctx.getDocumentChildren(); 37 while (en.hasMoreElements()) { 38 Node next = (Node ) en.nextElement(); 39 if (next.getNodeType() == next.DOCUMENT_TYPE_NODE) { 40 return org.openide.util.Enumerations.singleton (next); 41 } 42 } 43 return null; 44 } 45 46 public FeatureDescriptor getDescriptor() { 47 return new FeatureDescriptor (); 48 } 49 50 public GrammarQuery getGrammar(GrammarEnvironment env) { 51 return new DTDParser().parse(env.getInputSource()); 52 } 53 54 } 55 | Popular Tags |