Methods Summary |
---|
public java.lang.String | getAnnotationString()A text representation of annotation.
return fData;
|
public java.lang.String | getName()The name of type NCName of this declaration as defined in
XML Namespaces.
return null;
|
public java.lang.String | getNamespace()The [target namespace] of this object, or null if it is
unspecified.
return null;
|
public com.sun.org.apache.xerces.internal.xs.XSNamespaceItem | getNamespaceItem()A namespace schema information item corresponding to the target
namespace of the component, if it's globally declared; or null
otherwise.
return null;
|
public short | getType()The type of this object, i.e.
ELEMENT_DECLARATION .
return XSConstants.ANNOTATION;
|
public boolean | writeAnnotation(java.lang.Object target, short targetType)Write contents of the annotation to the specified DOM object. If the
specified target object is a DOM in-scope namespace
declarations for annotation element are added as
attributes nodes of the serialized annotation , otherwise
the corresponding events for all in-scope namespace declaration are
sent via specified document handler.
if(targetType == XSAnnotation.W3C_DOM_ELEMENT || targetType == XSAnnotation.W3C_DOM_DOCUMENT) {
writeToDOM((Node)target, targetType);
return true;
} else if (targetType == SAX_CONTENTHANDLER) {
writeToSAX((ContentHandler)target);
return true;
}
return false;
|
private synchronized void | writeToDOM(org.w3c.dom.Node target, short type)
Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT)?target.getOwnerDocument():(Document)target;
DOMParser parser = fGrammar.getDOMParser();
StringReader aReader = new StringReader(fData);
InputSource aSource = new InputSource(aReader);
try {
parser.parse(aSource);
} catch (SAXException e) {
// this should never happen!
// REVISIT: what to do with this?; should really not
// eat it...
} catch (IOException i) {
// ditto with above
}
Document aDocument = parser.getDocument();
Element annotation = aDocument.getDocumentElement();
Node newElem = futureOwner.importNode(annotation, true);
target.insertBefore(newElem, target.getFirstChild());
|
private synchronized void | writeToSAX(org.xml.sax.ContentHandler handler)
// nothing must go wrong with this parse...
SAXParser parser = fGrammar.getSAXParser();
StringReader aReader = new StringReader(fData);
InputSource aSource = new InputSource(aReader);
parser.setContentHandler(handler);
try {
parser.parse(aSource);
} catch (SAXException e) {
// this should never happen!
// REVISIT: what to do with this?; should really not
// eat it...
} catch (IOException i) {
// ditto with above
}
|