当前位置: 首页>>代码示例>>Java>>正文


Java XMLStreamWriter.writeStartElement方法代码示例

本文整理汇总了Java中javax.xml.stream.XMLStreamWriter.writeStartElement方法的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamWriter.writeStartElement方法的具体用法?Java XMLStreamWriter.writeStartElement怎么用?Java XMLStreamWriter.writeStartElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.stream.XMLStreamWriter的用法示例。


在下文中一共展示了XMLStreamWriter.writeStartElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toXml

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Override
public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);

    xmlWriter.writeStartElement("computation-succeed");
    xmlWriter.writeCharacters(Boolean.toString(computationSucceed));
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("overvoltage-count");
    xmlWriter.writeCharacters(Integer.toString(overvoltageCount));
    xmlWriter.writeEndElement();

    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:18,代码来源:TsoOvervoltageSecurityIndex.java

示例2: parse

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
 * Parses an inputstream containin xlsx into an outputStream containing XML
 * 
 * @param inputStream
 *            the source
 * @param outputStream
 *            the result
 * @throws IOException
 * @throws XMLStreamException
 */
public void parse(final InputStream inputStream, final OutputStream outputStream)
		throws IOException, XMLStreamException {
	XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
	XMLStreamWriter out = this.getXMLWriter(outputStream);
	out.writeStartDocument();
	out.writeStartElement("workbook");
	int sheetCount = workbook.getNumberOfSheets();
	for (int i = 0; i < sheetCount; i++) {
		final XSSFSheet sheet = workbook.getSheetAt(i);
		try {
			this.export(sheet, out);
		} catch (UnsupportedEncodingException | FileNotFoundException | XMLStreamException
				| FactoryConfigurationError e) {
			e.printStackTrace();
		}
	}
	out.writeEndElement();
	out.writeEndDocument();
	out.close();
	workbook.close();
}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:32,代码来源:E2xCmdline.java

