org.w3c.dom.Element

Here are the examples of the java api class org.w3c.dom.Element taken from open source projects.

1. OntologyToOwl#createErrorPropertyElement()

Project: lumify
Source File: OntologyToOwl.java
View license
private Element createErrorPropertyElement(String propertyIri, String displayName) {
    Element datatypePropertyElement = createDatatypePropertyElement(propertyIri + PtPropertyType.ERROR_SUFFIX);
    addLabel(datatypePropertyElement, displayName + " Error");
    Element searchableElement = exportDoc.createElementNS(ns.getNamespaceURI("lumify"), "lumify:searchable");
    searchableElement.appendChild(exportDoc.createTextNode("false"));
    datatypePropertyElement.appendChild(searchableElement);
    Element addableElement = exportDoc.createElementNS(ns.getNamespaceURI("lumify"), "lumify:addable");
    addableElement.appendChild(exportDoc.createTextNode("false"));
    datatypePropertyElement.appendChild(addableElement);
    Element textIndexHintsElement = exportDoc.createElementNS(ns.getNamespaceURI("lumify"), "lumify:textIndexHints");
    textIndexHintsElement.appendChild(exportDoc.createTextNode("NONE"));
    datatypePropertyElement.appendChild(textIndexHintsElement);
    Element rangeElement = exportDoc.createElementNS(ns.getNamespaceURI("rdfs"), "rdfs:range");
    rangeElement.setAttributeNS(ns.getNamespaceURI("rdf"), "rdf:resource", "http://www.w3.org/2001/XMLSchema#string");
    datatypePropertyElement.appendChild(rangeElement);
    return datatypePropertyElement;
}

2. ContextNamesCommand#run()

Project: jphp
Source File: ContextNamesCommand.java
View license
@Override
public void run(Debugger context, CommandArguments args, Document result) {
    Element response = createResponse(args, result);
    Element localContext = result.createElement("context");
    localContext.setAttribute("name", "Local");
    localContext.setAttribute("id", "0");
    response.appendChild(localContext);
    Element globalContext = result.createElement("context");
    globalContext.setAttribute("name", "Global");
    globalContext.setAttribute("id", "1");
    response.appendChild(localContext);
    Element classContext = result.createElement("context");
    classContext.setAttribute("name", "Class");
    classContext.setAttribute("id", "2");
    response.appendChild(localContext);
}

3. XmlResultParser#generateFailureResponse()

Project: pdfbox
Source File: XmlResultParser.java
View license
protected Element generateFailureResponse(Document rdocument, String name, long duration, String pdfType, Exception e) {
    Element preflight = generateResponseSkeleton(rdocument, name, duration);
    // valid ?
    Element valid = rdocument.createElement("isValid");
    valid.setAttribute("type", pdfType);
    valid.setTextContent("false");
    preflight.appendChild(valid);
    // exception 
    Element exception = rdocument.createElement("exceptionThrown");
    Element message = rdocument.createElement("message");
    message.setTextContent(e.getMessage());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    pw.close();
    Element stack = rdocument.createElement("stackTrace");
    stack.setTextContent(sw.toString());
    exception.appendChild(message);
    exception.appendChild(stack);
    preflight.appendChild(exception);
    return preflight;
}

4. BuildFileGenerator#createBuild()

Project: che
Source File: BuildFileGenerator.java
View license
//    /**
//     * Create classpath tag.
//     * <path id="libs.dir">
//     * <fileset dir="lib" includes="**\/*\.jar"/>
//     * </path>
//     */
//    private void createClassPath() {
//        Element path = doc.createElement("path");
//        path.setAttribute("id", "libs.dir");
//
//        Element fieldSet = doc.createElement("fileset");
//        fieldSet.setAttribute("dir", "lib");
//        fieldSet.setAttribute("includes", "**/*.jar");
//
//        path.appendChild(fieldSet);
//
//        root.appendChild(path);
//    }
/**
     * Create build target tag.
     * <target depends="clean" description="Builds the application" name="build">
     * ...
     * </target>
     */
private void createBuild() {
    //Insert comment
    Comment buildComment = doc.createComment("Application build");
    root.appendChild(buildComment);
    //Create main target tag
    Element target = doc.createElement("target");
    target.setAttribute("name", "build");
    target.setAttribute("depends", "clean");
    target.setAttribute("description", "Builds the application");
    //Insert comment
    Comment createDirectoryComment = doc.createComment("Create directory");
    target.appendChild(createDirectoryComment);
    //Create mkdir tag inside target
    Element mkdir = doc.createElement("mkdir");
    mkdir.setAttribute("dir", "${build.classes}");
    target.appendChild(mkdir);
    //Insert comment
    Comment compileSourcesComment = doc.createComment("Compile source code");
    target.appendChild(compileSourcesComment);
    //Create javac tag inside target
    Element javac = doc.createElement("javac");
    javac.setAttribute("srcdir", "${src.dir}");
    javac.setAttribute("destdir", "${build.classes}");
    javac.setAttribute("debug", "false");
    javac.setAttribute("deprecation", "true");
    javac.setAttribute("optimize", "true");
    javac.setAttribute("includeantruntime", "true");
    //        //Create classpath tag inside javac
    //        Element classpath = doc.createElement("classpath");
    //        classpath.setAttribute("refid", "libs.dir");
    //        javac.appendChild(classpath);
    target.appendChild(javac);
    //Insert comment
    Comment copyNecessaryFiles = doc.createComment("Copy necessary files");
    target.appendChild(copyNecessaryFiles);
    //Create copy tag inside target
    Element copy = doc.createElement("copy");
    copy.setAttribute("todir", "${build.classes}");
    //Create fileset tag inside copy
    Element copyFileset = doc.createElement("fileset");
    copyFileset.setAttribute("dir", "${src.dir}");
    copyFileset.setAttribute("includes", "**/*.*");
    copyFileset.setAttribute("excludes", "**/*.java");
    copy.appendChild(copyFileset);
    target.appendChild(copy);
    //Insert comment
    Comment createJarComment = doc.createComment("Create JAR-file");
    target.appendChild(createJarComment);
    //Create jar tag inside target
    Element jar = doc.createElement("jar");
    jar.setAttribute("jarfile", "${build}/${name}.jar");
    //Create fileset tag inside jar
    Element jarFileset = doc.createElement("fileset");
    jarFileset.setAttribute("dir", "${build.classes}");
    jar.appendChild(jarFileset);
    target.appendChild(jar);
    root.appendChild(target);
}

5. XmlDataWriter#createDevice()

Project: uadetector
Source File: XmlDataWriter.java
View license
private static Element createDevice(final Device device, final Document doc) {
    final Element b = doc.createElement(Tag.DEVICE);
    final Element id = doc.createElement(Tag.ID);
    id.appendChild(doc.createTextNode(String.valueOf(device.getId())));
    b.appendChild(id);
    final Element name = doc.createElement(Tag.NAME);
    name.appendChild(doc.createTextNode(device.getName()));
    b.appendChild(name);
    final Element icon = doc.createElement(Tag.ICON);
    icon.appendChild(doc.createTextNode(device.getIcon()));
    b.appendChild(icon);
    final Element botInfoUrl = doc.createElement(Tag.DEVICE_INFO_URL);
    botInfoUrl.appendChild(doc.createTextNode(device.getInfoUrl()));
    b.appendChild(botInfoUrl);
    return b;
}

6. XPointerFactory#employees()

Project: lenya
Source File: XPointerFactory.java
View license
/**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
public Document employees() {
    DOMParserFactory dpf = new DOMParserFactory();
    Document doc = dpf.getDocument();
    Element michi = dpf.newElementNode(doc, "Employee");
    michi.setAttribute("Id", "0");
    michi.appendChild(dpf.newTextNode(doc, "Michi"));
    Element levi = dpf.newElementNode(doc, "Employee");
    levi.setAttribute("Id", "1");
    levi.appendChild(dpf.newTextNode(doc, "Levi"));
    Element employees = dpf.newElementNode(doc, "Employees");
    employees.appendChild(dpf.newTextNode(doc, "\n"));
    employees.appendChild(michi);
    employees.appendChild(dpf.newTextNode(doc, "\n"));
    employees.appendChild(levi);
    employees.appendChild(dpf.newTextNode(doc, "\n"));
    doc.appendChild(employees);
    return doc;
}

7. mxDomUtils#createVmlDocument()

Project: jgraphx
Source File: mxDomUtils.java
View license
/**
	 * 
	 */
public static Document createVmlDocument() {
    Document document = createDocument();
    Element root = document.createElement("html");
    root.setAttribute("xmlns:v", "urn:schemas-microsoft-com:vml");
    root.setAttribute("xmlns:o", "urn:schemas-microsoft-com:office:office");
    document.appendChild(root);
    Element head = document.createElement("head");
    Element style = document.createElement("style");
    style.setAttribute("type", "text/css");
    style.appendChild(document.createTextNode("<!-- v\\:* {behavior: url(#default#VML);} -->"));
    head.appendChild(style);
    root.appendChild(head);
    Element body = document.createElement("body");
    root.appendChild(body);
    return document;
}

8. mxDomUtils#createVmlDocument()

Project: consulo
Source File: mxDomUtils.java
View license
/**
   *
   */
public static Document createVmlDocument() {
    Document document = createDocument();
    Element root = document.createElement("html");
    root.setAttribute("xmlns:v", "urn:schemas-microsoft-com:vml");
    root.setAttribute("xmlns:o", "urn:schemas-microsoft-com:office:office");
    document.appendChild(root);
    Element head = document.createElement("head");
    Element style = document.createElement("style");
    style.setAttribute("type", "text/css");
    style.appendChild(document.createTextNode("<!-- v\\:* {behavior: url(#default#VML);} -->"));
    head.appendChild(style);
    root.appendChild(head);
    Element body = document.createElement("body");
    root.appendChild(body);
    return document;
}

9. ConfigFileServiceImpl#createLogginNode()

View license
private Element createLogginNode(Document document) {
    Element log4j = document.createElement("log4j:configuration");
    log4j.setAttribute("xmlns:log4j", "http://jakarta.apache.org/log4j/");
    Element appender = document.createElement("appender");
    appender.setAttribute("name", "default");
    appender.setAttribute("class", "org.apache.log4j.ConsoleAppender");
    Element layout = document.createElement("layout");
    layout.setAttribute("class", "org.apache.log4j.PatternLayout");
    Element param = document.createElement("param");
    param.setAttribute("name", "ConversionPattern");
    param.setAttribute("value", "%-5p [%d{yyyy/MM/dd HH:mm}]: %m        at %l %n");
    layout.appendChild(param);
    appender.appendChild(layout);
    log4j.appendChild(appender);
    Element logger = document.createElement("logger");
    logger.setAttribute("name", "org.apache.empire.commons");
    logger.setAttribute("additivity", "false");
    Element level = document.createElement("level");
    level.setAttribute("value", "warn");
    Element loggerAppender = document.createElement("appender-ref");
    loggerAppender.setAttribute("ref", "default");
    logger.appendChild(level);
    logger.appendChild(loggerAppender);
    log4j.appendChild(logger);
    Element root = document.createElement("root");
    Element priority = document.createElement("priority");
    priority.setAttribute("value", "info");
    Element rootAppender = document.createElement("appender-ref");
    rootAppender.setAttribute("ref", "default");
    root.appendChild(priority);
    root.appendChild(rootAppender);
    log4j.appendChild(root);
    return log4j;
}

10. GraphMLWriter#createNodeDataTag()

Project: flex-falcon
Source File: GraphMLWriter.java
View license
/**
     * Helper function to create a {@link Element} representing a node of {@link ICompilationUnit} in the {@link DependencyGraph}.
     * 
     * @param label A {@link String} representing the compilation unit. This will be displayed on the node in yed when the report is opened.
     * @param external A {@link boolean} representing whether this node is an external compilation unit or an internal one. The color of the node
     *  depends on this.
     * @return A {@link Element} representing a node of {@link ICompilationUnit} in the {@link DependencyGraph}
     */
private Element createNodeDataTag(String label, boolean external) {
    Element dataTag = doc.createElement("data");
    dataTag.setAttribute("key", "d0");
    Element shapeNodeTag = doc.createElementNS(yNSuri, "y:ShapeNode");
    String colorString = external ? "#FFCC00" : "#CCCCFF";
    Element fillTag = doc.createElementNS(yNSuri, "y:Fill");
    fillTag.setAttribute("color", colorString);
    fillTag.setAttribute("transparent", "false");
    Element labelTag = doc.createElementNS(yNSuri, "y:NodeLabel");
    labelTag.setTextContent(label);
    shapeNodeTag.appendChild(fillTag);
    shapeNodeTag.appendChild(labelTag);
    dataTag.appendChild(shapeNodeTag);
    return dataTag;
}

11. Account#toOfx()

Project: gnucash-android
Source File: Account.java
View license
/**
	 * Converts this account's transactions into XML and adds them to the DOM document
	 * @param doc XML DOM document for the OFX data
	 * @param parent Parent node to which to add this account's transactions in XML
	 * @param exportStartTime Time from which to export transactions which are created/modified after
	 */
