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


Java XmlCursor.insertAttributeWithValue方法代码示例

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


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

示例1: escapeAttributeValue

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Escapes the reserved characters in a value of an attribute
 *
 * @param value Unescaped text
 * @return The escaped text
 */
public String escapeAttributeValue(Object value)
{
    String text = ScriptRuntime.toString(value);

    if (text.length() == 0) return "";

    XmlObject xo = XmlObject.Factory.newInstance();

    XmlCursor cursor = xo.newCursor();
    cursor.toNextToken();
    cursor.beginElement("a");
    cursor.insertAttributeWithValue("a", text);
    cursor.dispose();

    String elementText = xo.toString();
    int begin = elementText.indexOf('"');
    int end = elementText.lastIndexOf('"');
    return elementText.substring(begin + 1, end);
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:26,代码来源:XMLLibImpl.java

示例2: taotluseAndmedNrLiikParing

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public TaotluseAndmedVastus taotluseAndmedNrLiikParing(String taotluseLiik, String taotluseNr) throws XRoadServiceConsumptionException {
	TaotluseAndmedNrLiikSisend paring = TaotluseAndmedNrLiikSisend.Factory.newInstance();
	paring.setTaotluseLiik(com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.TaotluseLiik.Enum.forString(taotluseLiik));
	paring.setTaotluseNr(taotluseNr);

	//Kuna viisaregister tahab kindlasti oma xsi:type atribuute näha, siis paneme need käsitsi külge
	XmlCursor cursor = paring.newCursor();
	while (!cursor.isEnddoc()) {
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("taotluseLiik")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:taotluseLiik");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("taotluseNr")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string");
		}
		cursor.toNextToken();
	}

	return viisaregisterXRoadDatabase.taotlAndmedNrLiikParingV1(paring);
}
 
开发者ID:nortal,项目名称:j-road,代码行数:22,代码来源:ViisaregisterXTeeServiceImpl.java

示例3: insertSchemaLocation

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
  * Inserts a schema location to the current ebics root element.
  * @param namespaceURI the name space URI
  * @param localPart the local part
  * @param prefix the prefix
  * @param value the value
  */
 public void insertSchemaLocation(String namespaceURI,
                                  String localPart,
                                  String prefix,
                                  String value)
 {
   XmlCursor 			cursor;

   cursor = document.newCursor();
   while (cursor.hasNextToken()) {
     if (cursor.isStart()) {
cursor.toNextToken();
cursor.insertAttributeWithValue(new QName(namespaceURI, localPart, prefix), value);
break;
     } else {
cursor.toNextToken();
     }
   }
 }
 
开发者ID:pinaraf,项目名称:ebics,代码行数:26,代码来源:DefaultEbicsRootElement.java

