Java Code Examples for org.w3c.dom.Document

The following are top voted examples for showing how to use org.w3c.dom.Document. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: aws-toolkit-eclipse   File: AndroidManifestFile.java View source code Vote up 6 votes
/**
 * Updates the Android manifest file for the specified Android project with
 * customizations for building Android projects that work with AWS.
 *
 * Specifically, this method adds the following configuration:
 *   uses-sdk android:minSdkVersion="10"
 *   uses-permission android:name="android.permission.INTERNET"
 */
public void initialize() {
    try {
        Document doc = parse();
        Node manifestElement = firstChildElement(doc, "manifest");
        Node applicationElement = firstChildElement(manifestElement, "application");
        manifestElement.removeChild(applicationElement);

        Element usesSdkElement = doc.createElement("uses-sdk");
        usesSdkElement.setAttribute("android:minSdkVersion", "10");
        manifestElement.appendChild(usesSdkElement);

        Element usesPermissionElement = doc.createElement("uses-permission");
        usesPermissionElement.setAttribute("android:name", "android.permission.INTERNET");
        manifestElement.appendChild(usesPermissionElement);

        // Add the application element back, so that it
        // comes after the uses-permission elements
        manifestElement.appendChild(applicationElement);

        StreamResult result = new StreamResult(manifestFile);
        transformer.transform(new DOMSource(doc), result);
    } catch (Exception e) {
        IStatus status = new Status(IStatus.ERROR, AndroidSDKPlugin.PLUGIN_ID,
            "Unable to update Android project manifest with settings for the AWS SDK for Android", e);
        StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
    }
}
 
Example 2
Project: jbosgi   File: DocumentBuilderTestCase.java View source code Vote up 6 votes
private void parse(DocumentBuilderFactory factory) throws Exception {
    factory.setNamespaceAware(true);
    factory.setValidating(false);

    DocumentBuilder domBuilder = factory.newDocumentBuilder();
    URL resURL = bundle.getResource("simple.xml");
    Document dom = domBuilder.parse(resURL.openStream());
    assertNotNull("Document not null", dom);

    Element root = dom.getDocumentElement();
    assertEquals("root", root.getLocalName());

    Node child = root.getFirstChild();
    assertEquals("child", child.getLocalName());
    assertEquals("content", child.getTextContent());
}
 
Example 3
Project: aws-toolkit-eclipse   File: RegionMetadataParser.java View source code Vote up 6 votes
/**
 * Parses the specified input stream and returns a list of the regions
 * declared in it.
 *
 * @param input
 *            The stream containing the region metadata to parse.
 *
 * @return The list of parsed regions.
 */
public List<Region> parseRegionMetadata(InputStream input) {
    Document document;
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = factory.newDocumentBuilder();
        document = documentBuilder.parse(input);
    } catch (Exception e) {
        throw new RuntimeException("Unable to parse region metadata file: " + e.getMessage(), e);
    }

    NodeList regionNodes = document.getElementsByTagName(REGION_TAG);
    List<Region> regions = new ArrayList<Region>();
    for (int i = 0; i < regionNodes.getLength(); i++) {
        Node node = regionNodes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element)node;
            regions.add(parseRegionElement(element));
        }
    }

    return regions;
}
 
Example 4
Project: dlna   File: DescMeta.java View source code Vote up 6 votes
public Document createMetadataDocument() {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        Document d = factory.newDocumentBuilder().newDocument();
        Element rootElement = d.createElementNS(DIDLContent.DESC_WRAPPER_NAMESPACE_URI, "desc-wrapper");
        d.appendChild(rootElement);
        return d;
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 5
Project: java-csp   File: Base64.java View source code Vote up 6 votes
/**
 * This method takes an (empty) Element and a BigInteger and adds the
 * base64 encoded BigInteger to the Element.
 *
 * @param element
 * @param biginteger
 */
public static final void fillElementWithBigInteger(Element element, BigInteger biginteger) {

    String encodedInt = encode(biginteger);

    if (!XMLUtils.ignoreLineBreaks() && encodedInt.length() > BASE64DEFAULTLENGTH) {
        encodedInt = "\n" + encodedInt + "\n";
    }

    Document doc = element.getOwnerDocument();
    Text text = doc.createTextNode(encodedInt);

    element.appendChild(text);
}
 
Example 6
Project: android-platform-tools-base   File: NodeUtils.java View source code Vote up 6 votes
static Node duplicateNode(Document document, Node node) {
    Node newNode;
    if (node.getNamespaceURI() != null) {
        newNode = document.createElementNS(node.getNamespaceURI(), node.getLocalName());
    } else {
        newNode = document.createElement(node.getNodeName());
    }

    // copy the attributes
    NamedNodeMap attributes = node.getAttributes();
    for (int i = 0 ; i < attributes.getLength(); i++) {
        Attr attr = (Attr) attributes.item(i);

        Attr newAttr;
        if (attr.getNamespaceURI() != null) {
            newAttr = document.createAttributeNS(attr.getNamespaceURI(), attr.getLocalName());
            newNode.getAttributes().setNamedItemNS(newAttr);
        } else {
            newAttr = document.createAttribute(attr.getName());
            newNode.getAttributes().setNamedItem(newAttr);
        }

        newAttr.setValue(attr.getValue());
    }

    // then duplicate the sub-nodes.
    NodeList children = node.getChildNodes();
    for (int i = 0 ; i < children.getLength() ; i++) {
        Node child = children.item(i);
        if (child.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }
        Node duplicatedChild = duplicateNode(document, child);
        newNode.appendChild(duplicatedChild);
    }

    return newNode;
}
 
Example 7
Project: JFugue-for-Android   File: OutputFormat.java View source code Vote up 6 votes
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }
    
    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