public void toOfx(Document doc, Element parent, Timestamp exportStartTime) {
    Element currency = doc.createElement(OfxHelper.TAG_CURRENCY_DEF);
    currency.appendChild(doc.createTextNode(mCommodity.getCurrencyCode()));
    //================= BEGIN BANK ACCOUNT INFO (BANKACCTFROM) =================================
    Element bankId = doc.createElement(OfxHelper.TAG_BANK_ID);
    bankId.appendChild(doc.createTextNode(OfxHelper.APP_ID));
    Element acctId = doc.createElement(OfxHelper.TAG_ACCOUNT_ID);
    acctId.appendChild(doc.createTextNode(getUID()));
    Element accttype = doc.createElement(OfxHelper.TAG_ACCOUNT_TYPE);
    String ofxAccountType = convertToOfxAccountType(mAccountType).toString();
    accttype.appendChild(doc.createTextNode(ofxAccountType));
    Element bankFrom = doc.createElement(OfxHelper.TAG_BANK_ACCOUNT_FROM);
    bankFrom.appendChild(bankId);
    bankFrom.appendChild(acctId);
    bankFrom.appendChild(accttype);
    //================= END BANK ACCOUNT INFO ============================================
    //================= BEGIN ACCOUNT BALANCE INFO =================================
    String balance = getBalance().toPlainString();
    String formattedCurrentTimeString = OfxHelper.getFormattedCurrentTime();
    Element balanceAmount = doc.createElement(OfxHelper.TAG_BALANCE_AMOUNT);
    balanceAmount.appendChild(doc.createTextNode(balance));
    Element dtasof = doc.createElement(OfxHelper.TAG_DATE_AS_OF);
    dtasof.appendChild(doc.createTextNode(formattedCurrentTimeString));
    Element ledgerBalance = doc.createElement(OfxHelper.TAG_LEDGER_BALANCE);
    ledgerBalance.appendChild(balanceAmount);
    ledgerBalance.appendChild(dtasof);
    //================= END ACCOUNT BALANCE INFO =================================
    //================= BEGIN TIME PERIOD INFO =================================
    Element dtstart = doc.createElement(OfxHelper.TAG_DATE_START);
    dtstart.appendChild(doc.createTextNode(formattedCurrentTimeString));
    Element dtend = doc.createElement(OfxHelper.TAG_DATE_END);
    dtend.appendChild(doc.createTextNode(formattedCurrentTimeString));
    //================= END TIME PERIOD INFO =================================
    //================= BEGIN TRANSACTIONS LIST =================================
    Element bankTransactionsList = doc.createElement(OfxHelper.TAG_BANK_TRANSACTION_LIST);
    bankTransactionsList.appendChild(dtstart);
    bankTransactionsList.appendChild(dtend);
    for (Transaction transaction : mTransactionsList) {
        if (transaction.getModifiedTimestamp().before(exportStartTime))
            continue;
        bankTransactionsList.appendChild(transaction.toOFX(doc, getUID()));
    }
    //================= END TRANSACTIONS LIST =================================
    Element statementTransactions = doc.createElement(OfxHelper.TAG_STATEMENT_TRANSACTIONS);
    statementTransactions.appendChild(currency);
    statementTransactions.appendChild(bankFrom);
    statementTransactions.appendChild(bankTransactionsList);
    statementTransactions.appendChild(ledgerBalance);
    parent.appendChild(statementTransactions);
}

12. PrefixRewriterTest#generatePayloadElementOfDummySamlDocument()

Project: WS-Attacker
Source File: PrefixRewriterTest.java
View license
public static Element generatePayloadElementOfDummySamlDocument() {
    Document doc = DomUtilities.createDomDocument();
    Element response = doc.createElementNS(URI_NS_SAML20P, "samlp:Response");
    doc.appendChild(response);
    response.appendChild(doc.createElementNS(URI_NS_SAML20P, "samlp:Status"));
    response.appendChild(doc.createElementNS(URI_NS_SAML20P, "samlp:Irgendwas"));
    Element responseCopy = (Element) response.cloneNode(true);
    Element assertion = doc.createElementNS(URI_NS_SAML20, "saml:Assertion");
    response.appendChild(assertion);
    Element sigResp = doc.createElementNS(URI_NS_DS, "ds:Signature");
    response.insertBefore(sigResp, assertion);
    Element sigAss = doc.createElementNS(URI_NS_DS, "ds:Signature");
    assertion.appendChild(sigAss);
    sigAss.appendChild(responseCopy);
    return responseCopy;
}

13. RecordingData#getXMLDataModel()

Project: sakai
Source File: RecordingData.java
View license
/**
 * This takes a RecordingData object and puts it in XML.
 * @return the XML as an org.w3c.dom.Document
 */
public Document getXMLDataModel() {
    Logger log = LoggerFactory.getLogger(RecordingData.class);
    Document document = null;
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    try {
        DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
        document = documentBuilder.newDocument();
    } catch (ParserConfigurationException e) {
        log.error(e.getMessage(), e);
    }
    if (document == null) {
        log.error("document is null");
        return null;
    }
    //add audio setup data to  XML document
    //root
    Element recordingData = document.createElement("RecordingData");
    //sub elements
    Element agentName = document.createElement("AgentName");
    Element agentId = document.createElement("AgentId");
    Element courseAssignmentContext = document.createElement("CourseAssignmentContext");
    Element fileExtension = document.createElement("FileExtension");
    Element fileName = document.createElement("FileName");
    Element limit = document.createElement("Limit");
    Element dir = document.createElement("Dir");
    Element seconds = document.createElement("Seconds");
    Element appName = document.createElement("AppName");
    Element imageURL = document.createElement("ImageURL");
    agentName.appendChild(document.createTextNode(this.getAgentName()));
    agentId.appendChild(document.createTextNode(this.getAgentId()));
    courseAssignmentContext.appendChild(document.createTextNode(this.getCourseAssignmentContext()));
    fileExtension.appendChild(document.createTextNode(this.getFileExtension()));
    fileName.appendChild(document.createTextNode(this.getFileName()));
    limit.appendChild(document.createTextNode(this.getLimit()));
    dir.appendChild(document.createTextNode(this.getDir()));
    seconds.appendChild(document.createTextNode(this.getSeconds()));
    appName.appendChild(document.createTextNode(this.getAppName()));
    imageURL.appendChild(document.createTextNode(this.getImageURL()));
    recordingData.appendChild(agentName);
    recordingData.appendChild(agentId);
    recordingData.appendChild(courseAssignmentContext);
    recordingData.appendChild(fileExtension);
    recordingData.appendChild(fileName);
    recordingData.appendChild(limit);
    recordingData.appendChild(dir);
    recordingData.appendChild(seconds);
    recordingData.appendChild(appName);
    recordingData.appendChild(imageURL);
    document.appendChild(recordingData);
    // return the recording data available in  XML
    return document;
}

14. TileMapServiceResource#mrsPyramidMetadataToTileMapXml()

Project: mrgeo
Source File: TileMapServiceResource.java
View license
protected static Document mrsPyramidMetadataToTileMapXml(final String raster, final String url, final MrsPyramidMetadata mpm) throws ParserConfigurationException {
    /*
     * String tileMap = "<?xml version='1.0' encoding='UTF-8' ?>" +
     * "<TileMap version='1.0.0' tilemapservice='http://localhost/mrgeo-services/api/tms/1.0.0'>" +
     * "  <Title>AfPk Elevation V2</Title>" + "  <Abstract>A test of V2 MrsPyramid.</Abstract>"
     * + "  <SRS>EPSG:4326</SRS>" + "  <BoundingBox minx='68' miny='33' maxx='72' maxy='35' />" +
     * "  <Origin x='68' y='33' />" +
     * "  <TileFormat width='512' height='512' mime-type='image/tiff' extension='tif' />" +
     * "  <TileSets profile='global-geodetic'>" +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/1' units-per-pixel='0.3515625' order='1' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/2' units-per-pixel='0.17578125' order='2' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/3' units-per-pixel='0.08789063' order='3' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/4' units-per-pixel='0.08789063' order='4' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/5' units-per-pixel='0.08789063' order='5' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/6' units-per-pixel='0.08789063' order='6' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/7' units-per-pixel='0.08789063' order='7' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/8' units-per-pixel='0.08789063' order='8' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/9' units-per-pixel='0.08789063' order='9' />"
     * +
     * "    <TileSet href='http://localhost/mrgeo-services/api/tms/1.0.0/AfPkElevationV2/10' units-per-pixel='0.08789063' order='10' />"
     * + "  </TileSets>" + "</TileMap>";
     */
    final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    // root elements
    final Document doc = docBuilder.newDocument();
    final Element rootElement = doc.createElement("TileMap");
    doc.appendChild(rootElement);
    final Attr v = doc.createAttribute("version");
    v.setValue(VERSION);
    rootElement.setAttributeNode(v);
    final Attr tilemapservice = doc.createAttribute("tilemapservice");
    tilemapservice.setValue(normalizeUrl(normalizeUrl(url).replace(raster, "")));
    rootElement.setAttributeNode(tilemapservice);
    // child elements
    final Element title = doc.createElement("Title");
    title.setTextContent(raster);
    rootElement.appendChild(title);
    final Element abst = doc.createElement("Abstract");
    abst.setTextContent("");
    rootElement.appendChild(abst);
    final Element srs = doc.createElement("SRS");
    srs.setTextContent(SRS);
    rootElement.appendChild(srs);
    final Element bbox = doc.createElement("BoundingBox");
    rootElement.appendChild(bbox);
    final Attr minx = doc.createAttribute("minx");
    minx.setValue(String.valueOf(mpm.getBounds().w));
    bbox.setAttributeNode(minx);
    final Attr miny = doc.createAttribute("miny");
    miny.setValue(String.valueOf(mpm.getBounds().s));
    bbox.setAttributeNode(miny);
    final Attr maxx = doc.createAttribute("maxx");
    maxx.setValue(String.valueOf(mpm.getBounds().e));
    bbox.setAttributeNode(maxx);
    final Attr maxy = doc.createAttribute("maxy");
    maxy.setValue(String.valueOf(mpm.getBounds().n));
    bbox.setAttributeNode(maxy);
    final Element origin = doc.createElement("Origin");
    rootElement.appendChild(origin);
    final Attr x = doc.createAttribute("x");
    x.setValue(String.valueOf(mpm.getBounds().w));
    origin.setAttributeNode(x);
    final Attr y = doc.createAttribute("y");
    y.setValue(String.valueOf(mpm.getBounds().s));
    origin.setAttributeNode(y);
    final Element tileformat = doc.createElement("TileFormat");
    rootElement.appendChild(tileformat);
    final Attr w = doc.createAttribute("width");
    w.setValue(String.valueOf(mpm.getTilesize()));
    tileformat.setAttributeNode(w);
    final Attr h = doc.createAttribute("height");
    h.setValue(String.valueOf(mpm.getTilesize()));
    tileformat.setAttributeNode(h);
    final Attr mt = doc.createAttribute("mime-type");
    mt.setValue("image/tiff");
    tileformat.setAttributeNode(mt);
    final Attr ext = doc.createAttribute("extension");
    ext.setValue("tif");
    tileformat.setAttributeNode(ext);
    final Element tilesets = doc.createElement("TileSets");
    rootElement.appendChild(tilesets);
    final Attr profile = doc.createAttribute("profile");
    profile.setValue("global-geodetic");
    tilesets.setAttributeNode(profile);
    for (int i = 0; i <= mpm.getMaxZoomLevel(); i++) {
        final Element tileset = doc.createElement("TileSet");
        tilesets.appendChild(tileset);
        final Attr href = doc.createAttribute("href");
        href.setValue(normalizeUrl(normalizeUrl(url)) + "/" + i);
        tileset.setAttributeNode(href);
        final Attr upp = doc.createAttribute("units-per-pixel");
        upp.setValue(String.valueOf(180d / 256d / Math.pow(2, i)));
        tileset.setAttributeNode(upp);
        final Attr order = doc.createAttribute("order");
        order.setValue(String.valueOf(i));
        tileset.setAttributeNode(order);
    }
    return doc;
}

15. AndroidManifestFile#createActivityElement()

View license
private Node createActivityElement(Document doc) {
    Element activityElement = doc.createElement("activity");
    activityElement.setAttribute("android:name", "S3UploaderActivity");
    activityElement.setAttribute("android:label", "@string/app_name");
    Element intentFilterElement = doc.createElement("intent-filter");
    Element actionElement = doc.createElement("action");
    actionElement.setAttribute("android:name", "android.intent.action.MAIN");
    Element categoryElement = doc.createElement("category");
    categoryElement.setAttribute("android:name", "android.intent.category.LAUNCHER");
    intentFilterElement.appendChild(actionElement);
    intentFilterElement.appendChild(categoryElement);
    activityElement.appendChild(intentFilterElement);
    return activityElement;
}

16. VectorSerializer#writeSchema()

Project: axis1-java
Source File: VectorSerializer.java
View license
/**
     * Return XML schema for the specified type, suitable for insertion into
     * the <types> element of a WSDL document, or underneath an
     * <element> or <attribute> declaration.
     *
     * @param javaType the Java Class we're writing out schema for
     * @param types the Java2WSDL Types object which holds the context
     *              for the WSDL being generated.
     * @return a type element containing a schema simpleType/complexType
     * @see org.apache.axis.wsdl.fromJava.Types
     */
public Element writeSchema(Class javaType, Types types) throws Exception {
    Element complexType = types.createElement("complexType");
    complexType.setAttribute("name", "Vector");
    types.writeSchemaTypeDecl(Constants.SOAP_VECTOR, complexType);
    Element seq = types.createElement("sequence");
    complexType.appendChild(seq);
    Element element = types.createElement("element");
    element.setAttribute("name", "item");
    element.setAttribute("minOccurs", "0");
    element.setAttribute("maxOccurs", "unbounded");
    element.setAttribute("type", "xsd:anyType");
    seq.appendChild(element);
    return complexType;
}

17. SetSVGDocumentTest#canvasInit()

Project: batik
Source File: SetSVGDocumentTest.java
View license
/* JSVGCanvasHandler.Delegate Interface */
public boolean canvasInit(JSVGCanvas canvas) {
    DOMImplementation impl = GenericDOMImplementation.getDOMImplementation();
    Document doc = impl.createDocument(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SVG_TAG, null);
    Element e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_RECT_TAG);
    e.setAttribute("x", "10");
    e.setAttribute("y", "10");
    e.setAttribute("width", "100");
    e.setAttribute("height", "50");
    e.setAttribute("fill", "crimson");
    doc.getDocumentElement().appendChild(e);
    e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_CIRCLE_TAG);
    e.setAttribute("cx", "55");
    e.setAttribute("cy", "35");
    e.setAttribute("r", "30");
    e.setAttribute("fill", "gold");
    doc.getDocumentElement().appendChild(e);
    canvas.setDocument(doc);
    // We didn't trigger a load event.
    return false;
}

18. BackgroundColorTest#createTranscoderInput()

Project: batik
Source File: BackgroundColorTest.java
View license
/**
     * Creates the <code>TranscoderInput</code>.
     */
