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


Java XMLStreamWriter.writeAttribute方法代码示例

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


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

示例1: writeGroup

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

    writer.writeStartElement(GROUP_ELEMENT);
    writer.writeAttribute(IDENTIFIER_ATTR, group.getIdentifier());
    writer.writeAttribute(NAME_ATTR, group.getName());

    for (String user : users) {
        writer.writeStartElement(GROUP_USER_ELEMENT);
        writer.writeAttribute(IDENTIFIER_ATTR, user);
        writer.writeEndElement();
    }

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

示例2: writeTo

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    w.writeStartElement("", name.getLocalPart(), name.getNamespaceURI());
    w.writeDefaultNamespace(name.getNamespaceURI());
    if (mustUnderstand) {
        //Writing the ns declaration conditionally checking in the NSContext breaks XWSS. as readHeader() adds ns declaration,
        // where as writing alonf with the soap envelope does n't add it.
        //Looks like they expect the readHeader() and writeTo() produce the same infoset, Need to understand their usage

        //if(w.getNamespaceContext().getPrefix(soapVersion.nsUri) == null) {
        w.writeNamespace("S", soapVersion.nsUri);
        w.writeAttribute("S", soapVersion.nsUri, MUST_UNDERSTAND, getMustUnderstandLiteral(soapVersion));
        // } else {
        // w.writeAttribute(soapVersion.nsUri,MUST_UNDERSTAND, getMustUnderstandLiteral(soapVersion));
        // }
    }
    w.writeCharacters(value);
    w.writeEndElement();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:StringHeader.java

示例3: 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

示例4: 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)) {
  for (SubGeographicalRegion regions : this.regions){
           try {
             xmlsw.writeEmptyElement(CIMURI.CIMURI,"GeographicalRegion.Regions");
             xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                       + regions.getId());
           } catch (XMLStreamException e) {
             StringBuilder errorMessage = new StringBuilder(
                                "Error while trying to write the reference to ");
             errorMessage.append("GeographicalRegion ");
             errorMessage.append("which ID has been initialized to : ");
             errorMessage.append(getId());
             errorMessage.append(" in the subset ");
             errorMessage.append("Equipment");
             LOGGER.error(errorMessage.toString());
             LOGGER.error(e.toString(), e);
           }
  }
    }

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

示例5: 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)) {
  for (TopologicalNode topologicalNode : this.topologicalNode){
           try {
             xmlsw.writeEmptyElement(CIMURI.CIMURI,"ConnectivityNodeContainer.TopologicalNode");
             xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                       + topologicalNode.getId());
           } catch (XMLStreamException e) {
             StringBuilder errorMessage = new StringBuilder(
                                "Error while trying to write the reference to ");
             errorMessage.append("ConnectivityNodeContainer ");
             errorMessage.append("which ID has been initialized to : ");
             errorMessage.append(getId());
             errorMessage.append(" in the subset ");
             errorMessage.append("${subsetModel.getSubset($class).getName()}");
             LOGGER.error(errorMessage.toString());
             LOGGER.error(e.toString(), e);
           }
  }
    }

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

示例6: 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)) {
  for (TransformerWinding contains_TransformerWindings : this.contains_TransformerWindings){
           try {
             xmlsw.writeEmptyElement(CIMURI.CIMURI,"PowerTransformer.Contains_TransformerWindings");
             xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                       + contains_TransformerWindings.getId());
           } catch (XMLStreamException e) {
             StringBuilder errorMessage = new StringBuilder(
                                "Error while trying to write the reference to ");
             errorMessage.append("PowerTransformer ");
             errorMessage.append("which ID has been initialized to : ");
             errorMessage.append(getId());
             errorMessage.append(" in the subset ");
             errorMessage.append("Equipment");
             LOGGER.error(errorMessage.toString());
             LOGGER.error(e.toString(), e);
           }
  }
    }

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