Example 8
Project: fedora-client   File: XmlSerializer.java View source code Vote up 6 votes
private static DOMImplementationLS
        getDOMImplementationLS(Document document) {
    DOMImplementation domImplementation = document.getImplementation();
    if (domImplementation.hasFeature("LS", "3.0") &&
            domImplementation.hasFeature("Core", "2.0")) {
        DOMImplementationLS domImplementationLS;
        try {
            domImplementationLS =
                    (DOMImplementationLS) domImplementation.getFeature(
                            "LS", "3.0");
        } catch (NoSuchMethodError nse) {
            logger.warn("Caught NoSuchMethodError for " +
                    domImplementation.getClass().getName() +
                    "#getFeature. " +
                    "Trying fallback for DOMImplementationLS.");
            try {
                domImplementationLS = getDOMImplementationLS();
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage(), e);
            }

        }
        return domImplementationLS;
    } else {
        throw new RuntimeException(
                "DOM 3.0 LS and/or DOM 2.0 Core not supported.");
    }
}
 
Example 9
Project: LiveFootball   File: SVGImplementation.java View source code Vote up 6 votes
private SVGSVGElement getSVGElement(SVGImage im){
    SVGSVGElement retVal = null;
    Document dom = im.getDocument();
    retVal = (SVGSVGElement)dom.getElementById(this.getClass().getName() + id);
    if(retVal == null){
        retVal = (SVGSVGElement) dom.createElementNS(SVG_NAMESPACE, "svg");
        id = idCounter++;
        retVal.setId(this.getClass().getName() + id);
    }
    return retVal;
}
 
Example 10
Project: voms-api-java   File: VOMSRequestFactory.java View source code Vote up 6 votes
public VOMSRequestFragment(Document doc) {

    this.doc = doc;

    fragment = doc.createDocumentFragment();
    buildRootElement();
  }
 
Example 11
Project: eclipse-integration-commons   File: StsTestUtil.java View source code Vote up 6 votes
public static String canocalizeXml(String originalServerXml) throws Exception {
	DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
	documentBuilderFactory.setExpandEntityReferences(false);

	DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
	Document document = builder.parse(new InputSource(new StringReader(originalServerXml)));
	document.normalize();

	TransformerFactory factory = TransformerFactory.newInstance();
	Transformer transformer = factory.newTransformer();
	StringWriter writer = new StringWriter();
	transformer.setOutputProperty(OutputKeys.INDENT, "yes");
	transformer.transform(new DOMSource(document.getDocumentElement()), new StreamResult(writer));
	return writer.toString().replace("\\s+\\n", "\\n");
}
 
Example 12
Project: osmhv-fork   File: XMLReadTest.java View source code Vote up 6 votes
public static API06Item makeItem(String a_xml) throws Exception
{
	Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(a_xml.getBytes("UTF-8")));
	Element root = null;
	NodeList nodes = dom.getChildNodes();
	for(int i=0; i<nodes.getLength(); i++)
	{
		if(nodes.item(i).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
			continue;
		root = (Element) nodes.item(i);
		break;
	}

	if(root == null)
		throw new IOException("No root element.");

	List<Item> items = sm_api.makeObjects(root);
	if(items.size() < 1)
		throw new IOException("No items.");

	return (API06Item)items.get(0);
}
 
Example 13
Project: krypton   File: AbstractBaseBrowserSession.java View source code Vote up 6 votes
private void wrapContentsOfTagsWithCData(Document document, String tagName) {
    NodeList tags = document.getElementsByTagName(tagName);
    for (int i = 0; i < tags.getLength(); i++) {
        Node item = tags.item(i);
        CDATASection section = document.createCDATASection(item.getTextContent());
        while (item.hasChildNodes()) {
            item.removeChild(item.getFirstChild());
        }
        item.appendChild(section);
    }
}
 
Example 14
Project: keycloak   File: DocumentUtil.java View source code Vote up 6 votes
/**
 * DOM3 method: Normalize the document with namespaces
 *
 * @param doc
 *
 * @return
 */
public static Document normalizeNamespaces(Document doc) {
    DOMConfiguration docConfig = doc.getDomConfig();
    docConfig.setParameter("namespaces", Boolean.TRUE);
    doc.normalizeDocument();
    return doc;
}
 
Example 15
Project: eadventure   File: StringWriter.java View source code Vote up 6 votes
public boolean write(OutputStream outputStream,
		Map<EAdString, String> strings) {
	try {
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		TransformerFactory tf = TransformerFactory.newInstance();
		DocumentBuilder db = dbf.newDocumentBuilder();
		Document doc = db.newDocument();

		Element mainNode = doc.createElement("resources");

		for (Entry<EAdString, String> entry : strings.entrySet()) {
			Element newElement = doc.createElement("string");
			newElement.setAttribute("name", entry.getKey().toString());
			newElement.setTextContent(entry.getValue());
			Node newNode = doc.adoptNode(newElement);
			mainNode.appendChild(newNode);
		}
		doc.adoptNode(mainNode);
		doc.appendChild(mainNode);

		Transformer transformer = tf.newTransformer();

		OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
				outputStream, "UTF-8");
		transformer.transform(new DOMSource(doc), new StreamResult(
				outputStreamWriter));
		outputStreamWriter.close();

		return true;
	} catch (Exception e) {
		logger.error("Could not write strings file", e);
		return false;
	}
}
 
Example 16
Project: cms-ce   File: XMLTool.java View source code Vote up 6 votes
public static Element createRootElement( Document doc, String name )
{
    Preconditions.checkNotNull(name, "Root element name cannot be null!" );
    Preconditions.checkArgument(name.trim().length() != 0, "Root element name has to contain at least one character!" );

    // remove old root
    NodeList nodes = doc.getChildNodes();
    Node[] element = filterNodes( nodes, Node.ELEMENT_NODE );
    for ( int i = 0; i < element.length; i++ )
    {
        doc.removeChild( element[i] );
    }

    // create and append the new root
    Element root = doc.createElement( name );
    doc.appendChild( root );

    return root;
}
 