protected TranscoderInput createTranscoderInput() {
    DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    Document doc = impl.createDocument(svgNS, "svg", null);
    Element root = doc.getDocumentElement();
    root.setAttributeNS(null, "width", "400");
    root.setAttributeNS(null, "height", "400");
    Element r = doc.createElementNS(svgNS, "rect");
    r.setAttributeNS(null, "x", "100");
    r.setAttributeNS(null, "y", "50");
    r.setAttributeNS(null, "width", "100");
    r.setAttributeNS(null, "height", "50");
    r.setAttributeNS(null, "style", "fill:red");
    root.appendChild(r);
    return new TranscoderInput(doc);
}

19. WebModuleUtilTest#buildModuleConfig()

Project: openmrs-core
Source File: WebModuleUtilTest.java
View license
private Document buildModuleConfig() throws ParserConfigurationException {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    Document doc = docBuilder.newDocument();
    Element rootElement = doc.createElement("module");
    doc.appendChild(rootElement);
    Element dwr = doc.createElement("dwr");
    dwr.appendChild(doc.createTextNode(""));
    rootElement.appendChild(dwr);
    Element allow = doc.createElement("allow");
    allow.appendChild(doc.createTextNode(""));
    dwr.appendChild(allow);
    Attr attr = doc.createAttribute("moduleId");
    attr.setValue("mymodule");
    allow.setAttributeNode(attr);
    Element create = doc.createElement("create");
    allow.appendChild(create);
    return doc;
}

20. PFMReader#constructFontXML()

Project: fop
Source File: PFMReader.java
View license
/**
     * Generates the font metrics file from the PFM file.
     *
     * @param pfm The PFM file to generate the font metrics from.
     * @param fontName name of the font
     * @param className class name for the font
     * @param resource path to the font as embedded resource
     * @param file path to the font as file
     * @return  The DOM document representing the font metrics file.
     */
public org.w3c.dom.Document constructFontXML(PFMFile pfm, String fontName, String className, String resource, String file) {
    log.info("Creating xml font file...");
    log.info("");
    Document doc;
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        doc = factory.newDocumentBuilder().newDocument();
    } catch (javax.xml.parsers.ParserConfigurationException e) {
        log.error("Can't create DOM implementation", e);
        return null;
    }
    Element root = doc.createElement("font-metrics");
    doc.appendChild(root);
    root.setAttribute("type", "TYPE1");
    Element el = doc.createElement("font-name");
    root.appendChild(el);
    el.appendChild(doc.createTextNode(pfm.getPostscriptName()));
    // Currently unused.
    // String s = pfm.getPostscriptName();
    // int pos = s.indexOf("-");
    // if (pos >= 0) {
    // char[] sb = new char[s.length() - 1];
    // s.getChars(0, pos, sb, 0);
    // s.getChars(pos + 1, s.length(), sb, pos);
    // s = new String(sb);
    // }
    el = doc.createElement("embed");
    root.appendChild(el);
    if (file != null) {
        el.setAttribute("file", file);
    }
    if (resource != null) {
        el.setAttribute("class", resource);
    }
    el = doc.createElement("encoding");
    root.appendChild(el);
    el.appendChild(doc.createTextNode(pfm.getCharSetName() + "Encoding"));
    el = doc.createElement("cap-height");
    root.appendChild(el);
    Integer value = new Integer(pfm.getCapHeight());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("x-height");
    root.appendChild(el);
    value = new Integer(pfm.getXHeight());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("ascender");
    root.appendChild(el);
    value = new Integer(pfm.getLowerCaseAscent());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("descender");
    root.appendChild(el);
    value = new Integer(pfm.getLowerCaseDescent());
    el.appendChild(doc.createTextNode(value.toString()));
    Element bbox = doc.createElement("bbox");
    root.appendChild(bbox);
    int[] bb = pfm.getFontBBox();
    final String[] names = { "left", "bottom", "right", "top" };
    for (int i = 0; i < names.length; i++) {
        el = doc.createElement(names[i]);
        bbox.appendChild(el);
        value = new Integer(bb[i]);
        el.appendChild(doc.createTextNode(value.toString()));
    }
    el = doc.createElement("flags");
    root.appendChild(el);
    value = new Integer(pfm.getFlags());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("stemv");
    root.appendChild(el);
    value = new Integer(pfm.getStemV());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("italicangle");
    root.appendChild(el);
    value = new Integer(pfm.getItalicAngle());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("first-char");
    root.appendChild(el);
    value = new Integer(pfm.getFirstChar());
    el.appendChild(doc.createTextNode(value.toString()));
    el = doc.createElement("last-char");
    root.appendChild(el);
    value = new Integer(pfm.getLastChar());
    el.appendChild(doc.createTextNode(value.toString()));
    Element widths = doc.createElement("widths");
    root.appendChild(widths);
    for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) {
        el = doc.createElement("char");
        widths.appendChild(el);
        el.setAttribute("idx", Integer.toString(i));
        el.setAttribute("wdt", Integer.toString(pfm.getCharWidth(i)));
    }
    // Get kerning
    Iterator iter = pfm.getKerning().keySet().iterator();
    while (iter.hasNext()) {
        Integer kpx1 = (Integer) iter.next();
        el = doc.createElement("kerning");
        el.setAttribute("kpx1", kpx1.toString());
        root.appendChild(el);
        Element el2 = null;
        Map h2 = (Map) pfm.getKerning().get(kpx1);
        Iterator enum2 = h2.entrySet().iterator();
        while (enum2.hasNext()) {
            Map.Entry entry = (Map.Entry) enum2.next();
            Integer kpx2 = (Integer) entry.getKey();
            el2 = doc.createElement("pair");
            el2.setAttribute("kpx2", kpx2.toString());
            Integer val = (Integer) entry.getValue();
            el2.setAttribute("kern", val.toString());
            el.appendChild(el2);
        }
    }
    return doc;
}

21. DOMKeyValue#marshalDSAPublicKey()

Project: jdk7u-jdk
Source File: DOMKeyValue.java
View license
private void marshalDSAPublicKey(Node parent, Document doc, String dsPrefix, DOMCryptoContext context) throws MarshalException {
    Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue", XMLSignature.XMLNS, dsPrefix);
    // parameters J, Seed & PgenCounter are not included
    Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS, dsPrefix);
    Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS, dsPrefix);
    Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS, dsPrefix);
    Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS, dsPrefix);
    p.marshal(pElem, dsPrefix, context);
    q.marshal(qElem, dsPrefix, context);
    g.marshal(gElem, dsPrefix, context);
    y.marshal(yElem, dsPrefix, context);
    dsaElem.appendChild(pElem);
    dsaElem.appendChild(qElem);
    dsaElem.appendChild(gElem);
    dsaElem.appendChild(yElem);
    parent.appendChild(dsaElem);
}

22. WSSClient#getListItemQuery()

View license
/**
     * <p>
     * Generate the list item query. The query will contain one message element
     * representing the following XML.
     * </p>
     * <p>
     *
     * <pre>
     * <Query xmlns=""> <Where> <Contains> <FieldRef Name="FileRef" /> <Value
     * Type="Text">/Development/</Value> </Contains> <OrderBy> <FieldRef
     * Name="FileDirRef" Ascending="true" /> </OrderBy> </Where> </Query>
     * </pre>
     *
     * </p>
     *
     * @param docLib
     *        the document library to generate the query for (must not be
     *        <code>null</code>)
     * @return the query to list items for the specified document library
     */
public DOMAnyContentType getListItemQuery(final WSSDocumentLibrary docLib) {
    //$NON-NLS-1$
    Check.notNull(docLib, "docLib");
    //$NON-NLS-1$
    final Document document = DOMCreateUtils.newDocument("Query");
    final Element query = document.getDocumentElement();
    //$NON-NLS-1$
    final Element where = DOMUtils.appendChild(query, "Where");
    //$NON-NLS-1$
    final Element contains = DOMUtils.appendChild(where, "Contains");
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    DOMUtils.appendChild(contains, "FieldRef").setAttribute("Name", "FileRef");
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final Element value = DOMUtils.appendChildWithText(contains, "Value", "/" + docLib.getASCIIName() + "/");
    //$NON-NLS-1$ //$NON-NLS-2$
    value.setAttribute("Type", "Text");
    //$NON-NLS-1$
    final Element orderBy = DOMUtils.appendChild(where, "OrderBy");
    //$NON-NLS-1$
    final Element fieldRef2 = DOMUtils.appendChild(orderBy, "FieldRef");
    //$NON-NLS-1$ //$NON-NLS-2$
    fieldRef2.setAttribute("Name", "FileDirRef");
    //$NON-NLS-1$ //$NON-NLS-2$
    fieldRef2.setAttribute("Ascending", "true");
    return new DOMAnyContentType(new Element[] { query });
}

23. ParseContextConfigTest#testAll()

View license
public void testAll() throws Exception {
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Element entries = document.createElement("entries");
    Element entry = document.createElement("entry");
    entry.setAttribute("class", "org.apache.tika.parser.pdf.PDFParserConfig");
    entry.setAttribute("impl", "org.apache.tika.parser.pdf.PDFParserConfig");
    Element property = document.createElement("property");
    property.setAttribute("name", "extractInlineImages");
    property.setAttribute("value", "true");
    entry.appendChild(property);
    entries.appendChild(entry);
    ParseContext parseContext = new ParseContextConfig(new SolrResourceLoader(Paths.get(".")), entries).create();
    PDFParserConfig pdfParserConfig = parseContext.get(PDFParserConfig.class);
    assertEquals(true, pdfParserConfig.getExtractInlineImages());
}

24. Types#createLiteralArrayElement()

Project: axis1-java
Source File: Types.java
View license
/**
     * Create an array which is a wrapper type for "item" elements
     * of a component type.  This is basically the unencoded parallel to
     * a SOAP-encoded array.
     *
     * @param componentType
     * @param itemName the QName of the inner element (right now we only use the localPart)
     * @return
     */
public Element createLiteralArrayElement(String componentType, QName itemName) {
    String itemLocalName = "item";
    if (itemName != null) {
        itemLocalName = itemName.getLocalPart();
    }
    Element complexType = docHolder.createElement("complexType");
    Element sequence = docHolder.createElement("sequence");
    complexType.appendChild(sequence);
    Element elem = docHolder.createElement("element");
    elem.setAttribute("name", itemLocalName);
    elem.setAttribute("type", componentType);
    elem.setAttribute("minOccurs", "0");
    elem.setAttribute("maxOccurs", "unbounded");
    sequence.appendChild(elem);
    return complexType;
}

25. AttachmentImpl#createXMLForAdd()

View license
@Override
protected void createXMLForAdd(final Element parentElement) {
    final SimpleDateFormat metadataDateFormat = InternalWorkItemUtils.newMetadataDateFormat();
    final Element element = DOMUtils.appendChild(parentElement, UpdateXMLConstants.ELEMENT_NAME_INSERT_FILE);
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_FIELD_NAME, CoreFieldReferenceNames.ATTACHED_FILES);
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_ORIGINAL_NAME, fileName);
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_FILE_NAME, serverGuid);
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_CREATION_DATE, metadataDateFormat.format(fileCreatedDate));
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_LAST_WRITE_DATE, metadataDateFormat.format(fileLastModifiedDate));
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_FILE_NAME, serverGuid);
    if (comment != null && comment.trim().length() > 0) {
        DOMUtils.appendChildWithText(element, UpdateXMLConstants.ELEMENT_NAME_COMMENT, comment.trim());
    }
    element.setAttribute(UpdateXMLConstants.ATTRIBUTE_NAME_FILE_SIZE, String.valueOf(fileSize));
}

26. RestContentProvider#createErrorDocument()

Project: sakai
Source File: RestContentProvider.java
View license
/**
   * Given any error condition, create an error document including css
   * @return Document
   */
public static Document createErrorDocument() {
    Document errorDocument = createDocument();
    Element html = errorDocument.createElement("html");
    Element head = errorDocument.createElement("head");
    Element body = errorDocument.createElement("body");
    Element p = errorDocument.createElement("p");
    Text textNode = errorDocument.createTextNode("An error retrieving document from knowledge base has occurred.");
    p.appendChild(textNode);
    body.appendChild(p);
    html.appendChild(head);
    html.appendChild(body);
    errorDocument.appendChild(html);
    return errorDocument;
}

27. ItemHelper12Impl#addEMIItem()

Project: sakai
Source File: ItemHelper12Impl.java
View license
private void addEMIItem(String ident, ItemTextIfc itemText, Item itemXml) {
    //main node resprocessing
    Element resprocessing = createElement("resprocessing", itemXml);
    itemXml.addElement("item", resprocessing);
    //outcomes with the scores and required count
    Element outcomes = createElement("outcomes", itemXml);
    resprocessing.appendChild(outcomes);
    //decvar for score
    Element decvarScore = createElement("decvar", itemXml);
    decvarScore.setAttribute("defaultval", "0");
    decvarScore.setAttribute("varname", "SCORE");
    decvarScore.setAttribute("vartype", "Double");
    outcomes.appendChild(decvarScore);
    //decvar for required count
    Element decvarRequired = createElement("decvar", itemXml);
    decvarRequired.setAttribute("defaultval", String.valueOf(itemText.getEmiCorrectOptionLabels().length()));
    decvarRequired.setAttribute("maxvalue", itemText.getRequiredOptionsCount().toString());
    decvarRequired.setAttribute("minvalue", "0");
    decvarRequired.setAttribute("varname", "requiredOptionsCount");
    decvarRequired.setAttribute("vartype", "Integer");
    outcomes.appendChild(decvarRequired);
    //decvar for score user set
    Element decvarScoreUserSet = createElement("decvar", itemXml);
    decvarScoreUserSet.setAttribute("varname", "scoreUserSet");
    decvarScoreUserSet.setAttribute("vartype", "String");
    outcomes.appendChild(decvarScoreUserSet);
    //Item Text
    //Testing
    Element interpretvar = createElement("interpretvar", itemXml);
    //Testing
    outcomes.appendChild(interpretvar);
    //Testing
    Element material = createElement("material", itemXml);
    //Testing
    interpretvar.appendChild(material);
    //Testing
    Element mattext = createElement("mattext", itemXml);
    //Testing
    mattext.setTextContent(XmlUtil.convertToSingleCDATA(itemText.getText()));
    //Testing
    material.appendChild(mattext);
    if (itemText.getHasAttachment()) {
        setAttachments(itemText.getItemTextAttachmentSet(), itemXml, material);
    }
    double score = 0.0;
    double discount = 0.0;
    //respcondition for every correct option
    for (AnswerIfc answer : itemText.getAnswerArraySorted()) {
        decvarScoreUserSet.setAttribute("defaultval", answer.getGrade());
        Element respcondition = createElement("respcondition", itemXml);
        respcondition.setAttribute("continue", "Yes");
        respcondition.setAttribute("title", answer.getIsCorrect() ? "CORRECT" : "INCORRECT");
        resprocessing.appendChild(respcondition);
        //conditionvar for correct answers
        Element conditionvar = createElement("conditionvar", itemXml);
        respcondition.appendChild(conditionvar);
        Element varequal = createElement("varequal", itemXml);
        varequal.setAttribute("case", "Yes");
        varequal.setAttribute("respident", ident);
        varequal.setTextContent(answer.getLabel());
        conditionvar.appendChild(varequal);
        //setvar for action
        Element setvar = createElement("setvar", itemXml);
        if (answer.getIsCorrect()) {
            setvar.setAttribute("action", "Add");
            setvar.setTextContent(String.valueOf(getDouble(answer.getScore())));
            score += getDouble(answer.getScore());
        } else {
            setvar.setAttribute("action", "Subtract");
            setvar.setTextContent(String.valueOf(Math.abs(getDouble(answer.getDiscount()))));
            discount += getDouble(answer.getDiscount());
        }
        setvar.setAttribute("varname", "SCORE");
        respcondition.appendChild(setvar);
    }
    //set the scores
    decvarScore.setAttribute("maxvalue", String.valueOf(getDouble(score)));
    //String.valueOf(getDouble(discount)));
    decvarScore.setAttribute("minvalue", "0");
}