示例4: processSimpleType

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void processSimpleType( SchemaType stype, XmlCursor xmlc )
{
	if( _soapEnc )
	{
		QName typeName = stype.getName();
		if( typeName != null )
		{
			xmlc.insertAttributeWithValue( XSI_TYPE, formatQName( xmlc, typeName ) );
		}
	}

	String sample = sampleDataForSimpleType( stype );
	xmlc.insertChars( sample );
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:15,代码来源:SampleXmlUtil.java

示例5: setAttribute

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param attrName
 * @param value
 */
void setAttribute(XMLName xmlName, Object value)
{
    if (xmlName.uri() == null &&
        xmlName.localName().equals("*"))
    {
        throw ScriptRuntime.typeError("@* assignment not supported.");
    }

    XmlCursor curs = newCursor();

    String strValue = ScriptRuntime.toString(value);
    if (curs.currentTokenType().isStartdoc())
    {
        curs.toFirstContentToken();
    }

    javax.xml.namespace.QName qName;

    try
    {
        qName = new javax.xml.namespace.QName(xmlName.uri(), xmlName.localName());
    }
    catch(Exception e)
    {
        throw ScriptRuntime.typeError(e.getMessage());
    }

    if (!curs.setAttributeText(qName, strValue))
    {
        if (curs.currentTokenType().isStart())
        {
            // Can only add attributes inside of a start.
            curs.toNextToken();
        }
        curs.insertAttributeWithValue(qName, strValue);
    }

    curs.dispose();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:45,代码来源:XML.java

示例6: addAdditionalNamespace

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * The reason behing adding additional namespace is, there is a difference between Microsoft and
 * Axis web service artifacts
 * 
 * @param queryBase
 */
private final void addAdditionalNamespace(final QueryBase queryBase) {

  /* Get cursor from query node */
  final XmlCursor cursor = queryBase.newCursor();
  cursor.toNextToken();
  cursor.insertNamespace("query", MSCRMSchemaConstants.QUERY);

  /* Set cursor type information */
  cursor.insertAttributeWithValue("type", MSCRMSchemaConstants.XML_SCHEMA_INSTANCE, "query:QueryExpression");

  /* Dispose cursor */
  cursor.dispose();
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:20,代码来源:MSCRMLiveIdBasedServiceManager.java

示例7: addMSSpecificNS

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * This method is to avoid error from MS about missing NS
 * 
 * @param aoat
 */
private static final void addMSSpecificNS(final com.microsoft.schemas._2003._10.serialization.arrays.ArrayOfanyType aoat) {

  /* Create new cursor to add type information */
  final XmlCursor xc = aoat.getAnyTypeArray(0).newCursor();

  /* Go to first element */
  xc.toFirstContentToken();

  /* Add attribute with namespace */
  xc.insertNamespace("xs", "http://www.w3.org/2001/XMLSchema");
  xc.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type"), "xs:string");
  xc.dispose();
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:19,代码来源:MSCRMMessageFormatUtils.java

示例8: addAdditionalNamespace

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private static final void addAdditionalNamespace(final QueryBase queryBase) {

    /* Get cursor from query node */
    final XmlCursor cursor = queryBase.newCursor();
    cursor.toNextToken();
    cursor.insertNamespace("query", MSCRMSchemaConstants.QUERY);

    /* Set cursor type information */
    cursor.insertAttributeWithValue("type", MSCRMSchemaConstants.XML_SCHEMA_INSTANCE, "query:QueryExpression");

    /* Dispose cursor */
    cursor.dispose();
  }
 
开发者ID:inbravo,项目名称:scribe,代码行数:14,代码来源:MSCRMTest.java

示例9: getAttributedXmlString

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Builds a new {@link XmlString} instance holding the given <code>String</code> value. The instance will also have an
 * attribute with <code>xsi:type</code> name (where <code>xsi</code> represent a prefix for
 * <code>http://www.w3.org/2001/XMLSchema-instance</code> namespace) and a <code>xsd:string</code> value (where
 * <code>xsd</code> represents a prefix for <code>http://www.w3.org/2001/XMLSchema</code> namespace).
 * 
 * @param value content value
 * @return constructed {@link XmlString} instance
 */
public static XmlString getAttributedXmlString(String value) {
  XmlString xmlString = XmlString.Factory.newInstance();
  xmlString.setStringValue(value);

  XmlCursor cursor = xmlString.newCursor();
  cursor.toNextToken();
  cursor.insertNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
  cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"),
                                  "xsd:string");

  return xmlString;
}
 
开发者ID:nortal,项目名称:j-road,代码行数:22,代码来源:XmlBeansUtil.java

示例10: processAttributes

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void processAttributes(SchemaType stype, XmlCursor xmlc)
{
    if (_soapEnc)
    {
        QName typeName = stype.getName();
        if (typeName != null)
        {
            xmlc.insertAttributeWithValue(XSI_TYPE, formatQName(xmlc, typeName));
        }
    }
    
    SchemaProperty[] attrProps = stype.getAttributeProperties();
    for (int i = 0; i < attrProps.length; i++)
    {
        SchemaProperty attr = attrProps[i];
        if (_soapEnc)
        {
            if (SKIPPED_SOAP_ATTRS.contains(attr.getName()))
                continue;
            if (ENC_ARRAYTYPE.equals(attr.getName()))
            {
                SOAPArrayType arrayType = ((SchemaWSDLArrayType)stype.getAttributeModel().getAttribute(attr.getName())).getWSDLArrayType();
                if (arrayType != null)
                    xmlc.insertAttributeWithValue(attr.getName(), formatQName(xmlc, arrayType.getQName()) + arrayType.soap11DimensionString());
                continue;
            }
        }
        String defaultValue = attr.getDefaultText();
        xmlc.insertAttributeWithValue(attr.getName(), defaultValue == null ?
            sampleDataForSimpleType(attr.getType()) : defaultValue);
    }
}
 
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:33,代码来源:RestfulApiSchemaManager.java

示例11: processAttributes

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void processAttributes( SchemaType stype, XmlCursor xmlc )
{
	if( _soapEnc )
	{
		QName typeName = stype.getName();
		if( typeName != null )
		{
			xmlc.insertAttributeWithValue( XSI_TYPE, formatQName( xmlc, typeName ) );
		}
	}

	SchemaProperty[] attrProps = stype.getAttributeProperties();
	for( int i = 0; i < attrProps.length; i++ )
	{
		SchemaProperty attr = attrProps[i];
		if( attr.getMinOccurs().intValue() == 0 && ignoreOptional )
			continue;

		if( attr.getName().equals( new QName( "http://www.w3.org/2005/05/xmlmime", "contentType" ) ) )
		{
			xmlc.insertAttributeWithValue( attr.getName(), "application/?" );
			continue;
		}

		if( _soapEnc )
		{
			if( SKIPPED_SOAP_ATTRS.contains( attr.getName() ) )
				continue;
			if( ENC_ARRAYTYPE.equals( attr.getName() ) )
			{
				SOAPArrayType arrayType = ( ( SchemaWSDLArrayType )stype.getAttributeModel().getAttribute(
						attr.getName() ) ).getWSDLArrayType();
				if( arrayType != null )
					xmlc.insertAttributeWithValue( attr.getName(), formatQName( xmlc, arrayType.getQName() )
							+ arrayType.soap11DimensionString() );
				continue;
			}
		}

		String value = null;
		if( multiValues != null )
		{
			String[] values = multiValues.get( attr.getName() );
			if( values != null )
				value = StringUtils.join( values, "," );
		}
		if( value == null )
			value = attr.getDefaultText();
		if( value == null )
			value = sampleDataForSimpleType( attr.getType() );

		xmlc.insertAttributeWithValue( attr.getName(), value );
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:55,代码来源:SampleXmlUtil.java

示例12: insertTypeAttribute

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void insertTypeAttribute(XmlCursor cursor, String uri, String localPart, String prefix, String type) {
  cursor.insertAttributeWithValue(new QName(uri, localPart, prefix), type);
}
 
开发者ID:nortal,项目名称:j-road,代码行数:4,代码来源:TarnXTeeServiceImpl.java

示例13: taotluseAndmedIsikReisidokumentParing

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public TaotlusteNimistuVastus taotluseAndmedIsikReisidokumentParing(String eesnimi, String perenimi, Calendar synniaeg, String sugu, String reisiDokLiik, String reisiDokNr, Calendar reisiDokValjastamisKuup, String toimik) throws XRoadServiceConsumptionException {
	TaotluseAndmedIsikReisidokSisend paring = TaotluseAndmedIsikReisidokSisend.Factory.newInstance();
	if (eesnimi != null || perenimi != null || synniaeg != null || sugu != null) {
		StruktIsikSuguMK isik = paring.addNewIsik();
		isik.setEesnimi(eesnimi);
		isik.setPerenimi(perenimi);
		isik.setSynniaeg(synniaeg);
		com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.Sugu.Enum suguEnum = com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.Sugu.Enum.forString(sugu);
		isik.setSugu(suguEnum);
	}

	com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.ReisiDokLiik.Enum reisiDokLiikEnum = com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.ReisiDokLiik.Enum.forString(reisiDokLiik);
	paring.setReisiDokLiik(reisiDokLiikEnum);
	paring.setReisiDokNr(reisiDokNr);
	paring.setReisiDokValjastamisKuup(reisiDokValjastamisKuup);

	//Kuna viisaregister tahab kindlasti oma xsi:type atribuute näha, siis paneme need käsitsi külge
	XmlCursor cursor = paring.newCursor();
	while (!cursor.isEnddoc()) {
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("isik")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:struktIsikSuguMK");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("eesnimi")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("perenimi")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("synniaeg")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:date");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("sugu")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:sugu");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("reisiDokLiik")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:reisiDokLiik");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("reisiDokNr")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string");
		}
		if (cursor.isStart() && cursor.getName().getLocalPart().equals("reisiDokValjastamisKuup")) {
			cursor.toNextToken();
			cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:date");
		}
		cursor.toNextToken();
	}

	return viisaregisterXRoadDatabase.taotlAndmedIsikReisidokParingV1(paring);
}
 
开发者ID:nortal,项目名称:j-road,代码行数:57,代码来源:ViisaregisterXTeeServiceImpl.java


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