Example 17
Project: beowulf   File: Location.java View source code Vote up 6 votes
private URL getURL() {

		URL url;
		try {
			Document document = this.window.getDocumentNode();
			url = document == null ? null : new URL(document.getDocumentURI());
		} catch (java.net.MalformedURLException mfu) {
			url = null;
		}
		return url;
	}
 
Example 18
Project: uPortal   File: RDBMDistributedLayoutStore.java View source code Vote up 6 votes
/**
 * Handles locking and identifying proper root and namespaces that used to
 * take place in super class.
 *
 * @param person
 * @param profile
 * @return
 * @
 */
private Document _safeGetUserLayout(IPerson person, IUserProfile profile)

{
    Document layoutDoc;
    Tuple<String, String> key = null;

    final Cache<Tuple<String, String>, Document> layoutCache = getLayoutImportExportCache();
    if (layoutCache != null) {
        key = new Tuple<String, String>(person.getUserName(), profile.getProfileFname());
        layoutDoc = layoutCache.getIfPresent(key);
        if (layoutDoc != null) {
            return (Document) layoutDoc.cloneNode(true);
        }
    }

    layoutDoc = super.getPersonalUserLayout(person, profile);
    Element layout = layoutDoc.getDocumentElement();
    layout.setAttribute(Constants.NS_DECL, Constants.NS_URI);

    if (layoutCache != null && key != null) {
        layoutCache.put(key, (Document) layoutDoc.cloneNode(true));
    }

    return layoutDoc;
}
 
Example 19
Project: easy-mail   File: HtmlProcessor.java View source code Vote up 6 votes
private static String getHtmlBodyAsString(final Document doc) throws TransformerException {
    StringWriter writer = new StringWriter();
    StreamResult result = new StreamResult(writer);

    Node body = doc.getElementsByTagName("body").item(0);
    doc.renameNode(body, "", "div");

    javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(body);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    transformer.transform(domSource, result);

    final String content = writer.toString();
    return content.substring(content.indexOf("<div"));
}
 
Example 20
Project: hise   File: DOMUtils.java View source code Vote up 6 votes
/**
 * Convert a DOM node to a stringified XML representation.
 */
static public String domToString(Node node) {
    if (node == null) {
        throw new IllegalArgumentException("Cannot stringify null Node!");
    }

    String value = null;
    short nodeType = node.getNodeType();
    if (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE) {
        // serializer doesn't handle Node type well, only Element
        DOMSerializerImpl ser = new DOMSerializerImpl();
        ser.setParameter(Constants.DOM_NAMESPACES, Boolean.TRUE);
        ser.setParameter(Constants.DOM_WELLFORMED, Boolean.FALSE );
        ser.setParameter(Constants.DOM_VALIDATE, Boolean.FALSE);

        // create a proper XML encoding header based on the input document;
        // default to UTF-8 if the parent document's encoding is not accessible
        String usedEncoding = "UTF-8";
        Document parent = node.getOwnerDocument();
        if (parent != null) {
            String parentEncoding = parent.getXmlEncoding();
            if (parentEncoding != null) {
                usedEncoding = parentEncoding;
            }
        }

        // the receiver of the DOM
        DOMOutputImpl out = new DOMOutputImpl();
        out.setEncoding(usedEncoding);

        // we write into a String
        StringWriter writer = new StringWriter(4096);
        out.setCharacterStream(writer);

        // out, ye characters!
        ser.write(node, out);
        writer.flush();

        // finally get the String
        value = writer.toString();
    } else {
        value = node.getNodeValue();
    }
    return value;
}
 
Example 21
Project: resin   File: AbstractParser.java View source code Vote up 6 votes
/**
 * Parses a document from a VFS path
 *
 * @param path the VFS path containing the XML document.
 */
public Document parseDocument(Path path)
  throws IOException, SAXException
{
  if (_searchPath == null)
    _searchPath = path.getParent();
  
  ReadStream is = path.openRead();
  try {
    Document document = parseDocument(is);
    document.setDocumentURI(path.getURL());

    return document;
  } finally {
    is.close();
  }
}
 
Example 22
Project: JDK   File: C14nHelper.java View source code Vote up 6 votes
/**
 * This method throws a CanonicalizationException if the supplied Document
 * is not able to be traversed using a TreeWalker.
 *
 * @param document
 * @throws CanonicalizationException
 */
public static void checkTraversability(Document document)
        throws CanonicalizationException {

   if (!document.isSupported("Traversal", "2.0")) {
      Object exArgs[] = {
         document.getImplementation().getClass().getName() };

      throw new CanonicalizationException(
         "c14n.Canonicalizer.TraversalNotSupported", exArgs);
   }
}
 
Example 23
Project: resin   File: DOMDocument.java View source code Vote up 6 votes
private void saveToStream(DOMNode delegate, WriteStream os, boolean isHTML)
  throws IOException
{
  XmlPrinter printer = new XmlPrinter(os);

  printer.setMethod(isHTML ? "html" : "xml");

  printer.setEncoding(_encoding);
  if(delegate._delegate instanceof Document)
  {
      /*
      Print the XML Declaration ( the <?xml thing ) only for Documents,
      as they don't make sense when just printing nodes.
       */
      printer.setPrintDeclaration(true);

      Document document = (Document) delegate._delegate;
      printer.setVersion(document.getXmlVersion());
      if (document.getXmlStandalone()){
          printer.setStandalone("yes");
      }
      printer.printXml(document);
  }
    else
  {
      printer.printXml((org.w3c.dom.Node) delegate._delegate);
  }

  if (hasChildNodes())
    os.println();
}
 