28. AssignmentSubmissionAccess#toXml()

View license
public String toXml() {
    Document doc = Xml.createDocument();
    Element submission = doc.createElement("submission");
    doc.appendChild(submission);
    String numItemsString = null;
    String attributeString = null;
    String itemString = null;
    submission.setAttribute("reviewScore", this.reviewScore);
    submission.setAttribute("reviewReport", this.reviewReport);
    submission.setAttribute("reviewStatus", this.reviewStatus);
    submission.setAttribute("id", this.id);
    submission.setAttribute("context", this.context);
    submission.setAttribute("scaled_grade", this.grade);
    submission.setAttribute("scaled_factor", String.valueOf(this.m_factor));
    submission.setAttribute("assignment", this.assignment);
    submission.setAttribute("datesubmitted", this.datesubmitted);
    submission.setAttribute("datereturned", this.datereturned);
    submission.setAttribute("lastmod", this.lastmod);
    submission.setAttribute("submitted", this.submitted);
    submission.setAttribute("submitterid", this.submitterid);
    submission.setAttribute("returned", this.returned);
    submission.setAttribute("graded", this.graded);
    submission.setAttribute("gradedBy", this.gradedBy);
    submission.setAttribute("gradereleased", this.gradereleased);
    submission.setAttribute("pledgeflag", this.pledgeflag);
    // SAVE THE SUBMITTERS
    for (int x = 0; x < this.submitters.size(); x++) {
        attributeString = "submitter" + x;
        itemString = (String) this.submitters.get(x);
        if (itemString != null) {
            submission.setAttribute(attributeString, itemString);
        }
    }
    // SAVE THE SUBMISSION LOGS
    for (int x = 0; x < this.submissionLog.size(); x++) {
        attributeString = "log" + x;
        itemString = (String) this.submissionLog.get(x);
        if (itemString != null) {
            submission.setAttribute(attributeString, itemString);
        }
    }
    // SAVE GRADE OVERRIDES
    for (int x = 0; x < this.grades.size(); x++) {
        attributeString = "grade" + x;
        itemString = (String) this.grades.get(x);
        if (itemString != null) {
            submission.setAttribute(attributeString, itemString);
        }
    }
    // SAVE THE FEEDBACK ATTACHMENTS
    for (int x = 0; x < this.feedbackattachments.size(); x++) {
        attributeString = "feedbackattachment" + x;
        itemString = this.feedbackattachments.get(x);
        if (itemString != null) {
            submission.setAttribute(attributeString, itemString);
        }
    }
    // SAVE THE SUBMITTED ATTACHMENTS
    for (int x = 0; x < this.submittedattachments.size(); x++) {
        attributeString = "submittedattachment" + x;
        itemString = this.submittedattachments.get(x);
        if (itemString != null) {
            submission.setAttribute(attributeString, itemString);
        }
    }
    submission.setAttribute("submittedtext", this.submittedtext);
    submission.setAttribute("submittedtext-html", this.submittedtext_html);
    submission.setAttribute("feedbackcomment", this.feedbackcomment);
    submission.setAttribute("feedbackcomment-html", this.feedbackcomment_html);
    submission.setAttribute("feedbacktext", this.feedbacktext);
    submission.setAttribute("feedbacktext-html", this.feedbacktext_html);
    // SAVE THE PROPERTIES
    Element properties = doc.createElement("properties");
    submission.appendChild(properties);
    Map<String, Object> props = this.saxSerializableProperties.getSerializableProperties();
    for (Map.Entry<String, Object> entry : props.entrySet()) {
        String key = entry.getKey();
        Object value = props.get(key);
        if (value instanceof String) {
            Element propElement = doc.createElement("property");
            properties.appendChild(propElement);
            propElement.setAttribute("name", key);
            // encode to allow special characters in the value
            Xml.encodeAttribute(propElement, "value", (String) value);
            propElement.setAttribute("enc", "BASE64");
        } else if (value instanceof List) {
            for (Object val : (List) value) {
                if (val == null) {
                    continue;
                }
                if (val instanceof String) {
                    Element propElement = doc.createElement("property");
                    properties.appendChild(propElement);
                    propElement.setAttribute("name", key);
                    Xml.encodeAttribute(propElement, "value", (String) val);
                    propElement.setAttribute("enc", "BASE64");
                    propElement.setAttribute("list", "list");
                } else {
                    log.warn(".toXml: in list not string: " + key);
                }
            }
        } else {
            log.warn(".toXml: not a string, not a value: " + key);
        }
    }
    return Xml.writeDocumentToString(doc);
}

29. ManifestGenerator#appendLOMMetadataToElement()

Project: sakai
Source File: ManifestGenerator.java
View license
public void appendLOMMetadataToElement(String title, Element parent) {
    // imsmd:lom
    Element imsmdLom = createLOMElement("lom");
    // imsmd:general
    Element imsmdGeneral = createLOMElement("general");
    // imsmd:identifier
    String identifier = Long.toHexString((new Date()).getTime());
    Element imsmdIdentifier = createLOMElementWithLangstring("identifier", identifier);
    imsmdGeneral.appendChild(imsmdIdentifier);
    // imsmd:title
    Element imsmdTitle = createLOMElementWithLangstring("title", title);
    imsmdGeneral.appendChild(imsmdTitle);
    imsmdLom.appendChild(imsmdGeneral);
    parent.appendChild(imsmdLom);
}

30. FCKConnectorServlet#createCommonXml()

Project: sakai
Source File: FCKConnectorServlet.java
View license
private Node createCommonXml(Document doc, String commandStr, String type, String currentPath, String currentUrl) {
    Element root = doc.createElement("Connector");
    doc.appendChild(root);
    root.setAttribute("command", commandStr);
    root.setAttribute("resourceType", type);
    Element element = doc.createElement("CurrentFolder");
    element.setAttribute("path", currentPath);
    element.setAttribute("url", currentUrl);
    root.appendChild(element);
    return root;
}

31. RMPolicyExtension#addMethodsToStub()

Project: sandesha
Source File: RMPolicyExtension.java
View license
public void addMethodsToStub(Document document, Element element, QName opName, Policy policy) {
    Element methods = document.createElement("reliableMessagingMethods");
    Element startSequence = document.createElement("createSequence");
    methods.appendChild(startSequence);
    Element setLastMessage = document.createElement("setLastMessage");
    methods.appendChild(setLastMessage);
    Element endSequence = document.createElement("endSequence");
    methods.appendChild(endSequence);
    element.appendChild(methods);
}

32. Canonicalizer20010315ExclusiveTest#test24Aexcl()

View license
/**
     * Method test24Aexcl - a testcase for SANTUARIO-263
     * "Canonicalizer can't handle dynamical created DOM correctly"
     * https://issues.apache.org/jira/browse/SANTUARIO-263
     */
@org.junit.Test
public void test24Aexcl() throws Exception {
    Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
    Element local = doc.createElementNS("foo:bar", "dsig:local");
    Element test = doc.createElementNS("http://example.net", "etsi:test");
    Element elem2 = doc.createElementNS("http://example.net", "etsi:elem2");
    Element stuff = doc.createElementNS("foo:bar", "dsig:stuff");
    elem2.appendChild(stuff);
    test.appendChild(elem2);
    local.appendChild(test);
    doc.appendChild(local);
    Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
    Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
    byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath("src/test/resources/org/apache/xml/security/c14n/inExcl/example2_4_c14nized.xml"));
    byte[] result = c.engineCanonicalizeSubTree(root);
    boolean equals = java.security.MessageDigest.isEqual(reference, result);
    assertTrue(equals);
}

33. DOMX509IssuerSerial#marshal()

Project: openjdk
Source File: DOMX509IssuerSerial.java
View license
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException {
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial", XMLSignature.XMLNS, dsPrefix);
    Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName", XMLSignature.XMLNS, dsPrefix);
    Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber", XMLSignature.XMLNS, dsPrefix);
    inElem.appendChild(ownerDoc.createTextNode(issuerName));
    snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
    isElem.appendChild(inElem);
    isElem.appendChild(snElem);
    parent.appendChild(isElem);
}

34. ConfigWebAdmin#addResourceProvider()

Project: railo
Source File: ConfigWebAdmin.java
View license
private void addResourceProvider(String scheme, String clazz, String arguments) throws SecurityException {
    checkWriteAccess();
    Element resources = _getRootElement("resources");
    Element[] rpElements = ConfigWebFactory.getChildren(resources, "resource-provider");
    String s;
    // update
    if (rpElements != null) {
        for (int i = 0; i < rpElements.length; i++) {
            s = rpElements[i].getAttribute("scheme");
            if (!StringUtil.isEmpty(s) && s.equalsIgnoreCase(scheme)) {
                rpElements[i].setAttribute("class", clazz);
                rpElements[i].setAttribute("scheme", scheme);
                rpElements[i].setAttribute("arguments", arguments);
                return;
            }
        }
    }
    // Insert
    Element el = doc.createElement("resource-provider");
    resources.appendChild(XMLCaster.toRawNode(el));
    el.setAttribute("class", clazz);
    el.setAttribute("scheme", scheme);
    el.setAttribute("arguments", arguments);
}

35. DOMX509IssuerSerial#marshal()

Project: jdk7u-jdk
Source File: DOMX509IssuerSerial.java
View license
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException {
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial", XMLSignature.XMLNS, dsPrefix);
    Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName", XMLSignature.XMLNS, dsPrefix);
    Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber", XMLSignature.XMLNS, dsPrefix);
    inElem.appendChild(ownerDoc.createTextNode(issuerName));
    snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
    isElem.appendChild(inElem);
    isElem.appendChild(snElem);
    parent.appendChild(isElem);
}

36. mxDomUtils#createSvgDocument()

Project: jgraphx
Source File: mxDomUtils.java
View license
/**
	 * Creates a new SVG document for the given width and height.
	 */
public static Document createSvgDocument(int width, int height) {
    Document document = createDocument();
    Element root = document.createElement("svg");
    String w = String.valueOf(width);
    String h = String.valueOf(height);
    root.setAttribute("width", w);
    root.setAttribute("height", h);
    root.setAttribute("viewBox", "0 0 " + w + " " + h);
    root.setAttribute("version", "1.1");
    root.setAttribute("xmlns", mxConstants.NS_SVG);
    root.setAttribute("xmlns:xlink", mxConstants.NS_XLINK);
    document.appendChild(root);
    return document;
}

37. Credential#toXml()

View license
public Element toXml(final Document document) {
    final Element valueNode = document.createElement("value");
    final Element passwordNode = document.createElement("Password");
    final Text passwordValue = document.createTextNode(this.Password);
    passwordNode.appendChild(passwordValue);
    valueNode.appendChild(passwordNode);
    final Element usernameNode = document.createElement("Username");
    final Text usernameValue = document.createTextNode(this.Username);
    usernameNode.appendChild(usernameValue);
    valueNode.appendChild(usernameNode);
    return valueNode;
}

38. Token#toXml()

View license
public Element toXml(final Document document) {
    final Element valueNode = document.createElement("value");
    final Element typeNode = document.createElement("Type");
    final Text typeValue = document.createTextNode(this.Type.toString());
    typeNode.appendChild(typeValue);
    valueNode.appendChild(typeNode);
    final Element tokenValueNode = document.createElement("Value");
    final Text valueValue = document.createTextNode(this.Value);
    tokenValueNode.appendChild(valueValue);
    valueNode.appendChild(tokenValueNode);
    if (!Guid.Empty.equals(this.getTargetIdentity())) {
        final Element targetIdentityNode = document.createElement("targetIdentity");
        final Text targetIdentityValue = document.createTextNode(this.getTargetIdentity().toString());
        targetIdentityNode.appendChild(targetIdentityValue);
        valueNode.appendChild(targetIdentityNode);
    }
    return valueNode;
}

39. TestQueueManagerForHierarchialQueues#testValidation()

View license
public void testValidation() throws Exception {
    checkForConfigFile();
    Document doc = createDocument();
    Element queues = createQueuesNode(doc, "false");
    Element q1 = createQueue(doc, "q1");
    q1.appendChild(createAcls(doc, "acl-submit-job", "u1"));
    q1.appendChild(createAcls(doc, "acl-administer-jobs", "u2"));
    q1.appendChild(createQueue(doc, "p15"));
    q1.appendChild(createQueue(doc, "p16"));
    queues.appendChild(q1);
    writeToFile(doc, CONFIG);
    try {
        new QueueManager(CONFIG);
        fail("Should throw an exception as configuration is wrong ");
    } catch (RuntimeException re) {
        LOG.info(re.getMessage());
    }
}