示例7: exportResource

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
static void exportResource(XMLStreamWriter writer,
		AbstractResource ar) throws XMLStreamException {
	writer.writeStartElement("Resource");
	writer.writeAttribute("type", ar.getClass().getSimpleName());
	//Export additional construction parameters
	exportConstructParameters(writer, ar);
	exportParameters(writer, ar);
	writer.writeEndElement();//End of Resource
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:10,代码来源:XMLExporter.java

示例8: printUnknownField

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
private void printUnknownField(String fieldKey,
        String fieldValue,
        XMLStreamWriter generator) throws XMLStreamException {
          
    generator.writeStartElement(UNKNOWN_FIELD_ELEMENT);
    generator.writeAttribute(UNKNOWN_FIELD_INDEX, fieldKey);
    generator.writeCharacters(fieldValue);
    generator.writeEndElement();
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:10,代码来源:XmlJavaxFormat.java

示例9: 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,代码来源:FileAccessPolicyProvider.java

示例10: 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

示例11: writeNativeDrillConnection

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

  xmlStreamWriter.writeStartElement("connection");

  xmlStreamWriter.writeAttribute("class", "drill");
  xmlStreamWriter.writeAttribute("connection-type", "Direct");
  xmlStreamWriter.writeAttribute("authentication", "Basic Authentication");

  xmlStreamWriter.writeAttribute("odbc-connect-string-extras", "");
  // It has to match what is returned by the driver/Tableau
  xmlStreamWriter.writeAttribute("schema", dataset.toParentPath());
  xmlStreamWriter.writeAttribute("port", String.valueOf(endpoint.getUserPort()));
  xmlStreamWriter.writeAttribute("server", hostname);

  writeRelation(xmlStreamWriter, datasetConfig);
  if (customizationEnabled) {
    writeConnectionCustomization(xmlStreamWriter);
  }

  /* DX-7447 - When using the drill driver, Tableau will show an misleading error message because it could not connect
    to Dremio since it doesn't have the username/password (and doesn't prompt for them first).  To work around this,
    we generate metadata for the Dataset and add it to the .tds file.  This prefills the schema in Tableau and when
    the user starts working with the schema it will prompt the user to authenticate with Dremio.
  */
  writeTableauMetadata(xmlStreamWriter, datasetConfig);

  xmlStreamWriter.writeEndElement();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:30,代码来源: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)) {
    if (idRegulatingControl != null) {
        try {
            // xmlsw.writeCharacters("\t");
            xmlsw.writeEmptyElement(CIMURI.CIMURI,
                    "RegulatingCondEq.RegulatingControl");
            xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                    + idRegulatingControl);
            // xmlsw.writeCharacters("\n");
        } catch(XMLStreamException e) {
            StringBuilder errorMessage = new StringBuilder(
                    "Error while trying to write the resource attribute ");
            errorMessage.append("RegulatingControl");
            errorMessage.append(" in class ");
            errorMessage.append("RegulatingCondEq ");
            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,代码行数:34,代码来源:RegulatingCondEq.java

示例13: 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)) {

/*
 * Careful here : we may write an association "twice" if
 * the association is 1..1 one and if
 * both ends belong to the same subset
 */

    if (idBusbarSection != null &&
            !idBusbarSection.isEmpty()) {

        try {
            // xmlsw.writeCharacters("\t");
            xmlsw.writeEmptyElement(CIMURI.CIMURI,
                    "VoltageControlZone.BusbarSection");
            xmlsw.writeAttribute(CIMModel.rdfURI, "resource", "#"
                    + idBusbarSection);
            // xmlsw.writeCharacters("\n");
        } catch(XMLStreamException e) {
            StringBuilder errorMessage = new StringBuilder(
                    "Error while trying to write the resource attribute ");
            errorMessage.append("BusbarSection");
            errorMessage.append(" in class ");
            errorMessage.append("VoltageControlZone ");
            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,代码行数:43,代码来源:VoltageControlZone.java

示例14: 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("freq-out-count");
    xmlWriter.writeCharacters(Integer.toString(freqOutCount));
    xmlWriter.writeEndElement();
    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:12,代码来源:TsoFrequencySecurityIndex.java

示例15: writeOptionalFloat

import javax.xml.stream.XMLStreamWriter; //导入方法依赖的package包/类
public static void writeOptionalFloat(String name, float value, float absentValue, XMLStreamWriter writer) throws XMLStreamException {
    if (!Float.isNaN(value) && value != absentValue) {
        writer.writeAttribute(name, Float.toString(value));
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:6,代码来源:XmlUtil.java


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