Example 24
Project: mlo-net   File: SerdesTest.java View source code Vote up 6 votes
private boolean isEqualXml(String xml1, File xmlfile) throws Throwable {
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	dbf.setNamespaceAware(true);
	dbf.setCoalescing(true);
	dbf.setIgnoringElementContentWhitespace(true);
	dbf.setIgnoringComments(true);
	
	DocumentBuilder db = dbf.newDocumentBuilder();
	InputStream istream1 = null;
	InputStream istream2 = null;
	Document doc1 = null;
	Document doc2 = null;

	try {
		istream1 = new ByteArrayInputStream(xml1.getBytes("UTF-8"));
		doc1 = db.parse(istream1);
		doc1.normalizeDocument();
	
		istream2 = new FileInputStream(xmlfile);
		doc2 = db.parse(istream2);
		doc2.normalizeDocument();
	} finally {
		if (istream1 != null) {
			istream1.close();
		}
		if (istream2 != null) {
			istream2.close();
		}
	}
	
	return doc1.isEqualNode(doc2);
}
 
Example 25
Project: extension-aws   File: ElasticPostMailStatus.java View source code Vote up 6 votes
public static ElasticPostMailStatus parseXML(String xml){
	ElasticPostMailStatus status = new ElasticPostMailStatus();
	status.setSent(false);
	try{
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setNamespaceAware(true);
		DocumentBuilder dBuilder = factory.newDocumentBuilder();
		Document doc = dBuilder.parse(new InputSource(new StringReader(xml)));
		if (doc.hasChildNodes()){
			NodeList nl = doc.getChildNodes();
			processNodes(nl,status);
		}
	} catch (Exception e){
		e.printStackTrace();
		throw new OpenEditException(e.getMessage(),e);
	}
	return status;
}
 
Example 26
Project: automation-test-engine   File: TestDatabaseInitializer.java View source code Vote up 5 votes
/**
 * Combine init xml files.
 *
 * @return the input stream
 */
private InputStream combineInitXmlFiles() {
	if (getInitXmlFiles().isEmpty()) {
		throw GlobalUtils
				.createNotInitializedException("xml data files are not populated");
	} else {
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		dbf.setValidating(false);
		DocumentBuilder dbuilder;
		try {
			dbuilder = dbf.newDocumentBuilder();

			Document retDoc = dbuilder.newDocument();
			Document doc0;

			doc0 = dbuilder.parse(getInitXmlFiles().get(0));

			Node firstDataset = retDoc.importNode(doc0.getFirstChild(),
					true);
			retDoc.appendChild(firstDataset);
			for (int i = 1; i < getInitXmlFiles().size(); i++) {
				Document doc2 = dbuilder.parse(getInitXmlFiles().get(i));
				Node root = doc2.getFirstChild();
				NodeList list = root.getChildNodes();
				for (int index = 0; index < list.getLength(); index++) {
					Node copiedNode = retDoc.importNode(list.item(index),
							true);
					retDoc.getDocumentElement().appendChild(copiedNode);
				}
			}

			DOMSource source = new DOMSource(retDoc);
			StringWriter xmlAsWriter = new StringWriter();

			StreamResult result = new StreamResult(xmlAsWriter);

			TransformerFactory.newInstance().newTransformer()
					.transform(source, result);

			// write changes
			return new ByteArrayInputStream(xmlAsWriter.toString()
					.getBytes("UTF-8"));

		} catch (SAXException | IOException | ParserConfigurationException e) {
			throw GlobalUtils.createNotInitializedException(
					"xml data files are not correctly populated", e);
		} catch (TransformerException
				| TransformerFactoryConfigurationError transE) {
			throw GlobalUtils.createInternalError("xml transformer error!",
					transE);
		}

	}
}
 
Example 27
Project: java-csp   File: SignTest.java View source code Vote up 5 votes
@Test
	public void test() throws Exception {
		if(signKeys.isEmpty())
			return;
		
		String templateName = "signature-enveloping-gost-template.xml";
		InputStream inputStream = getClass().getClassLoader().getResourceAsStream(templateName);

		assertNotNull("?? ?????? ???? " + templateName, templateName);

		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		Document doc = dbf.newDocumentBuilder().parse(inputStream);

		CSPNative.closeSilently(inputStream);

		// Find Signature element
		NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
		if (nl.getLength() == 0) {
			throw new Exception("Cannot find Signature element");
		}
		DOMStructure domSignature = new DOMStructure(nl.item(0));
		// unmarshal the XMLSignature
		XMLSignature signature = fac.unmarshalXMLSignature(domSignature);

		// create copy of Signature
		XMLSignature newSignature = fac.newXMLSignature(
				signature.getSignedInfo(), 
				null, 
				signature.getObjects(),
				signature.getId(), 
				signature.getSignatureValue().getId());

		// Sign the template
		Node parent = domSignature.getNode().getParentNode();
		DOMSignContext signContext = new DOMSignContext(signKeys.get(0), parent);
		
		// ????????????? ??????? ?????????? ????????, ??????? ????? ???????? ???? ??? ???????
		signContext.setProperty("org.jcp.xml.dsig.internal.dom.SignatureProvider", Security.getProvider(CSP_PROVIDER));
		
		// remove the signature node (since it will get recreated)
		parent.removeChild(domSignature.getNode());
		newSignature.sign(signContext);
//		TestUtils.validateSecurityOrEncryptionElement(parent.getLastChild());

		// check that Object element retained namespace definitions
		Element objElem = (Element)parent.getFirstChild().getLastChild();
		Attr a = objElem.getAttributeNode("xmlns:test");
		if (!a.getValue().equals("http://www.example.org/ns"))
			throw new Exception("Object namespace definition not retained");
		
		System.out.format("XML ???????? ? ????????:\n----- Begin XML Document ------\n%s\n----- End XML Document ------\n",
				domToString(doc));
	}
 