40. XPSAssembler#noNodesReturnedFromXLink()

Project: lenya
Source File: XPSAssembler.java
View license
/**
     * DOCUMENT ME!
     *
     * @param xlink DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
public NodeList noNodesReturnedFromXLink(XLink xlink) {
    log.warn("No nodes returned from XLink: " + xlink);
    Document dummyDocument = dpf.getDocument();
    Element dummyRoot = dpf.newElementNode(dummyDocument, "DummyRoot");
    Element element = xlink.getXLink(dummyDocument, dpf);
    dummyRoot.appendChild(element);
    Element exceptionElement = dpf.newElementNode(dummyDocument, XPSEXCEPTION_ELEMENT_NAME);
    exceptionElement.appendChild(dpf.newElementNode(dummyDocument, "NoNodesReturnedFromXLink"));
    dummyRoot.appendChild(exceptionElement);
    return dummyRoot.getChildNodes();
}

41. mxDomUtils#createSvgDocument()

Project: consulo
Source File: mxDomUtils.java
View license
/**
   * Creates a new SVG document for the given width and height.
   */
public static Document createSvgDocument(int width, int height) {
    Document document = createDocument();
    Element root = document.createElement("svg");
    String w = String.valueOf(width);
    String h = String.valueOf(height);
    root.setAttribute("width", w);
    root.setAttribute("height", h);
    root.setAttribute("viewBox", "0 0 " + w + " " + h);
    root.setAttribute("version", "1.1");
    root.setAttribute("xmlns", mxConstants.NS_SVG);
    root.setAttribute("xmlns:xlink", mxConstants.NS_XLINK);
    document.appendChild(root);
    return document;
}

42. XmlDataWriter#createDescription()

Project: uadetector
Source File: XmlDataWriter.java
View license
private static Element createDescription(@Nonnull final Data data, @Nonnull final Document doc) {
    final Element description = doc.createElement(Tag.DESCRIPTION);
    final Element label = doc.createElement(Tag.LABEL);
    description.appendChild(label).appendChild(doc.createTextNode("Data (format xml) for UASparser - http://user-agent-string.info/download/UASparser"));
    final Element version = doc.createElement("version");
    description.appendChild(version).appendChild(doc.createTextNode(data.getVersion()));
    final Element md5Checksum = doc.createElement("checksum");
    md5Checksum.setAttribute(Tag.TYPE, "MD5");
    description.appendChild(md5Checksum).appendChild(doc.createTextNode("http://user-agent-string.info/rpc/get_data.php?format=xml&md5=y"));
    final Element shaChecksum = doc.createElement("checksum");
    shaChecksum.setAttribute(Tag.TYPE, "SHA1");
    description.appendChild(shaChecksum).appendChild(doc.createTextNode("http://user-agent-string.info/rpc/get_data.php?format=xml&sha1=y"));
    return description;
}

43. Credential#toXml()

View license
public Element toXml(final Document document) {
    final Element valueNode = document.createElement("value");
    final Element passwordNode = document.createElement("Password");
    final Text passwordValue = document.createTextNode(this.Password);
    passwordNode.appendChild(passwordValue);
    valueNode.appendChild(passwordNode);
    final Element usernameNode = document.createElement("Username");
    final Text usernameValue = document.createTextNode(this.Username);
    usernameNode.appendChild(usernameValue);
    valueNode.appendChild(usernameNode);
    return valueNode;
}

44. Token#toXml()

View license
public Element toXml(final Document document) {
    final Element valueNode = document.createElement("value");
    final Element typeNode = document.createElement("Type");
    final Text typeValue = document.createTextNode(this.Type.toString());
    typeNode.appendChild(typeValue);
    valueNode.appendChild(typeNode);
    final Element tokenValueNode = document.createElement("Value");
    final Text valueValue = document.createTextNode(this.Value);
    tokenValueNode.appendChild(valueValue);
    valueNode.appendChild(tokenValueNode);
    if (!Guid.Empty.equals(this.getTargetIdentity())) {
        final Element targetIdentityNode = document.createElement("targetIdentity");
        final Text targetIdentityValue = document.createTextNode(this.getTargetIdentity().toString());
        targetIdentityNode.appendChild(targetIdentityValue);
        valueNode.appendChild(targetIdentityNode);
    }
    return valueNode;
}

45. TokenPair#toXml()

View license
public Element toXml(final Document document) {
    final Element valueNode = document.createElement("value");
    final Element accessTokenNode = document.createElement("accessToken");
    final Text accessTokenValue = document.createTextNode(AccessToken.Value);
    accessTokenNode.appendChild(accessTokenValue);
    valueNode.appendChild(accessTokenNode);
    final Element refreshTokenNode = document.createElement("refreshToken");
    final Text refreshTokenValue = document.createTextNode(RefreshToken.Value);
    refreshTokenNode.appendChild(refreshTokenValue);
    valueNode.appendChild(refreshTokenNode);
    return valueNode;
}

46. XsetDirectiveTest#setsTextDirectlyIntoDomNodes()

Project: xembly
Source File: XsetDirectiveTest.java
View license
/**
     * XsetDirective can set text content of nodes.
     * @throws Exception If some problem inside
     * @since 0.7
     */
@Test
public void setsTextDirectlyIntoDomNodes() throws Exception {
    final Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    final Element root = dom.createElement("xxx");
    final Element first = dom.createElement("first");
    first.setTextContent("15");
    root.appendChild(first);
    final Element second = dom.createElement("second");
    second.setTextContent("13");
    root.appendChild(second);
    dom.appendChild(root);
    new XsetDirective("sum(/xxx/*/text()) + 5").exec(dom, new DomCursor(Collections.<Node>singletonList(first)), new DomStack());
    MatcherAssert.assertThat(XhtmlMatchers.xhtml(dom), XhtmlMatchers.hasXPaths("/xxx[first='33' and second='13']"));
}

47. XPathDescendantWeaknessTest#detectHashedPostTreeTest2()

View license
@Test
public void detectHashedPostTreeTest2() throws Exception {
    SoapTestDocument soap = new SoapTestDocument();
    Document doc = soap.getDocument();
    String postXPath = "ns1:payloadBody";
    Element signedElement = soap.getDummyPayloadBody();
    signedElement.appendChild(doc.createElementNS("http://ns2", "ns2:a"));
    Element theSigned = doc.createElementNS("http://ns2", "ns2:b");
    signedElement.appendChild(theSigned);
    signedElement.appendChild(doc.createElementNS("http://ns2", "ns2:c"));
    signedElement = theSigned;
    signedElement.setTextContent("Original Content");
    Element hashed = XPathWeaknessTools.detectHashedPostTree(signedElement, postXPath);
    assertNotNull(hashed);
    assertEquals(soap.getDummyPayloadBody(), hashed);
}

48. RepositoryGeneratorImpl#writeRequirement()

View license
/**
   * write the requirement
   * 
   * @param req
   *          requirement
   * @param writer
   *          buffer writer
   * @throws IOException
   */
private static void writeRequirement(Requirement req, Document doc, Element resource) throws IOException {
    logger.debug(LOG_ENTRY, "writeRequirement", new Object[] { req, doc, resource });
    Element requirement = doc.createElement("require");
    requirement.setAttribute("name", req.getName());
    requirement.setAttribute("extend", String.valueOf(req.isExtend()));
    requirement.setAttribute("multiple", String.valueOf(req.isMultiple()));
    requirement.setAttribute("optional", String.valueOf(req.isOptional()));
    requirement.setAttribute("filter", req.getFilter());
    requirement.setTextContent(req.getComment());
    resource.appendChild(requirement);
    logger.debug(LOG_EXIT, "writeRequirement");
}

49. RepositoryGeneratorImpl#writeRequirement()

Project: aries
Source File: RepositoryGeneratorImpl.java
View license
/**
   * write the requirement
   * 
   * @param req
   *          requirement
   * @param writer
   *          buffer writer
   * @throws IOException
   */
private static void writeRequirement(Requirement req, Document doc, Element resource) throws IOException {
    logger.debug(LOG_ENTRY, "writeRequirement", new Object[] { req, doc, resource });
    Element requirement = doc.createElement("require");
    requirement.setAttribute("name", req.getName());
    requirement.setAttribute("extend", String.valueOf(req.isExtend()));
    requirement.setAttribute("multiple", String.valueOf(req.isMultiple()));
    requirement.setAttribute("optional", String.valueOf(req.isOptional()));
    requirement.setAttribute("filter", req.getFilter());
    requirement.setTextContent(req.getComment());
    resource.appendChild(requirement);
    logger.debug(LOG_EXIT, "writeRequirement");
}

50. SVGAlphaComposite#compositeToSVG()

Project: batik
Source File: SVGAlphaComposite.java
View license
/**
     * @param composite AlphaComposite to convert to a filter effect
     * @exception Error if an AlphaComposite with SRC_OVER rule in passed to
     *            this method.
     */
private Element compositeToSVG(AlphaComposite composite) {
    // operator is equivalent to rule
    String operator = null;
    // input1 is equivalent to Src
    String input1 = null;
    // input2 is equivalent to Dst
    String input2 = null;
    // k2 is used only for arithmetic
    // to obtain the equivalent of SRC
    String k2 = "0";
    // ID used to identify the composite
    String id = null;
    switch(composite.getRule()) {
        case AlphaComposite.CLEAR:
            operator = SVG_ARITHMETIC_VALUE;
            input1 = SVG_SOURCE_GRAPHIC_VALUE;
            input2 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_CLEAR;
            break;
        case AlphaComposite.SRC:
            operator = SVG_ARITHMETIC_VALUE;
            input1 = SVG_SOURCE_GRAPHIC_VALUE;
            input2 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_SRC;
            k2 = SVG_DIGIT_ONE_VALUE;
            break;
        case AlphaComposite.SRC_IN:
            operator = SVG_IN_VALUE;
            input1 = SVG_SOURCE_GRAPHIC_VALUE;
            input2 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_SRC_IN;
            break;
        case AlphaComposite.SRC_OUT:
            operator = SVG_OUT_VALUE;
            input1 = SVG_SOURCE_GRAPHIC_VALUE;
            input2 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_SRC_OUT;
            break;
        case AlphaComposite.DST_IN:
            operator = SVG_IN_VALUE;
            input2 = SVG_SOURCE_GRAPHIC_VALUE;
            input1 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_DST_IN;
            break;
        case AlphaComposite.DST_OUT:
            operator = SVG_OUT_VALUE;
            input2 = SVG_SOURCE_GRAPHIC_VALUE;
            input1 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_DST_OUT;
            break;
        case AlphaComposite.DST_OVER:
            operator = SVG_OVER_VALUE;
            input2 = SVG_SOURCE_GRAPHIC_VALUE;
            input1 = SVG_BACKGROUND_IMAGE_VALUE;
            id = ID_PREFIX_ALPHA_COMPOSITE_DST_OVER;
            break;
        default:
            throw new Error("invalid rule:" + composite.getRule());
    }
    Element compositeFilter = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FILTER_TAG);
    compositeFilter.setAttributeNS(null, SVG_ID_ATTRIBUTE, id);
    compositeFilter.setAttributeNS(null, SVG_FILTER_UNITS_ATTRIBUTE, SVG_OBJECT_BOUNDING_BOX_VALUE);
    compositeFilter.setAttributeNS(null, SVG_X_ATTRIBUTE, SVG_ZERO_PERCENT_VALUE);
    compositeFilter.setAttributeNS(null, SVG_Y_ATTRIBUTE, SVG_ZERO_PERCENT_VALUE);
    compositeFilter.setAttributeNS(null, SVG_WIDTH_ATTRIBUTE, SVG_HUNDRED_PERCENT_VALUE);
    compositeFilter.setAttributeNS(null, SVG_HEIGHT_ATTRIBUTE, SVG_HUNDRED_PERCENT_VALUE);
    Element feComposite = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FE_COMPOSITE_TAG);
    feComposite.setAttributeNS(null, SVG_OPERATOR_ATTRIBUTE, operator);
    feComposite.setAttributeNS(null, SVG_IN_ATTRIBUTE, input1);
    feComposite.setAttributeNS(null, SVG_IN2_ATTRIBUTE, input2);
    feComposite.setAttributeNS(null, SVG_K2_ATTRIBUTE, k2);
    feComposite.setAttributeNS(null, SVG_RESULT_ATTRIBUTE, SVG_COMPOSITE_VALUE);
    Element feFlood = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FE_FLOOD_TAG);
    feFlood.setAttributeNS(null, SVG_FLOOD_COLOR_ATTRIBUTE, "white");
    feFlood.setAttributeNS(null, SVG_FLOOD_OPACITY_ATTRIBUTE, "1");
    feFlood.setAttributeNS(null, SVG_RESULT_ATTRIBUTE, SVG_FLOOD_VALUE);
    Element feMerge = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FE_MERGE_TAG);
    Element feMergeNodeFlood = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FE_MERGE_NODE_TAG);
    feMergeNodeFlood.setAttributeNS(null, SVG_IN_ATTRIBUTE, SVG_FLOOD_VALUE);
    Element feMergeNodeComposite = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FE_MERGE_NODE_TAG);
    feMergeNodeComposite.setAttributeNS(null, SVG_IN_ATTRIBUTE, SVG_COMPOSITE_VALUE);
    feMerge.appendChild(feMergeNodeFlood);
    feMerge.appendChild(feMergeNodeComposite);
    compositeFilter.appendChild(feFlood);
    compositeFilter.appendChild(feComposite);
    compositeFilter.appendChild(feMerge);
    return compositeFilter;
}

51. OriginalMetadataAnnotation#makeOriginalMetadata()

View license
/**
   * Create a DOM element for this annotation with the given document
   * as the parent.
   * @param document the parent document for this annotation
   * @return the DOM element corresponding to this annotation
   */
protected Element makeOriginalMetadata(Document document) {
    Element keyElement = document.createElement("Key");
    Element valueElement = document.createElement("Value");
    keyElement.setTextContent(key);
    valueElement.setTextContent(value);
    Element originalMetadata = document.createElement("OriginalMetadata");
    originalMetadata.appendChild(keyElement);
    originalMetadata.appendChild(valueElement);
    return originalMetadata;
}

52. BuildFileGenerator#createClean()

