|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.web.dd; import java.util.Enumeration; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.*; import org.netbeans.modules.xml.dtd.grammar.DTDParser; import org.netbeans.api.xml.services.UserCatalog; /** DD Grammar provided code completion for web.xml specified by XML schema. * * @author mk115033 */ public class DDGrammarQueryManager extends org.netbeans.modules.xml.api.model.GrammarQueryManager { private static final String XMLNS_ATTR="xmlns"; //NOI18N private static final String WEB_APP_TAG="web-app"; //NOI18N public java.util.Enumeration enabled(org.netbeans.modules.xml.api.model.GrammarEnvironment ctx) { if (ctx.getFileObject() == null) return null; Enumeration en = ctx.getDocumentChildren(); while (en.hasMoreElements()) { Node next = (Node) en.nextElement(); if (next.getNodeType() == next.DOCUMENT_TYPE_NODE) { return null; // null for web.xml specified by DTD } else if (next.getNodeType() == next.ELEMENT_NODE) { Element element = (Element) next; String tag = element.getTagName(); if (WEB_APP_TAG.equals(tag)) { // NOI18N String xmlns = element.getAttribute(XMLNS_ATTR); if (xmlns!=null && DDCatalog.J2EE_NS.equals(xmlns)) //NOI18N return org.openide.util.Enumerations.singleton (next); } } } return null; } public java.beans.FeatureDescriptor getDescriptor() { return new java.beans.FeatureDescriptor(); } /** Returns pseudo DTD for code completion */ public org.netbeans.modules.xml.api.model.GrammarQuery getGrammar(org.netbeans.modules.xml.api.model.GrammarEnvironment ctx) { UserCatalog catalog = UserCatalog.getDefault(); if (catalog != null) { EntityResolver resolver = catalog.getEntityResolver(); if (resolver != null) { try { InputSource inputSource = resolver.resolveEntity(DDCatalog.WEB_APP_2_4_ID, null); if (inputSource!=null) { DTDParser dtdParser = new DTDParser(true); return dtdParser.parse(inputSource); } } catch(SAXException e) { } catch(java.io.IOException e) { } } } return null; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.