Example 28
Project: android-essentials-toolbox   File: ConvertPScoutToXML.java View source code Vote up 5 votes
public static void main(String[] args) throws FileNotFoundException, ParserConfigurationException, IOException, TransformerException {
		String permissionName = "";
		Element permission = null;
		Element call = null;

		// create a file object that points at the file to parse
		File file = new File(args[0]);
		String tag = args[1]; // android api name

		// initialization to create xml file
		// to store all info of methods in the mapping
		DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
		Document document = documentBuilder.newDocument();
		Element permissions = document.createElement("permissions");
		document.appendChild(permissions);

		// read to read the file
		Scanner scanner = new Scanner(file);
		while (scanner.hasNextLine()) {
			// read one line of the input file
			String line = scanner.nextLine();

			if (line.charAt(0) == 'P') {
				// get the permission name if this is a permission line
				permissionName = line.substring(11);

				// define permission elements in xml
				permission = document.createElement("permission");
				permissions.appendChild(permission);
				Attr attribute = document.createAttribute("name");
				attribute.setValue(permissionName);
				permission.setAttributeNode(attribute);

			} else if (line.charAt(0) != 'P' && line.charAt(0) != '<') {
				// get the number of methods to read if this is callers line
//				int spaceindex = line.indexOf(" ");
//				int numberOfMethods = Integer.parseInt(line.substring(0, spaceindex));
			} else {
				// read the method if this is method line
				String qualifiedClass = line.substring(1, line.indexOf(":"));

				// parse the package
				String packageName = qualifiedClass.substring(0, (qualifiedClass.lastIndexOf(".")));

				// parse the class
				String className = qualifiedClass.substring((qualifiedClass.lastIndexOf(".") + 1), qualifiedClass.length());

				// parse the return type
				String line2 = line.substring(line.indexOf(":") + 1, line.indexOf("("));
				String qualifiedMethodTrimmed = line2.trim();
				String methodNameWithReturnType[] = qualifiedMethodTrimmed.split(" ");
				String qualifiedMethodReturnType = methodNameWithReturnType[0];
				String unqualifiedMethodReturnType = qualifiedMethodReturnType;
				if (qualifiedMethodReturnType.contains(".")) {
					unqualifiedMethodReturnType = qualifiedMethodReturnType.substring(qualifiedMethodReturnType.lastIndexOf(".") + 1);
				}

				// parse the method name
				String methodName = methodNameWithReturnType[1];

				// parse the parameters
				String line3 = line.substring(line.indexOf("(") + 1, line.indexOf(")"));
				String parameterArry[] = line3.split(",");

				// create call elements under permission elements
				call = document.createElement("call");
				permission.appendChild(call);

				// create package elements under call elements
				Element pkg = document.createElement("package");
				pkg.appendChild(document.createTextNode(packageName));
				call.appendChild(pkg);

				// create class elements under call elements
				Element clazz = document.createElement("class");
				clazz.appendChild(document.createTextNode(className));
				call.appendChild(clazz);

				// create method elements under call elements
				Element method = document.createElement("method");
				method.appendChild(document.createTextNode(methodName));
				call.appendChild(method);

				// create returnType elements under call elements
				Element returnType = document.createElement("returnType");
				returnType.appendChild(document.createTextNode(unqualifiedMethodReturnType));
				call.appendChild(returnType);

				// create parameters elements under call elements
				Element parameters = document.createElement("parameters");
				call.appendChild(parameters);
				// create parameter elements under parameters elements
				for (String paramName : parameterArry) {
					if (paramName == null || paramName.equals(""))
						break;
					Element parameter = document.createElement("parameter");
					parameter.appendChild(document.createTextNode(paramName));
					parameters.appendChild(parameter);
				}
			} // end read method line
		} // end read file

		// creating and writing to xml file
		TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
		DOMSource domSource = new DOMSource(document);
		String filename = tag + "PermissionMapping.xml";
		File outputFile = new File(filename);
		StreamResult streamResult = new StreamResult(outputFile);
		transformer.transform(domSource, streamResult);
		scanner.close();

		System.out.println("Wrote: " + outputFile.getAbsolutePath());
	}
 
Example 29
Project: ISAcreator   File: AcceptedOntologiesLoader.java View source code Vote up 5 votes
public static void populateAcceptedOntologies() {

        System.out.println("_____populateAcceptedOntologies()____");
        BioPortal4Client client = new BioPortal4Client();

        Collection<Ontology> ontologies = client.getAllOntologies();

        System.out.println("Found " + ontologies.size() + " ontologies \n");

        try {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

            // root elements
            Document doc = docBuilder.newDocument();

            Comment comment = doc.createComment("Defines the accepted ontologies for BioPortal");
            doc.appendChild(comment);


            Element rootElement = doc.createElement("acceptedOntologies");
            doc.appendChild(rootElement);

            //<acceptedOntology abbreviation="OBI" id="1123"/>
            for (Ontology ontology : ontologies) {

                Element acceptedOntologyElement = doc.createElement("acceptedOntology");

                Attr abbreviation = doc.createAttribute("abbreviation");
                abbreviation.setValue(ontology.getOntologyAbbreviation());
                acceptedOntologyElement.setAttributeNode(abbreviation);

                Attr name = doc.createAttribute("name");
                name.setValue(ontology.getOntologyDisplayLabel());
                acceptedOntologyElement.setAttributeNode(name);

                Attr version = doc.createAttribute("version");
                version.setValue(ontology.getSubmissionId());
                acceptedOntologyElement.setAttributeNode(version);

                Attr uri = doc.createAttribute("uri");
                uri.setValue(ontology.getHomepage());
                acceptedOntologyElement.setAttributeNode(uri);

                Attr id = doc.createAttribute("id");
                id.setValue(ontology.getOntologyID());
                acceptedOntologyElement.setAttributeNode(id);

                rootElement.appendChild(acceptedOntologyElement);

            }


            // write the content into xml file
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            Transformer transformer = transformerFactory.newTransformer();
            DOMSource source = new DOMSource(doc);

            String fullPath = FILE;

            File outputFile = new File(fullPath);

            StreamResult result = new StreamResult(outputFile.getAbsolutePath());
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

            transformer.transform(source, result);

        } catch (ParserConfigurationException pce) {
            pce.printStackTrace();
        } catch (TransformerException tfe) {
            tfe.printStackTrace();
        }

    }
 