Project: che
Source File: BuildFileGenerator.java
View license
/**
     * Create clean target tag.
     * <target description="Remove all temporary files" name="clean">
     * ...
     * </target>
     */
private void createClean() {
    //Insert comment
    Comment cleanUpComment = doc.createComment("Clean up");
    root.appendChild(cleanUpComment);
    //Create main target tag
    Element target = doc.createElement("target");
    target.setAttribute("name", "clean");
    target.setAttribute("description", "Remove all temporary files");
    //Insert comment
    Comment deleteFileComment = doc.createComment("Delete files");
    target.appendChild(deleteFileComment);
    //Create delete tag inside target tag
    Element delete = doc.createElement("delete");
    delete.setAttribute("dir", "${build.classes}");
    target.appendChild(delete);
    root.appendChild(target);
}

53. ItemHelper12Impl#addEMIOption()

Project: sakai
Source File: ItemHelper12Impl.java
View license
private void addEMIOption(String ident, String text, Item itemXml) {
    Element response_label = createElement("response_label", itemXml);
    response_label.setAttribute("ident", ident);
    Element material = createElement("material", itemXml);
    response_label.appendChild(material);
    Element mattext = createElement("mattext", itemXml);
    material.appendChild(mattext);
    if (text != null) {
        mattext.setTextContent(XmlUtil.convertToSingleCDATA(text));
    }
    itemXml.addElement("item/presentation/flow[@class='Options']/response_lid/render_choice", response_label);
}

54. LoginForm#addProvider()

Project: gerrit
Source File: LoginForm.java
View license
private static void addProvider(Element form, boolean link, String pluginName, String id, String serviceName) {
    Element div = form.getOwnerDocument().createElement("div");
    div.setAttribute("id", id);
    Element hyperlink = form.getOwnerDocument().createElement("a");
    StringBuilder u = new StringBuilder(String.format("?id=%s_%s", pluginName, id));
    if (link) {
        u.append("&link");
    }
    hyperlink.setAttribute("href", u.toString());
    hyperlink.setTextContent(serviceName + " (" + pluginName + " plugin)");
    div.appendChild(hyperlink);
    form.appendChild(div);
}

55. OAuthWebFilter#addProvider()

Project: gerrit
Source File: OAuthWebFilter.java
View license
private static void addProvider(Element form, String pluginName, String id, String serviceName) {
    Element div = form.getOwnerDocument().createElement("div");
    div.setAttribute("id", id);
    Element hyperlink = form.getOwnerDocument().createElement("a");
    hyperlink.setAttribute("href", String.format("?provider=%s_%s", pluginName, id));
    hyperlink.setTextContent(serviceName + " (" + pluginName + " plugin)");
    div.appendChild(hyperlink);
    form.appendChild(div);
}

56. ItemDefinitionImpl#toXml()

Project: jackrabbit
Source File: ItemDefinitionImpl.java
View license
//------------------------------------------< XmlSerializable interface >---
/**
     * Returns the Xml representation of a {@link ItemDefinition} object.
     *
     * @return Xml representation of the specified {@link ItemDefinition def}.
     * @param document
     */
public Element toXml(Document document) {
    Element elem = document.createElement(getElementName());
    NodeType dnt = getDeclaringNodeType();
    if (dnt != null) {
        elem.setAttribute(DECLARINGNODETYPE_ATTRIBUTE, dnt.getName());
    }
    elem.setAttribute(NAME_ATTRIBUTE, getName());
    elem.setAttribute(AUTOCREATED_ATTRIBUTE, Boolean.toString(isAutoCreated()));
    elem.setAttribute(MANDATORY_ATTRIBUTE, Boolean.toString(isMandatory()));
    elem.setAttribute(ONPARENTVERSION_ATTRIBUTE, OnParentVersionAction.nameFromValue(getOnParentVersion()));
    elem.setAttribute(PROTECTED_ATTRIBUTE, Boolean.toString(isProtected()));
    return elem;
}

57. XsMetaModel#createXsSchemaElement()

Project: isis
Source File: XsMetaModel.java
View license
/**
     * Creates an <xs:schema> element for the document to the provided
     * element, attaching to root of supplied Xsd doc.
     * 
     * In addition:
     * <ul>
     * <li>the elementFormDefault is set
     * <li>the NOF namespace is set
     * <li>the <code>xs:import</code> element referencing the NOF namespace is
     * added as a child
     * </ul>
     */
Element createXsSchemaElement(final Document xsdDoc) {
    if (xsdDoc.getDocumentElement() != null) {
        throw new IllegalArgumentException("XSD document already has content");
    }
    final Element xsSchemaElement = createXsElement(xsdDoc, "schema");
    xsSchemaElement.setAttribute("elementFormDefault", "qualified");
    isisMeta.addNamespace(xsSchemaElement);
    xsdDoc.appendChild(xsSchemaElement);
    final Element xsImportElement = createXsElement(xsdDoc, "import");
    xsImportElement.setAttribute("namespace", IsisSchema.NS_URI);
    xsImportElement.setAttribute("schemaLocation", IsisSchema.DEFAULT_LOCATION);
    xsSchemaElement.appendChild(xsImportElement);
    return xsSchemaElement;
}

58. AtomProtocol#generateMediaEntry()

Project: exist
Source File: AtomProtocol.java
View license
public static Element generateMediaEntry(String id, String created, String title, String filename, String mimeType) throws ParserConfigurationException {
    final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setNamespaceAware(true);
    final Document owner = docFactory.newDocumentBuilder().getDOMImplementation().createDocument(Atom.NAMESPACE_STRING, "entry", null);
    final Element entry = owner.getDocumentElement();
    final Element idE = owner.createElementNS(Atom.NAMESPACE_STRING, "id");
    idE.appendChild(owner.createTextNode(id));
    entry.appendChild(idE);
    final Element publishedE = owner.createElementNS(Atom.NAMESPACE_STRING, "published");
    publishedE.appendChild(owner.createTextNode(created));
    entry.appendChild(publishedE);
    final Element updatedE = owner.createElementNS(Atom.NAMESPACE_STRING, "updated");
    updatedE.appendChild(owner.createTextNode(created));
    entry.appendChild(updatedE);
    final Element titleE = owner.createElementNS(Atom.NAMESPACE_STRING, "title");
    titleE.appendChild(owner.createTextNode(title));
    entry.appendChild(titleE);
    Element linkE = owner.createElementNS(Atom.NAMESPACE_STRING, "link");
    linkE.setAttribute("rel", "edit");
    linkE.setAttribute("type", Atom.MIME_TYPE);
    linkE.setAttribute("href", "?id=" + id);
    entry.appendChild(linkE);
    linkE = owner.createElementNS(Atom.NAMESPACE_STRING, "link");
    linkE.setAttribute("rel", "edit-media");
    linkE.setAttribute("type", mimeType);
    linkE.setAttribute("href", filename);
    entry.appendChild(linkE);
    final Element contentE = owner.createElementNS(Atom.NAMESPACE_STRING, "content");
    entry.appendChild(contentE);
    contentE.setAttribute("src", filename);
    contentE.setAttribute("type", mimeType);
    return entry;
}

59. SUTimeMain#annotationToXmlDocument()

Project: CoreNLP
Source File: SUTimeMain.java
View license
public static Document annotationToXmlDocument(Annotation annotation) {
    Element dateElem = XMLUtils.createElement("DATE");
    dateElem.setTextContent(annotation.get(CoreAnnotations.DocDateAnnotation.class));
    Element textElem = annotationToTmlTextElement(annotation);
    Element docElem = XMLUtils.createElement("DOC");
    docElem.appendChild(dateElem);
    docElem.appendChild(textElem);
    // Create document and import elements into this document....
    Document doc = XMLUtils.createDocument();
    doc.appendChild(doc.importNode(docElem, true));
    return doc;
}

60. ManifestGenerator#createManifestElement()

Project: sakai
Source File: ManifestGenerator.java
View license
private Element createManifestElement() {
    Element manifest = createDefaultNSElement("manifest");
    manifest.setAttribute("identifier", "MANIFEST1");
    manifest.setAttribute("xmlns", DEFAULT_NAMESPACE_URI);
    manifest.setAttribute("xmlns:imsmd", IMSMD_NAMESPACE_URI);
    manifest.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    manifest.setAttribute("xsi:schemaLocation", DEFAULT_NAMESPACE_URI + " " + DEFAULT_NAMESPACE_SCHEMA_LOCATION + " " + IMSMD_NAMESPACE_URI + " " + IMSMD_NAMESPACE_SCHEMA_LOCATION);
    return manifest;
}

61. W3CDOMStreamReaderTest#testElementChild()

View license
public void testElementChild() throws Exception {
    Document doc = getDocument();
    Element e = doc.createElementNS("urn:test", "root");
    e.setAttribute("xmlns", "urn:test");
    Element child = doc.createElementNS("urn:test2", "child");
    child.setAttribute("xmlns:a", "urn:test2");
    child.setPrefix("a");
    e.appendChild(child);
    doc.appendChild(e);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writeXml(doc, baos);
    LOG.info(baos.toString());
    W3CDOMStreamReader reader = new W3CDOMStreamReader(e);
    testElementChild(reader);
}

62. W3CDOMStreamReaderTest#testMixedContent()

View license
public void testMixedContent() throws Exception {
    Document doc = getDocument();
    Element e = doc.createElementNS("urn:test", "test:root");
    e.setAttribute("xmlns", "urn:test");
    doc.appendChild(e);
    Node text = doc.createTextNode("Hello World");
    e.appendChild(text);
    Element child = doc.createElement("element");
    e.appendChild(child);
    text = doc.createTextNode(" more text");
    e.appendChild(text);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writeXml(doc, baos);
    LOG.info(baos.toString());
    W3CDOMStreamReader reader = new W3CDOMStreamReader(e);
    testMixedContent(reader);
}

63. WSDL11Endpoint#fromMap()

Project: ode
Source File: WSDL11Endpoint.java
View license
public void fromMap(Map eprMap) {
    Document doc = DOMUtils.newDocument();
    Element serviceRef = doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(), SERVICE_REF_QNAME.getLocalPart());
    doc.appendChild(serviceRef);
    _serviceElmt = doc.createElementNS(Namespaces.WSDL_11, "service");
    serviceRef.appendChild(_serviceElmt);
    if (eprMap.get(SERVICE_QNAME) != null) {
        QName serviceQName = ((QName) eprMap.get(SERVICE_QNAME));
        _serviceElmt.setAttribute("name", serviceQName.getLocalPart());
        _serviceElmt.setAttribute("targetNamespace", serviceQName.getNamespaceURI());
    }
    Element port = doc.createElementNS(Namespaces.WSDL_11, "port");
    if (eprMap.get(PORT_NAME) != null) {
        port.setAttribute("name", (String) eprMap.get(PORT_NAME));
    }
    port.setAttribute("binding", "");
    Element address = doc.createElementNS(Namespaces.SOAP_NS, "address");
    if (eprMap.get(ADDRESS) != null)
        address.setAttribute("location", (String) eprMap.get(ADDRESS));
    _serviceElmt.appendChild(port);
    port.appendChild(address);
}

64. AddIfDirectiveTest#addsDomNodesDirectly()

Project: xembly
Source File: AddIfDirectiveTest.java
View license
/**
     * AddIfDirective can add node to a node.
     * @throws Exception If some problem inside
     * @since 0.15.2
     */
@Test
public void addsDomNodesDirectly() throws Exception {
    final Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    final Element root = dom.createElement("xxx");
    root.appendChild(dom.createElement("a"));
    root.appendChild(dom.createTextNode("hello"));
    root.appendChild(dom.createComment("some comment"));
    root.appendChild(dom.createCDATASection("CDATA"));
    root.appendChild(dom.createProcessingInstruction("a12", "22"));
    dom.appendChild(root);
    new AddIfDirective("b").exec(dom, new DomCursor(Collections.<Node>singleton(root)), new DomStack());
    MatcherAssert.assertThat(XhtmlMatchers.xhtml(dom), XhtmlMatchers.hasXPath("/xxx/b"));
}

65. SchemeGenerator#serializeBuildableReference()

Project: buck
Source File: SchemeGenerator.java
View license
public static Element serializeBuildableReference(Document doc, XCScheme.BuildableReference buildableReference) {
    Element refElem = doc.createElement("BuildableReference");
    refElem.setAttribute("BuildableIdentifier", "primary");
    refElem.setAttribute("BlueprintIdentifier", buildableReference.getBlueprintIdentifier());
    refElem.setAttribute("BuildableName", buildableReference.getBuildableName());
    refElem.setAttribute("BlueprintName", buildableReference.getBlueprintName());
    String referencedContainer = "container:" + buildableReference.getContainerRelativePath();
    refElem.setAttribute("ReferencedContainer", referencedContainer);
    return refElem;
}

66. RepositoryDescriptorGenerator#addPackageRequirement()

View license
private static void addPackageRequirement(Document doc, Element resource, BundleInfo info, Content p) {
    Element requirement = doc.createElement("require");
    requirement.setAttribute("name", "package");
    requirement.setAttribute("extend", "false");
    requirement.setAttribute("multiple", "false");
    String optional = p.getDirective("optional");
    if (optional == null)
        optional = "false";
    requirement.setAttribute("optional", optional);
    requirement.setAttribute("filter", ManifestHeaderProcessor.generateFilter("package", p.getContentName(), p.getAttributes()));
    resource.appendChild(requirement);
}

67. RepositoryDescriptorGenerator#addBundleRequirement()

View license
private static void addBundleRequirement(Document doc, Element resource, BundleInfo info, Content p) {
    Element requirement = doc.createElement("require");
    requirement.setAttribute("name", "bundle");
    requirement.setAttribute("extend", "false");
    requirement.setAttribute("multiple", "false");
    requirement.setAttribute("optional", "false");
    requirement.setAttribute("filter", ManifestHeaderProcessor.generateFilter("bundle", p.getContentName(), p.getAttributes()));
    resource.appendChild(requirement);
}

68. RepositoryGeneratorImpl#writeResource()

Project: aries
Source File: RepositoryGeneratorImpl.java
View license
/**
   * Write out the resource element
   * 
   * @param r
   *          resource
   * @param writer
   *          buffer writer
   * @throws IOException
   */
