當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。