Example 30
Project: p2-bridge   File: ArtifactRepositoryService.java View source code Vote up 5 votes
private void generateArtifactMappings( final Collection<IArtifactDescriptor> artifactDescriptors,
                                       final Collection<SimpleArtifactRepository> artifactRepositories,
                                       final File destination )
{
    final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try
    {
        final DocumentBuilder db = dbf.newDocumentBuilder();
        final Document doc = db.newDocument();
        doc.setXmlStandalone( true );
        final Element rootElement = doc.createElement( "repositories" );
        doc.appendChild( rootElement );
        for ( final SimpleArtifactRepository repository : artifactRepositories )
        {
            final URI repositoryURI = repository.getLocation();

            final Element repositoryElement = doc.createElement( "repository" );
            rootElement.appendChild( repositoryElement );
            repositoryElement.setAttribute( "uri", repositoryURI.toString() );
            final String mirrorsURL = repository.getProperties().get( IRepository.PROP_MIRRORS_URL );
            if ( mirrorsURL != null )
            {
                repositoryElement.setAttribute( IRepository.PROP_MIRRORS_URL, mirrorsURL );
            }

            final Iterator<IArtifactDescriptor> iterArtifactDescriptors = artifactDescriptors.iterator();
            while ( iterArtifactDescriptors.hasNext() )
            {
                final IArtifactDescriptor artifactDescriptor = iterArtifactDescriptors.next();
                if ( repository.contains( artifactDescriptor ) )
                {
                    final Element artifactElement = doc.createElement( "artifact" );
                    if ( "0".equals( artifactDescriptor.getProperty( "download.size" ) ) )
                    {
                        continue;
                    }
                    final URI remoteArtifactUri = repository.getLocation( artifactDescriptor );
                    if ( remoteArtifactUri == null )
                    {
                        if ( "packed".equals( artifactDescriptor.getProperty( "format" ) ) )
                        {
                            // Some repositories contain packed artifacts,
                            // but they don't have rules to handle them,
                            // so the packed artifacts cannot be reached,
                            // but that's usually fine because the same
                            // artifact is available unpacked too (usually).
                        }
                        else
                        {
                            throw new RuntimeException( "Cannot get remote path for repository '"
                                                            + repository.getName() + "', artifact '"
                                                            + artifactDescriptor + "'." );
                        }
                    }
                    else
                    {
                        String remotePath = remoteArtifactUri.getPath();
                        if ( remotePath.startsWith( repositoryURI.getPath() ) )
                        {
                            remotePath = remotePath.substring( repositoryURI.getPath().length() );
                            if ( !remotePath.startsWith( "/" ) )
                            {
                                remotePath = "/" + remotePath;
                            }
                            artifactElement.setAttribute( "remotePath", remotePath );

                            final String md5 = artifactDescriptor.getProperty( "download.md5" );
                            if ( md5 != null )
                            {
                                artifactElement.setAttribute( "md5", md5 );
                            }

                            repositoryElement.appendChild( artifactElement );
                        }
                        else
                        {
                            throw new RuntimeException( "Could not get remote path for artifact "
                                                            + artifactDescriptor );
                        }

                        iterArtifactDescriptors.remove();
                    }
                }
            }
        }
        rootElement.setAttribute( "size", "" + artifactRepositories.size() );

        final TransformerFactory transformerFactory = TransformerFactory.newInstance();
        // transformerFactory.setAttribute( "indent-number", "2" );
        final Transformer transformer = transformerFactory.newTransformer();
        transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
        transformer.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", "2" );
        final DOMSource source = new DOMSource( doc );
        final OutputStream os = new FileOutputStream( destination );
        try
        {
            final StreamResult result = new StreamResult( os );
            transformer.transform( source, result );
        }
        finally
        {
            os.close();
        }
    }
    catch ( final Exception e )
    {
        throw new RuntimeException( "Could not generate artifact mappings file", e );
    }
}
 
Example 31
Project: JFugue-for-Android   File: DOMUtil.java View source code Vote up 5 votes
/**
 * Copies the source tree into the specified place in a destination
 * tree. The source node and its children are appended as children
 * of the destination node.
 * <p>
 * <em>Note:</em> This is an iterative implementation.
 */