private static void writeResource(Resource r, String uri, Document doc, Element root) throws IOException {
    logger.debug(LOG_ENTRY, "writeResource", new Object[] { r, uri, doc, root });
    Element resource = doc.createElement("resource");
    resource.setAttribute(Resource.VERSION, r.getVersion().toString());
    resource.setAttribute("uri", r.getURI());
    resource.setAttribute(Resource.SYMBOLIC_NAME, r.getSymbolicName());
    resource.setAttribute(Resource.ID, r.getSymbolicName() + "/" + r.getVersion());
    resource.setAttribute(Resource.PRESENTATION_NAME, r.getPresentationName());
    root.appendChild(resource);
    for (Capability c : r.getCapabilities()) writeCapability(c, doc, resource);
    for (Requirement req : r.getRequirements()) {
        writeRequirement(req, doc, resource);
    }
    logger.debug(LOG_EXIT, "writeResource");
}

69. RepositoryDescriptorGenerator#addPackageRequirement()

View license
private static void addPackageRequirement(Document doc, Element resource, BundleInfo info, Content p) {
    Element requirement = doc.createElement("require");
    requirement.setAttribute("name", "package");
    requirement.setAttribute("extend", "false");
    requirement.setAttribute("multiple", "false");
    String optional = p.getDirective("optional");
    if (optional == null)
        optional = "false";
    requirement.setAttribute("optional", optional);
    requirement.setAttribute("filter", ManifestHeaderProcessor.generateFilter("package", p.getContentName(), p.getAttributes()));
    resource.appendChild(requirement);
}

70. RepositoryDescriptorGenerator#addBundleRequirement()

View license
private static void addBundleRequirement(Document doc, Element resource, BundleInfo info, Content p) {
    Element requirement = doc.createElement("require");
    requirement.setAttribute("name", "bundle");
    requirement.setAttribute("extend", "false");
    requirement.setAttribute("multiple", "false");
    requirement.setAttribute("optional", "false");
    requirement.setAttribute("filter", ManifestHeaderProcessor.generateFilter("bundle", p.getContentName(), p.getAttributes()));
    resource.appendChild(requirement);
}

71. RepositoryGeneratorImpl#writeResource()

View license
/**
   * Write out the resource element
   * 
   * @param r
   *          resource
   * @param writer
   *          buffer writer
   * @throws IOException
   */
private static void writeResource(Resource r, String uri, Document doc, Element root) throws IOException {
    logger.debug(LOG_ENTRY, "writeResource", new Object[] { r, uri, doc, root });
    Element resource = doc.createElement("resource");
    resource.setAttribute(Resource.VERSION, r.getVersion().toString());
    resource.setAttribute("uri", r.getURI());
    resource.setAttribute(Resource.SYMBOLIC_NAME, r.getSymbolicName());
    resource.setAttribute(Resource.ID, r.getSymbolicName() + "/" + r.getVersion());
    resource.setAttribute(Resource.PRESENTATION_NAME, r.getPresentationName());
    root.appendChild(resource);
    for (Capability c : r.getCapabilities()) writeCapability(c, doc, resource);
    for (Requirement req : r.getRequirements()) {
        writeRequirement(req, doc, resource);
    }
    logger.debug(LOG_EXIT, "writeResource");
}

72. Result#toXML()

Project: oodt
Source File: Result.java
View license
public Node toXML(Document doc) throws DOMException {
    Element root = doc.createElement("resultElement");
    root.setAttribute("classified", String.valueOf(classified));
    root.setAttribute("validity", String.valueOf(validity));
    XML.add(root, "resultId", id);
    XML.add(root, "resultMimeType", mimeType);
    XML.add(root, "profId", profileID);
    XML.add(root, "identifier", resourceID);
    Element resultHeader = doc.createElement("resultHeader");
    root.appendChild(resultHeader);
    for (Object header1 : headers) {
        Header header = (Header) header1;
        resultHeader.appendChild(header.toXML(doc));
    }
    Codec codec = (Codec) codecs.get(mimeType);
    if (codec == null) {
        throw new IllegalStateException("No codec available for supposedly valid MIME type \"" + mimeType + "\"");
    }
    root.appendChild(codec.encode(value, doc));
    return root;
}

73. RIFLWriter#writeAttackerIO()

Project: JAADAS
Source File: RIFLWriter.java
View license
/**
	 * Writes out the attackerIO component of the RIFL document
	 * @param document The XML document in which to write
	 * @param rootElement The root element of the document
	 */
private void writeAttackerIO(Document document, Element rootElement) {
    Element attackerIO = document.createElement("attackerio");
    rootElement.appendChild(attackerIO);
    Element sources = document.createElement("sources");
    attackerIO.appendChild(sources);
    for (SourceSinkSpec spec : this.document.getAttackerIO().getSources()) {
        Element source = document.createElement("source");
        sources.appendChild(source);
        writeSourceSinkSpec(spec, document, source);
    }
    Element sinks = document.createElement("sinks");
    attackerIO.appendChild(sinks);
    for (SourceSinkSpec spec : this.document.getAttackerIO().getSinks()) {
        Element sink = document.createElement("sink");
        sinks.appendChild(sink);
        writeSourceSinkSpec(spec, document, sink);
    }
}

74. DocumentationEnricher#addDocumentation()

Project: camel
Source File: DocumentationEnricher.java
View license
private void addDocumentation(Element item, String textContent) {
    Element annotation = document.createElement(Constants.XS_ANNOTATION_ELEMENT_NAME);
    Element documentation = document.createElement(Constants.XS_DOCUMENTATION_ELEMENT_NAME);
    documentation.setAttribute("xml:lang", "en");
    CDATASection cdataDocumentationText = document.createCDATASection(formatTextContent(item, textContent));
    documentation.appendChild(cdataDocumentationText);
    annotation.appendChild(documentation);
    if (item.getFirstChild() != null) {
        item.insertBefore(annotation, item.getFirstChild());
    } else {
        item.appendChild(annotation);
    }
}

75. ConfigurationDOMFactoryTest#testRemoveElement()

View license
@Test
public void testRemoveElement() throws ParserConfigurationException, IllegalAccessException, InstantiationException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException, SAXException, IOException {
    CommandTagRemove commandTagRemove = new CommandTagRemove(25L, 23L, 234L);
    DataTagRemove dataTagRemove = new DataTagRemove(24L, 22L, 324L);
    Document document = xmlFactory.createDocument();
    Element configElement = xmlFactory.createConfigurationChangeEventElement(document);
    document.appendChild(configElement);
    Element commandTagRemoveElement = xmlFactory.createCommandTagRemoveElement(document, commandTagRemove);
    Element dataTagRemoveElement = xmlFactory.createDataTagRemoveElement(document, dataTagRemove);
    configElement.appendChild(commandTagRemoveElement);
    configElement.appendChild(dataTagRemoveElement);
}

76. ConfigurationDOMFactoryTest#testDataTagAddNode()

View license
@Test
public void testDataTagAddNode() throws ParserConfigurationException, IllegalAccessException, InstantiationException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException, SAXException, IOException {
    DataTagAdd dataTagAdd = createDataTagAdd();
    DataTagAdd anotherDataTagAdd = createDataTagAdd();
    Document document = xmlFactory.createDocument();
    Element configurationElement = xmlFactory.createConfigurationChangeEventElement(document);
    document.appendChild(configurationElement);
    Element dataTagAddElement = xmlFactory.createDataTagAddElement(document, dataTagAdd);
    Element anotherDataTagAddElement = xmlFactory.createDataTagAddElement(document, anotherDataTagAdd);
    configurationElement.appendChild(dataTagAddElement);
    configurationElement.appendChild(anotherDataTagAddElement);
}

77. NodeBaseURITest#runImplBasic()

Project: batik
Source File: NodeBaseURITest.java
View license
public boolean runImplBasic() throws Exception {
    Document doc = newSVGDoc();
    ((AbstractDocument) doc).setDocumentURI("http://example.com/blah");
    Element e = doc.createElementNS(SVG_NAMESPACE_URI, "g");
    doc.getDocumentElement().appendChild(e);
    e.setAttributeNS(XML_NAMESPACE_URI, "xml:base", "http://example.org/base");
    Element e2 = doc.createElementNS(SVG_NAMESPACE_URI, "g");
    e.appendChild(e2);
    e2.setAttributeNS(XML_NAMESPACE_URI, "xml:base", "/somewhere");
    return "http://example.com/blah".equals(((AbstractNode) doc).getBaseURI()) && "http://example.org/base".equals(((AbstractNode) e).getBaseURI()) && "http://example.org/somewhere".equals(((AbstractNode) e2).getBaseURI());
}

78. SVGTextContentRenderingAccuracyTest#manipulateSVGDocument()

View license
protected Document manipulateSVGDocument(Document doc) {
    Element root = doc.getDocumentElement();
    String function;
    if (parameter == null) {
        function = onload + "()";
    } else {
        function = onload + "(" + parameter + ")";
    }
    root.setAttributeNS(null, "onload", function);
    Element scriptElement = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SCRIPT_TAG);
    scriptElement.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, XMLConstants.XLINK_HREF_QNAME, script);
    root.appendChild(scriptElement);
    return doc;
}

79. SVGLine#toSVG()

Project: batik
Source File: SVGLine.java
View license
/**
     * @param line the Line2D object to be converted
     */
public Element toSVG(Line2D line) {
    Element svgLine = generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_LINE_TAG);
    svgLine.setAttributeNS(null, SVG_X1_ATTRIBUTE, doubleString(line.getX1()));
    svgLine.setAttributeNS(null, SVG_Y1_ATTRIBUTE, doubleString(line.getY1()));
    svgLine.setAttributeNS(null, SVG_X2_ATTRIBUTE, doubleString(line.getX2()));
    svgLine.setAttributeNS(null, SVG_Y2_ATTRIBUTE, doubleString(line.getY2()));
    return svgLine;
}

80. ServiceFileCreator#getServiceModel()

Project: axis2-java
Source File: ServiceFileCreator.java
View license
private Document getServiceModel(String serviceName, String className, ArrayList methods) {
    DocumentBuilder builder = null;
    try {
        builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException(e);
    }
    Document doc = builder.newDocument();
    Element rootElement = doc.createElement("interface");
    rootElement.setAttribute("classpackage", "");
    rootElement.setAttribute("name", className);
    rootElement.setAttribute("servicename", serviceName);
    Element methodElement = null;
    int size = methods.size();
    for (int i = 0; i < size; i++) {
        methodElement = doc.createElement("method");
        rootElement.setAttribute("name", methods.get(i).toString());
        rootElement.appendChild(methodElement);
    }
    doc.appendChild(rootElement);
    return doc;
}

81. ServiceFileCreator#getServiceModel()

Project: axis2-java
Source File: ServiceFileCreator.java
View license
private Document getServiceModel(String serviceName, String className, ArrayList methods) {
    DocumentBuilder builder = null;
    try {
        builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException(e);
    }
    Document doc = builder.newDocument();
    Element rootElement = doc.createElement("interface");
    rootElement.setAttribute("classpackage", "");
    rootElement.setAttribute("name", className);
    rootElement.setAttribute("servicename", serviceName);
    Element methodElement = null;
    int size = methods.size();
    for (int i = 0; i < size; i++) {
        methodElement = doc.createElement("method");
        rootElement.setAttribute("name", methods.get(i).toString());
        rootElement.appendChild(methodElement);
    }
    doc.appendChild(rootElement);
    return doc;
}

82. AnnotationElementBuilder#buildWebServiceClientAnnotationElement()

View license
static Element buildWebServiceClientAnnotationElement(String name, String targetNS, String wsdlLocation, Document doc) {
    Element annotationElement = doc.createElement("annotation");
    XSLTUtils.addAttribute(doc, "name", "javax.xml.ws.WebServiceClient", annotationElement);
    Element paramElement = doc.createElement("param");
    XSLTUtils.addAttribute(doc, "type", "name", paramElement);
    XSLTUtils.addAttribute(doc, "value", name, paramElement);
    annotationElement.appendChild(paramElement);
    paramElement = doc.createElement("param");
    XSLTUtils.addAttribute(doc, "type", "targetNamespace", paramElement);
    XSLTUtils.addAttribute(doc, "value", targetNS, paramElement);
    annotationElement.appendChild(paramElement);
    paramElement = doc.createElement("param");
    XSLTUtils.addAttribute(doc, "type", "wsdlLocation", paramElement);
    XSLTUtils.addAttribute(doc, "value", wsdlLocation, paramElement);
    annotationElement.appendChild(paramElement);
    return annotationElement;
}

83. AbstractCommand#createResponse()

Project: jphp
Source File: AbstractCommand.java
View license
protected Element createResponse(CommandArguments args, Document document) {
    Element response = document.createElement("response");
    response.setAttribute("xmlns", "urn:debugger_protocol_v1");
    response.setAttribute("xmlns:xdebug", "http://xdebug.org/dbgp/xdebug");
    response.setAttribute("command", getName());
    response.setAttribute("transaction_id", args.getTransactionId());
    document.appendChild(response);
    return response;
}

84. mxDomUtils#createHtmlDocument()

Project: jgraphx
Source File: mxDomUtils.java
View license
/**
	 * Returns a document with a HTML node containing a HEAD and BODY node.
	 */
public static Document createHtmlDocument() {
    Document document = createDocument();
    Element root = document.createElement("html");
    document.appendChild(root);
    Element head = document.createElement("head");
    root.appendChild(head);
    Element body = document.createElement("body");
    root.appendChild(body);
    return document;
}

85. DOMKeyValue#marshalRSAPublicKey()

Project: jdk7u-jdk
Source File: DOMKeyValue.java
View license
private void marshalRSAPublicKey(Node parent, Document doc, String dsPrefix, DOMCryptoContext context) throws MarshalException {
    Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue", XMLSignature.XMLNS, dsPrefix);
    Element modulusElem = DOMUtils.createElement(doc, "Modulus", XMLSignature.XMLNS, dsPrefix);
    Element exponentElem = DOMUtils.createElement(doc, "Exponent", XMLSignature.XMLNS, dsPrefix);
    modulus.marshal(modulusElem, dsPrefix, context);
    exponent.marshal(exponentElem, dsPrefix, context);
    rsaElem.appendChild(modulusElem);
    rsaElem.appendChild(exponentElem);
    parent.appendChild(rsaElem);
}

