1 11 package org.eclipse.pde.internal.core.schema; 12 13 import org.eclipse.pde.internal.core.XMLDefaultHandler; 14 import org.w3c.dom.Node ; 15 import org.w3c.dom.Text ; 16 import org.xml.sax.SAXException ; 17 18 public class SchemaHandler extends XMLDefaultHandler { 19 20 public SchemaHandler(boolean abbreviated) { 21 super(abbreviated); 22 } 23 24 27 public void characters(char[] characters, int start, int length) throws SAXException { 28 if (!fAbbreviated) { 29 super.characters(characters, start, length); 30 return; 31 } 32 33 if (onAttributeDescription()) { 34 StringBuffer buff = new StringBuffer (); 35 buff.append(characters, start, length); 36 Node node = ((Node )fElementStack.peek()); 37 Node child = node.getFirstChild(); 38 if (child == null) 39 node.appendChild(getDocument().createTextNode(buff.toString())); 40 else 41 ((Text )child).appendData(buff.toString()); 42 } 43 } 44 45 private boolean onAttributeDescription() { 46 Node node = (Node )fElementStack.peek(); 47 if (node == null) 48 return false; 49 if (!node.getNodeName().equals("documentation")) return false; 51 node = node.getParentNode(); 52 if (node == null) 53 return false; 54 if (!node.getNodeName().equals("annotation")) return false; 56 node = node.getParentNode(); 57 if (node == null) 58 return false; 59 return node.getNodeName().equals("attribute"); } 61 } 62 | Popular Tags |