public static void copyInto(Node src, Node dest) throws DOMException {
    
    // get node factory
    Document factory = dest.getOwnerDocument();
    boolean domimpl = factory instanceof DocumentImpl;
    
    // placement variables
    Node start  = src;
    Node parent = src;
    Node place  = src;
    
    // traverse source tree
    while (place != null) {
        
        // copy this node
        Node node = null;
        int  type = place.getNodeType();
        switch (type) {
        case Node.CDATA_SECTION_NODE: {
            node = factory.createCDATASection(place.getNodeValue());
            break;
        }
        case Node.COMMENT_NODE: {
            node = factory.createComment(place.getNodeValue());
            break;
        }
        case Node.ELEMENT_NODE: {
            Element element = factory.createElement(place.getNodeName());
            node = element;
            NamedNodeMap attrs  = place.getAttributes();
            int attrCount = attrs.getLength();
            for (int i = 0; i < attrCount; i++) {
                Attr attr = (Attr)attrs.item(i);
                String attrName = attr.getNodeName();
                String attrValue = attr.getNodeValue();
                element.setAttribute(attrName, attrValue);
                if (domimpl && !attr.getSpecified()) {
                    ((AttrImpl)element.getAttributeNode(attrName)).setSpecified(false);
                }
            }
            break;
        }
        case Node.ENTITY_REFERENCE_NODE: {
            node = factory.createEntityReference(place.getNodeName());
            break;
        }
        case Node.PROCESSING_INSTRUCTION_NODE: {
            node = factory.createProcessingInstruction(place.getNodeName(),
                    place.getNodeValue());
            break;
        }
        case Node.TEXT_NODE: {
            node = factory.createTextNode(place.getNodeValue());
            break;
        }
        default: {
            throw new IllegalArgumentException("can't copy node type, "+
                    type+" ("+
                    node.getNodeName()+')');
        }
        }
        dest.appendChild(node);
        
        // iterate over children
        if (place.hasChildNodes()) {
            parent = place;
            place  = place.getFirstChild();
            dest   = node;
        }
        
        // advance
        else {
            place = place.getNextSibling();
            while (place == null && parent != start) {
                place  = parent.getNextSibling();
                parent = parent.getParentNode();
                dest   = dest.getParentNode();
            }
        }
        
    }
    
}
 
Example 32
Project: latexdraw   File: PreferencesSetter.java View source code Vote up 5 votes
/**
 * Writes the preferences of latexdraw in an XML document.
 * 
 * @since 3.0
 */
public void writeXMLPreferences() {
	try {
		try(final FileOutputStream fos = new FileOutputStream(LPath.PATH_PREFERENCES_XML_FILE)) {
			final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
			Stage frame = (Stage)pathExportField.getScene().getWindow();
			Rectangle2D rec = Screen.getPrimary().getBounds();
			final Element root;
			Element elt;
			Element elt2;

			document.setXmlVersion("1.0");//$NON-NLS-1$
			document.setXmlStandalone(true);
			root = document.createElement(LNamespace.XML_ROOT_PREFERENCES);
			document.appendChild(root);

			final Attr attr = document.createAttribute(LNamespace.XML_VERSION);
			attr.setTextContent(VersionChecker.VERSION);
			root.setAttributeNode(attr);

			elt = document.createElement(LNamespace.XML_PATH_EXPORT);
			elt.setTextContent(pathExportField.getText());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_PATH_OPEN);
			elt.setTextContent(pathOpenField.getText());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_DISPLAY_GRID);
			elt.setTextContent(String.valueOf(styleList.getSelectionModel().getSelectedItem()!=GridStyle.NONE));
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_UNIT);
			elt.setTextContent(unitChoice.getSelectionModel().getSelectedItem().toString());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_CHECK_VERSION);
			elt.setTextContent(String.valueOf(checkNewVersion.isSelected()));
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_LANG);
			elt.setTextContent(langList.getSelectionModel().getSelectedItem().toString());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_MAGNETIC_GRID);
			elt.setTextContent(String.valueOf(magneticCB.isSelected()));
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_CLASSIC_GRID);
			if(styleList.getSelectionModel().getSelectedItem()==GridStyle.STANDARD)
				elt.setTextContent(Boolean.TRUE.toString());
			else
				elt.setTextContent(Boolean.FALSE.toString());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_GRID_GAP);
			elt.setTextContent(persoGridGapField.getValue().toString());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_LATEX_INCLUDES);
			elt.setTextContent(latexIncludes.getText());
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_RECENT_FILES);
			elt.setAttribute(LNamespace.XML_NB_RECENT_FILES, nbRecentFilesField.getValue().toString());
			root.appendChild(elt);

			for(final String recentFile : recentFilesName) {
				elt2 = document.createElement(LNamespace.XML_RECENT_FILE);
				elt2.setTextContent(recentFile);
				elt.appendChild(elt2);
			}

			elt = document.createElement(LNamespace.XML_MAXIMISED);
			elt.setTextContent(String.valueOf(frame.isMaximized()));
			root.appendChild(elt);

			elt = document.createElement(LNamespace.XML_SIZE);
			root.appendChild(elt);

			elt2 = document.createElement(LNamespace.XML_WIDTH);
			elt2.setTextContent(String.valueOf(frame.getWidth()));
			elt.appendChild(elt2);

			elt2 = document.createElement(LNamespace.XML_HEIGHT);
			elt2.setTextContent(String.valueOf(frame.getHeight()));
			elt.appendChild(elt2);

			elt = document.createElement(LNamespace.XML_POSITION);
			root.appendChild(elt);

			elt2 = document.createElement(LNamespace.XML_POSITION_X);
			elt2.setTextContent(String.valueOf((int)(frame.getX()-rec.getMinX())));
			elt.appendChild(elt2);

			elt2 = document.createElement(LNamespace.XML_POSITION_Y);
			elt2.setTextContent(String.valueOf((int)(frame.getY()-rec.getMinY())));
			elt.appendChild(elt2);

			final Transformer transformer = TransformerFactory.newInstance().newTransformer();
			transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
			transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
			transformer.transform(new DOMSource(document), new StreamResult(fos));
		}
	}catch(final Exception e) {
		BadaboomCollector.INSTANCE.add(e);
	}
}
 