示例3: generateXML

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
private void generateXML(XMLStreamWriter writer, String sequence)
        throws XMLStreamException {
    char[] seqArr = sequence.toCharArray();
    writer.writeStartDocument();
    writer.writeStartElement("root");

    // Use writeCharacters( String ) to write characters
    writer.writeStartElement("writeCharactersWithString");
    writer.writeCharacters(sequence);
    writer.writeEndElement();

    // Use writeCharacters( char [], int , int ) to write characters
    writer.writeStartElement("writeCharactersWithArray");
    writer.writeCharacters(seqArr, 0, seqArr.length);
    writer.writeEndElement();

    // Close root element and document
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.flush();
    writer.close();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SurrogatesTest.java

示例4: writeConnection

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
private void writeConnection(XMLStreamWriter xmlStreamWriter, DatasetConfig datasetConfig, String hostname) throws XMLStreamException {
  DatasetPath dataset = new DatasetPath(datasetConfig.getFullPathList());

  xmlStreamWriter.writeStartElement("connection");

  xmlStreamWriter.writeAttribute("class", "genericodbc");
  xmlStreamWriter.writeAttribute("dbname", InfoSchemaConstants.IS_CATALOG_NAME);
  xmlStreamWriter.writeAttribute("odbc-connect-string-extras", format("AUTHENTICATIONTYPE=Basic Authentication;CONNECTIONTYPE=Direct;HOST=%s", hostname));
  // It has to match what is returned by the driver/Tableau
  xmlStreamWriter.writeAttribute("odbc-dbms-name", "Dremio");
  xmlStreamWriter.writeAttribute("odbc-driver", "Dremio Connector");
  xmlStreamWriter.writeAttribute("odbc-dsn", "");
  xmlStreamWriter.writeAttribute("odbc-suppress-connection-pooling", "");
  xmlStreamWriter.writeAttribute("odbc-use-connection-pooling", "");
  xmlStreamWriter.writeAttribute("schema", dataset.toParentPath());
  xmlStreamWriter.writeAttribute("port", String.valueOf(endpoint.getUserPort()));
  xmlStreamWriter.writeAttribute("server", "");
  xmlStreamWriter.writeAttribute("username", "");

  writeRelation(xmlStreamWriter, datasetConfig);
  if (customizationEnabled) {
    writeConnectionCustomization(xmlStreamWriter);
  }
  xmlStreamWriter.writeEndElement();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:TableauMessageBodyGenerator.java

示例5: testSAXResult

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Test
public void testSAXResult() {
    DefaultHandler handler = new DefaultHandler();

    final String EXPECTED_OUTPUT = "<?xml version=\"1.0\"?><root></root>";
    try {
        SAXResult saxResult = new SAXResult(handler);
        // saxResult.setSystemId("jaxp-ri/unit-test/javax/xml/stream/XMLOutputFactoryTest/cr6846132.xml");
        XMLOutputFactory ofac = XMLOutputFactory.newInstance();
        XMLStreamWriter writer = ofac.createXMLStreamWriter(saxResult);
        writer.writeStartDocument("1.0");
        writer.writeStartElement("root");
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.flush();
        writer.close();
    } catch (Exception e) {
        if (e instanceof UnsupportedOperationException) {
            // expected
        } else {
            e.printStackTrace();
            Assert.fail(e.toString());
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Bug6846132Test.java

示例6: testBoundPrefix

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Test
public void testBoundPrefix() throws Exception {

    try {
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        XMLStreamWriter w = xof.createXMLStreamWriter(System.out);
        // here I'm trying to write
        // <bar xmlns="foo" />
        w.writeStartDocument();
        w.writeStartElement("foo", "bar", "http://namespace");
        w.writeCharacters("---");
        w.writeEndElement();
        w.writeEndDocument();
        w.close();

        // Expected success
        System.out.println("Expected success.");
    } catch (Exception exception) {
        // Unexpected Exception
        String FAIL_MSG = "Unexpected Exception: " + exception.toString();
        System.err.println(FAIL_MSG);
        Assert.fail(FAIL_MSG);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:UnprefixedNameTest.java

示例7: toXml

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Override
public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);

    xmlWriter.writeStartElement("computation-succeed");
    xmlWriter.writeCharacters(Boolean.toString(computationSucceed));
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("overload-count");
    xmlWriter.writeCharacters(Integer.toString(overloadCount));
    xmlWriter.writeEndElement();

    for (String overloadedBranch : overloadedBranches) {
        xmlWriter.writeStartElement("overloaded-branch");
        xmlWriter.writeCharacters(overloadedBranch);
        xmlWriter.writeEndElement();
    }

    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:24,代码来源:TsoOverloadSecurityIndex.java

示例8: toXml

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Override
public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);

    xmlWriter.writeStartElement("synchro-loss-count");
    xmlWriter.writeCharacters(Integer.toString(synchroLossCount));
    xmlWriter.writeEndElement();

    for (Map.Entry<String, Float> e : desynchronizedGenerators.entrySet()) {
        String id = e.getKey();
        float p = e.getValue();
        xmlWriter.writeStartElement(GENERATOR);
        xmlWriter.writeAttribute("id", id);
        xmlWriter.writeCharacters(Float.toString(p));
        xmlWriter.writeEndElement();
    }

    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:23,代码来源:TsoSynchroLossSecurityIndex.java

示例9: toXml

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Override
public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);

    xmlWriter.writeStartElement("computation-succeed");
    xmlWriter.writeCharacters(Boolean.toString(computationSucceed));
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("undervoltage-count");
    xmlWriter.writeCharacters(Integer.toString(undervoltageCount));
    xmlWriter.writeEndElement();

    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:18,代码来源:TsoUndervoltageSecurityIndex.java

示例10: toXml

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Override
protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException {
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("index");
    xmlWriter.writeAttribute("name", XML_NAME);
    for (Map.Entry<String, Float> e : disconnectedGenerators.entrySet()) {
        String id = e.getKey();
        float p = e.getValue();
        xmlWriter.writeStartElement("generator");
        xmlWriter.writeAttribute("id", id);
        xmlWriter.writeCharacters(Float.toString(p));
        xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:17,代码来源:TsoDisconnectedGenerator.java

示例11: writeElement

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
private void writeElement(XMLStreamWriter xmlStreamWriter, String name, String contents) throws XMLStreamException {
  xmlStreamWriter.writeStartElement(name);

  if (contents != null) {
    xmlStreamWriter.writeCharacters(contents);
  }

  xmlStreamWriter.writeEndElement();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:TableauMessageBodyGenerator.java

示例12: writeClass

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
 * Utility to return the content of this class into the CIM XML format
 *
 * @param xmlsw
 *            the stream in which are stored the elements to write
 */
private void writeClass(XMLStreamWriter xmlsw) {

    if (currentBitset.get(0)) {

    try {
        // xmlsw.writeCharacters("\t");
        xmlsw.writeStartElement(CIMURI.CIMURI,
                "VoltageLimit.value");
        xmlsw.writeCharacters(String.valueOf(getValue()));
        xmlsw.writeEndElement();
        // xmlsw.writeCharacters("\n");
    } catch(XMLStreamException e) {
        StringBuilder errorMessage = new StringBuilder(
                "Error while trying to write the value of the attribute ");
        errorMessage.append("Value");
        errorMessage.append(" in class ");
        errorMessage.append("VoltageLimit ");
        errorMessage.append("which ID has been initialized to : ");
        errorMessage.append(getId());
        LOGGER.error(errorMessage.toString());
        LOGGER.error(e.toString(), e);
    }
    }

    return;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:33,代码来源:VoltageLimit.java

示例13: print

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
/**
 * Outputs a Smile representation of the Protocol Message supplied into the parameter output.
 * (This representation is the new version of the classic "ProtocolPrinter" output from the
 * original Protocol Buffer system)
 */
public void print(Message message, XMLStreamWriter generator) throws IOException {
    try {
        final String messageName = message.getDescriptorForType().getName();
    	generator.writeStartElement(messageName);    	
    	printMessage(message, generator);
        generator.writeEndElement();
        generator.flush();
    } catch (XMLStreamException e) {
        throw new IOException(e);
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:17,代码来源:XmlJavaxFormat.java

示例14: writeTo

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
@Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    w.writeStartElement("", name.getLocalPart(), name.getNamespaceURI());
    w.writeDefaultNamespace(name.getNamespaceURI());
    if (type != null)
        w.writeAttribute("type", type);
    w.writeCharacters(value);
    w.writeEndElement();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:RelatesToHeader.java

示例15: writePolicy

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
private void writePolicy(final XMLStreamWriter writer, final AccessPolicy policy) throws XMLStreamException {
    // sort the users for the policy
    List<String> policyUsers = new ArrayList<>(policy.getUsers());
    Collections.sort(policyUsers);

    // sort the groups for this policy
    List<String> policyGroups = new ArrayList<>(policy.getGroups());
    Collections.sort(policyGroups);

    writer.writeStartElement(POLICY_ELEMENT);
    writer.writeAttribute(IDENTIFIER_ATTR, policy.getIdentifier());
    writer.writeAttribute(RESOURCE_ATTR, policy.getResource());
    writer.writeAttribute(ACTIONS_ATTR, policy.getAction().name());

    for (String policyUser : policyUsers) {
        writer.writeStartElement(POLICY_USER_ELEMENT);
        writer.writeAttribute(IDENTIFIER_ATTR, policyUser);
        writer.writeEndElement();
    }

    for (String policyGroup : policyGroups) {
        writer.writeStartElement(POLICY_GROUP_ELEMENT);
        writer.writeAttribute(IDENTIFIER_ATTR, policyGroup);
        writer.writeEndElement();
    }

    writer.writeEndElement();
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:29,代码来源:AbstractPolicyBasedAuthorizer.java


注:本文中的javax.xml.stream.XMLStreamWriter.writeStartElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。