String ecmaToXMLString(XmlProcessor processor) { if (this.isElementType()) { Element copy = (Element) this.dom.cloneNode(true); Namespace[] inScope = this.getInScopeNamespaces(); for (int i = 0; i < inScope.length; i++) { declareNamespace(copy, inScope[i].getPrefix(), inScope[i].getUri()); } return processor.ecmaToXmlString(copy); } else { return processor.ecmaToXmlString(dom); } }
String debug() { XmlProcessor raw = new XmlProcessor(); raw.setIgnoreComments(false); raw.setIgnoreProcessingInstructions(false); raw.setIgnoreWhitespace(false); raw.setPrettyPrinting(false); return raw.ecmaToXmlString(this.dom); }
static XmlNode newElementWithText( XmlProcessor processor, XmlNode reference, XmlNode.QName qname, String value) { if (reference instanceof org.w3c.dom.Document) throw new IllegalArgumentException("Cannot use Document node as reference"); Document document = null; if (reference != null) { document = reference.dom.getOwnerDocument(); } else { document = processor.newDocument(); } Node referenceDom = (reference != null) ? reference.dom : null; Element e = document.createElementNS(qname.getUri(), qname.qualify(referenceDom)); if (value != null) { e.appendChild(document.createTextNode(value)); } return XmlNode.createImpl(e); }
@Nullable public static PsiElement treeWalkUp(final XmlProcessor processor, PsiElement elt) { if (elt == null) return null; PsiElement cur = elt; do { if (cur instanceof XmlTag) { final XmlTag tag = (XmlTag) cur; if (!processor.process(tag)) { if (processor instanceof ResolveProcessor) { return ((ResolveProcessor) processor).getResult(); } return null; } } if (cur instanceof PsiFile) break; cur = PsiTreeUtil.getPrevSiblingOfType(cur, XmlTag.class); } while (cur != null); return treeWalkUp(processor, elt.getContext()); }
static XmlNode createText(XmlProcessor processor, String value) { return createImpl(processor.newDocument().createTextNode(value)); }
String toXmlString(XmlProcessor processor) { return processor.ecmaToXmlString(this.dom); }
static XmlNode createElement(XmlProcessor processor, String namespaceUri, String xml) throws org.xml.sax.SAXException { return createImpl(processor.toXml(namespaceUri, xml)); }