Example 33
Project: beowulf   File: HTMLAbstractUIElement.java View source code Vote up 5 votes
public Function getEventFunction(Function varValue, String attributeName) {

		if (varValue != null) {
			return varValue;
		}
		String normalAttributeName = this.normalizeAttributeName(attributeName);
		synchronized (this) {
			Map fba = this.functionByAttribute;
			Function f = fba == null ? null : (Function) fba.get(normalAttributeName);
			if (f != null) {
				return f;
			}
			UserAgentContext uac = this.getUserAgentContext();
			if (uac == null) {
				throw new IllegalStateException("No user agent context.");
			}
			if (uac.isScriptingEnabled()) {
				String attributeValue = this.getAttribute(attributeName);
				if (attributeValue == null || attributeValue.length() == 0) {
					f = null;
				} else {
					String functionCode = "function " + normalAttributeName + "_" + System.identityHashCode(this) + "() { " + attributeValue + " }";
					Document doc = this.document;
					if (doc == null) {
						throw new IllegalStateException("Element does not belong to a document.");
					}
					Context ctx = Executor.createContext(this.getDocumentURL(), uac);
					try {
						Scriptable scope = (Scriptable) doc.getUserData(Executor.SCOPE_KEY);
						if (scope == null) {
							throw new IllegalStateException("Scriptable (scope) instance was expected to be keyed as UserData to document using "
									+ Executor.SCOPE_KEY);
						}
						Scriptable thisScope = (Scriptable) JavaScript.getInstance().getJavascriptObject(this, scope);
						try {
							// TODO: Get right line number for script. //TODO:
							// Optimize this in case it's called multiple times?
							// Is that done?
							f = ctx.compileFunction(thisScope, functionCode, this.getTagName() + "[" + this.getId() + "]." + attributeName, 1, null);
						} catch (EcmaError ecmaError) {
							logger.log(Level.WARNING, "Javascript error at " + ecmaError.getSourceName() + ":" + ecmaError.getLineNumber() + ": "
									+ ecmaError.getMessage(), ecmaError);
							f = null;
						} catch (Throwable err) {
							logger.log(Level.WARNING, "Unable to evaluate Javascript code", err);
							f = null;
						}
					} finally {
						Context.exit();
					}
				}
				if (fba == null) {
					fba = new HashMap(1);
					this.functionByAttribute = fba;
				}
				fba.put(normalAttributeName, f);
			}
			return f;
		}
	}
 
Example 34
Project: keycloak   File: XMLEncryptionUtil.java View source code Vote up 5 votes
/**
 * Encrypt the root document element inside a Document. <b>NOTE:</> The document root element will be replaced by
 * the
 * wrapping element.
 *
 * @param document Document that contains an element to encrypt
 * @param publicKey The Public Key used to encrypt the secret encryption key
 * @param secretKey The secret encryption key
 * @param keySize Length of key
 * @param wrappingElementQName QName of the element to be used to wrap around the cipher data.
 * @param addEncryptedKeyInKeyInfo Should the encrypted key be inside a KeyInfo or added as a peer of Cipher Data
 *
 * @return An element that has the wrappingElementQName
 *
 * @throws ProcessingException
 * @throws org.keycloak.saml.common.exceptions.ConfigurationException
 */
public static Element encryptElementInDocument(Document document, PublicKey publicKey, SecretKey secretKey, int keySize,
                                               QName wrappingElementQName, boolean addEncryptedKeyInKeyInfo) throws ProcessingException, ConfigurationException {
    String wrappingElementPrefix = wrappingElementQName.getPrefix();
    if (wrappingElementPrefix == null || wrappingElementPrefix == "")
        throw logger.wrongTypeError("Wrapping element prefix invalid");

    XMLCipher cipher = null;
    EncryptedKey encryptedKey = encryptKey(document, secretKey, publicKey, keySize);

    String encryptionAlgorithm = getXMLEncryptionURL(secretKey.getAlgorithm(), keySize);
    // Encrypt the Document
    try {
        cipher = XMLCipher.getInstance(encryptionAlgorithm);
        cipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
    } catch (XMLEncryptionException e1) {
        throw logger.configurationError(e1);
    }

    Document encryptedDoc;
    try {
        encryptedDoc = cipher.doFinal(document, document.getDocumentElement());
    } catch (Exception e) {
        throw logger.processingError(e);
    }

    // The EncryptedKey element is added
    Element encryptedKeyElement = cipher.martial(document, encryptedKey);

    String wrappingElementName = wrappingElementPrefix + ":" + wrappingElementQName.getLocalPart();

    // Create the wrapping element and set its attribute NS
    Element wrappingElement = encryptedDoc.createElementNS(wrappingElementQName.getNamespaceURI(), wrappingElementName);

    if (StringUtil.isNullOrEmpty(wrappingElementPrefix)) {
        wrappingElementName = wrappingElementQName.getLocalPart();
    }
    wrappingElement.setAttributeNS(XMLNS, "xmlns:" + wrappingElementPrefix, wrappingElementQName.getNamespaceURI());

    Element encryptedDocRootElement = encryptedDoc.getDocumentElement();
    // Bring in the encrypted wrapping element to wrap the root node
    encryptedDoc.replaceChild(wrappingElement, encryptedDocRootElement);

    wrappingElement.appendChild(encryptedDocRootElement);

    if (addEncryptedKeyInKeyInfo) {
        // Outer ds:KeyInfo Element to hold the EncryptionKey
        Element sigElement = encryptedDoc.createElementNS(XMLSIG_NS, DS_KEY_INFO);
        sigElement.setAttributeNS(XMLNS, "xmlns:ds", XMLSIG_NS);
        sigElement.appendChild(encryptedKeyElement);

        // Insert the Encrypted key before the CipherData element
        NodeList nodeList = encryptedDocRootElement.getElementsByTagNameNS(XMLENC_NS, CIPHER_DATA_LOCALNAME);
        if (nodeList == null || nodeList.getLength() == 0)
            throw logger.domMissingElementError("xenc:CipherData");

        Element cipherDataElement = (Element) nodeList.item(0);
        encryptedDocRootElement.insertBefore(sigElement, cipherDataElement);
    } else {
        // Add the encrypted key as a child of the wrapping element
        wrappingElement.appendChild(encryptedKeyElement);
    }

    return encryptedDoc.getDocumentElement();
}