86. RegistrationDocument#addServiceTagRegistry()

Project: jdk7u-jdk
Source File: RegistrationDocument.java
View license
private static void addServiceTagRegistry(Document document, String registryURN, Set<ServiceTag> svcTags) {
    // add service tag registry node and its attributes
    Element reg = document.createElement(ST_NODE_REGISTRY);
    reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN);
    reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION);
    Element root = getRegistrationDataRoot(document);
    root.appendChild(reg);
    // adds the elements for the service tags
    for (ServiceTag st : svcTags) {
        addServiceTagElement(document, reg, st);
    }
}

87. ModuleConfig#toXml()

Project: controller
Source File: ModuleConfig.java
View license
public Element toXml(ObjectName instanceON, Document document, String namespace, final EnumResolver enumResolver) {
    final Optional<String> configNs = Optional.of(XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
    Element root = XmlUtil.createElement(document, XmlMappingConstants.MODULE_KEY, configNs);
    // type belongs to config.yang namespace, but needs to be <type prefix:moduleNS>prefix:moduleName</type>
    Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlMappingConstants.TYPE_KEY, XmlMappingConstants.PREFIX, namespace, moduleName, configNs);
    root.appendChild(typeElement);
    // name belongs to config.yang namespace
    String instanceName = ObjectNameUtil.getInstanceName(instanceON);
    Element nameElement = XmlUtil.createTextElement(document, XmlMappingConstants.NAME_KEY, instanceName, configNs);
    root.appendChild(nameElement);
    root = instanceConfig.toXml(instanceON, namespace, document, root, enumResolver);
    return root;
}

88. ObjectNameAttributeWritingStrategy#writeElement()

View license
@Override
public void writeElement(Element parentElement, String namespace, Object value) {
    Util.checkType(value, ObjectNameAttributeMappingStrategy.MappedDependency.class);
    Element innerNode = XmlUtil.createElement(document, key, Optional.of(namespace));
    String moduleName = ((ObjectNameAttributeMappingStrategy.MappedDependency) value).getServiceName();
    String refName = ((ObjectNameAttributeMappingStrategy.MappedDependency) value).getRefName();
    String namespaceForType = ((ObjectNameAttributeMappingStrategy.MappedDependency) value).getNamespace();
    Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlMappingConstants.TYPE_KEY, XmlMappingConstants.PREFIX, namespaceForType, moduleName);
    innerNode.appendChild(typeElement);
    final Element nameElement = XmlUtil.createTextElement(document, XmlMappingConstants.NAME_KEY, refName, Optional.<String>absent());
    innerNode.appendChild(nameElement);
    parentElement.appendChild(innerNode);
}

89. mxDomUtils#createHtmlDocument()

Project: consulo
Source File: mxDomUtils.java
View license
/**
   * Returns a document with a HTML node containing a HEAD and BODY node.
   */
public static Document createHtmlDocument() {
    Document document = createDocument();
    Element root = document.createElement("html");
    document.appendChild(root);
    Element head = document.createElement("head");
    root.appendChild(head);
    Element body = document.createElement("body");
    root.appendChild(body);
    return document;
}

90. BuildTargetsSerializer#writeBuildTargetElement()

View license
protected Element writeBuildTargetElement(Document doc, BuildTargetDataView btd) {
    Element targetElem = doc.createElement(TARGET_ElemName);
    targetElem.setAttribute(PROP_NAME, btd.getTargetName());
    targetElem.setAttribute(PROP_ENABLED, Boolean.toString(btd.isNormalBuildEnabled()));
    targetElem.setAttribute(PROP_AUTO_ENABLED, Boolean.toString(btd.isAutoBuildEnabled()));
    targetElem.setAttribute(PROP_FORMAT_VERSION2, "true");
    commandSerializer.writeToParent(targetElem, btd.getBuildCommand());
    setAttribute(targetElem, PROP_EXE_PATH, btd.getExecutablePath());
    return targetElem;
}

91. ElementTest#testDuplicateAttributeNode()

Project: openjdk
Source File: ElementTest.java
View license
/*
     * Test setAttributeNode, newAttr can't be an attribute of another Element
     * object, must explicitly clone Attr nodes to re-use them in other
     * elements.
     */
@Test
public void testDuplicateAttributeNode() throws Exception {
    final String name = "testAttrName";
    final String value = "testAttrValue";
    Document document = createNewDocument();
    Attr attr = document.createAttribute(name);
    attr.setValue(value);
    Element element1 = document.createElement("AFirstElement");
    element1.setAttributeNode(attr);
    Element element2 = document.createElement("ASecondElement");
    Attr attr2 = (Attr) attr.cloneNode(true);
    element2.setAttributeNode(attr2);
    assertEquals(element1.getAttribute(name), element2.getAttribute(name));
    Element element3 = document.createElement("AThirdElement");
    try {
        element3.setAttributeNode(attr);
        fail(DOMEXCEPTION_EXPECTED);
    } catch (DOMException doe) {
        assertEquals(doe.code, INUSE_ATTRIBUTE_ERR);
    }
}

92. XpathDirectiveTest#findsNodesByXpathDirectly()

Project: xembly
Source File: XpathDirectiveTest.java
View license
/**
     * XpathDirective can find nodes by XPath.
     * @throws Exception If some problem inside
     * @since 0.7
     */
@Test
public void findsNodesByXpathDirectly() throws Exception {
    final Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    final Element root = dom.createElement("xxx");
    final Element first = dom.createElement("a");
    root.appendChild(first);
    final Element second = dom.createElement("b");
    root.appendChild(second);
    dom.appendChild(root);
    MatcherAssert.assertThat(new XpathDirective("/*").exec(dom, new DomCursor(Collections.<Node>singletonList(first)), new DomStack()), Matchers.hasItem(root));
}

93. XmlDataWriter#createRobots()

Project: uadetector
Source File: XmlDataWriter.java
View license
private static Element createRobots(final Robot robot, final Document doc) {
    final Element r = doc.createElement(Tag.ROBOT);
    final Element id = doc.createElement(Tag.ID);
    id.appendChild(doc.createTextNode(String.valueOf(robot.getId())));
    r.appendChild(id);
    final Element useragent = doc.createElement(Tag.USERAGENT);
    useragent.appendChild(doc.createCDATASection(robot.getUserAgentString()));
    r.appendChild(useragent);
    final Element family = doc.createElement(Tag.FAMILY);
    family.appendChild(doc.createTextNode(robot.getFamilyName()));
    r.appendChild(family);
    final Element name = doc.createElement(Tag.NAME);
    name.appendChild(doc.createTextNode(robot.getName()));
    r.appendChild(name);
    final Element company = doc.createElement(Tag.COMPANY);
    company.appendChild(doc.createCDATASection(robot.getProducer()));
    r.appendChild(company);
    final Element companyUrl = doc.createElement(Tag.URL_COMPANY);
    companyUrl.appendChild(doc.createCDATASection(robot.getProducerUrl()));
    r.appendChild(companyUrl);
    final Element icon = doc.createElement(Tag.ICON);
    icon.appendChild(doc.createTextNode(robot.getIcon()));
    r.appendChild(icon);
    final Element botInfoUrl = doc.createElement(Tag.BOT_INFO_URL);
    botInfoUrl.appendChild(doc.createTextNode(robot.getInfoUrl()));
    r.appendChild(botInfoUrl);
    return r;
}

94. XmlDataWriter#createOperatingSystem()

Project: uadetector
Source File: XmlDataWriter.java
View license
private static Element createOperatingSystem(final OperatingSystem operatingSystem, final Document doc) {
    final Element os = doc.createElement(Tag.OS);
    final Element id = doc.createElement("id");
    id.appendChild(doc.createTextNode(String.valueOf(operatingSystem.getId())));
    os.appendChild(id);
    final Element family = doc.createElement(Tag.FAMILY);
    family.appendChild(doc.createTextNode(operatingSystem.getFamily()));
    os.appendChild(family);
    final Element name = doc.createElement(Tag.NAME);
    name.appendChild(doc.createTextNode(operatingSystem.getName()));
    os.appendChild(name);
    final Element url = doc.createElement(Tag.URL);
    url.appendChild(doc.createCDATASection(operatingSystem.getUrl()));
    os.appendChild(url);
    final Element company = doc.createElement(Tag.COMPANY);
    company.appendChild(doc.createCDATASection(operatingSystem.getProducer()));
    os.appendChild(company);
    final Element companyUrl = doc.createElement(Tag.URL_COMPANY);
    companyUrl.appendChild(doc.createCDATASection(operatingSystem.getProducerUrl()));
    os.appendChild(companyUrl);
    final Element icon = doc.createElement(Tag.ICON);
    icon.appendChild(doc.createTextNode(operatingSystem.getIcon()));
    os.appendChild(icon);
    final Element botInfoUrl = doc.createElement(Tag.OS_INFO_URL);
    botInfoUrl.appendChild(doc.createTextNode(operatingSystem.getInfoUrl()));
    os.appendChild(botInfoUrl);
    return os;
}

95. XmlDataWriter#createBrowser()

Project: uadetector
Source File: XmlDataWriter.java
View license
private static Element createBrowser(final Browser browser, final Document doc) {
    final Element b = doc.createElement(Tag.BROWSER);
    final Element id = doc.createElement(Tag.ID);
    id.appendChild(doc.createTextNode(String.valueOf(browser.getId())));
    b.appendChild(id);
    final Element family = doc.createElement(Tag.TYPE);
    family.appendChild(doc.createTextNode(String.valueOf(browser.getType().getId())));
    b.appendChild(family);
    final Element name = doc.createElement(Tag.NAME);
    name.appendChild(doc.createTextNode(browser.getFamilyName()));
    b.appendChild(name);
    final Element url = doc.createElement(Tag.URL);
    url.appendChild(doc.createCDATASection(browser.getUrl()));
    b.appendChild(url);
    final Element company = doc.createElement(Tag.COMPANY);
    company.appendChild(doc.createCDATASection(browser.getProducer()));
    b.appendChild(company);
    final Element companyUrl = doc.createElement(Tag.URL_COMPANY);
    companyUrl.appendChild(doc.createCDATASection(browser.getProducerUrl()));
    b.appendChild(companyUrl);
    final Element icon = doc.createElement(Tag.ICON);
    icon.appendChild(doc.createTextNode(browser.getIcon()));
    b.appendChild(icon);
    final Element botInfoUrl = doc.createElement(Tag.BROWSER_INFO_URL);
    botInfoUrl.appendChild(doc.createTextNode(browser.getInfoUrl()));
    b.appendChild(botInfoUrl);
    return b;
}

96. DifferenceHelperTest#initDefaultDocument()

View license
private Document initDefaultDocument() throws ParserConfigurationException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    Document document = factory.newDocumentBuilder().newDocument();
    Element root = document.createElement("rootElement");
    document.appendChild(root);
    Attr scriptAttribute = document.createAttribute("src");
    scriptAttribute.setValue("http://localhost");
    Element script = document.createElement("script");
    script.setAttributeNode(scriptAttribute);
    root.appendChild(script);
    root.appendChild(document.createTextNode("Data"));
    return document;
}

97. RemoveDirectiveTest#removesDomNodesDirectly()

Project: xembly
Source File: RemoveDirectiveTest.java
View license
/**
     * RemoveDirective can remove nodes.
     * @throws Exception If some problem inside
     * @since 0.7
     */
@Test
public void removesDomNodesDirectly() throws Exception {
    final Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    final Element root = dom.createElement("xxx");
    final Element first = dom.createElement("a");
    root.appendChild(first);
    final Element second = dom.createElement("b");
    root.appendChild(second);
    dom.appendChild(root);
    new RemoveDirective().exec(dom, new DomCursor(Collections.<Node>singletonList(first)), new DomStack());
    MatcherAssert.assertThat(XhtmlMatchers.xhtml(dom), XhtmlMatchers.hasXPath("/xxx[b and not(a)]"));
}

98. ConfigXml#changeDefaultFolder()

Project: syncthing-android
Source File: ConfigXml.java
View license
/**
     * Change default folder id to camera and path to camera folder path.
     */
public void changeDefaultFolder() {
    Element folder = (Element) mConfig.getDocumentElement().getElementsByTagName("folder").item(0);
    String model = Build.MODEL.replace(" ", "_").toLowerCase(Locale.US).replaceAll("[^a-z0-9_-]", "");
    folder.setAttribute("label", mContext.getString(R.string.default_folder_label));
    folder.setAttribute("id", mContext.getString(R.string.default_folder_id, model));
    folder.setAttribute("path", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath());
    folder.setAttribute("type", "readonly");
    saveChanges();
}

99. AttrDirectiveTest#addsDomAttributesDirectly()

Project: xembly
Source File: AttrDirectiveTest.java
View license
/**
     * AttrDirective can add attribute to node.
     * @throws Exception If some problem inside
     * @since 0.7
     */
@Test
public void addsDomAttributesDirectly() throws Exception {
    final Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    final Element root = dom.createElement("xxx");
    final Element first = dom.createElement("a");
    root.appendChild(first);
    final Element second = dom.createElement("b");
    root.appendChild(second);
    dom.appendChild(root);
    new AttrDirective("x", "y").exec(dom, new DomCursor(Collections.<Node>singletonList(second)), new DomStack());
    MatcherAssert.assertThat(XhtmlMatchers.xhtml(dom), XhtmlMatchers.hasXPath("/xxx/b[@x='y']"));
}

100. XmlRenderer#testFailure()

Project: sling
Source File: XmlRenderer.java
View license
@Override
public void testFailure(Failure failure) throws Exception {
    super.testFailure(failure);
    failures.add(failure.getDescription());
    Element nested = doc.createElement("failure");
    Element currentTest = testElements.get(failure.getDescription());
    currentTest.appendChild(nested);
    String message = failure.getMessage();
    if (message != null && message.length() > 0) {
        nested.setAttribute("message", message);
    }
    nested.setAttribute("type", failure.getClass().getName());
    String strace = getException(failure.getException());
    strace = BaseTestRunner.getFilteredTrace(strace);
    Text trace = doc.createTextNode(strace);
    nested.appendChild(trace);
}