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


Java XmlCursor.toChild方法代码示例

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


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

示例1: AttributeTypeImpl

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public AttributeTypeImpl(AttributeType attributeType) {
    this.attributeType = attributeType;
    final XmlCursor xmlCursor = attributeType.newCursor();
    sampleAttributeElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
    xmlCursor.push();
    xmlCursor.toChild("TAG");
    tagElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
    xmlCursor.pop();
    xmlCursor.push();
    xmlCursor.toChild("VALUE");
    valueElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
    xmlCursor.pop();
    if (xmlCursor.toChild("UNITS")) {
        unitsElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
    }
    xmlCursor.dispose();
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:18,代码来源:AttributeTypeImpl.java

示例2: encodeStatisticCollection

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private StatisticsCollectionDocument encodeStatisticCollection(StatisticCollection element) throws UnsupportedUncertaintyTypeException {
    StatisticsCollectionDocument xb_scDoc = StatisticsCollectionDocument.Factory.newInstance();
    StatisticsCollectionType xb_scType = xb_scDoc.addNewStatisticsCollection();
    XmlCursor cursor = null;
    for (int i = 0; i < element.size(); i++) {
        IStatistic s = element.get(i);

        AbstractSummaryStatisticType xb_cmType = xb_scType.addNewAbstractSummaryStatistic();
        AbstractSummaryStatisticDocument result = encodeStatistic(s);
        cursor = xb_scType.newCursor();
        xb_cmType.set(result.getAbstractSummaryStatistic());

        //renaming of element and removal of xsi:type attribute
        String elementName = result.getClass().getSimpleName().replace("DocumentImpl", "");
        cursor.toChild(new QName(NAMESPACE, "AbstractSummaryStatistic"));
        cursor.setName(new QName(NAMESPACE, elementName));
        cursor.removeAttribute(new QName("http://www.w3.org/2001/XMLSchema-instance", "type"));
    }

    return xb_scDoc;
}
 
开发者ID:52North,项目名称:uncertml-api,代码行数:22,代码来源:XMLEncoder.java

示例3: getAtomParameters

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/** 
 * Retrieves all of the parameters of an atom in order (including skolems and vars)
 * 
 * @author mdangelo
 * 
 * @param m			The mapping to get the atomParameters of
 * @param foreach	A boolean to determine whether to check the for each or exist clauses for the atom
 * @param atomPos	The position of the atom within the mapping
 * 
 * @return			An array of objects
 */
public Object[] getAtomParameters (MappingType m, boolean foreach, int atomPos) 
{
	MapExprType clause = foreach ? m.getForeach() : m.getExists();
	RelAtomType atom = clause.getAtomArray(atomPos);
	XmlCursor c = atom.newCursor();
	
	int size = atom.sizeOfSKFunctionArray() + atom.sizeOfVarArray();
	Object[] result = new Object[size];
	int varPos = 0;
	
	for(int i = 0; i < size; i++) 
	{
		if(i == 0)
			c.toChild(i);
		else
			c.toNextSibling();
		
		XmlObject x = c.getObject();
		
		if (x instanceof SKFunction)
			result[i] = x;
		else
			result[i] = atom.getVarArray(varPos++);
	}

	return result;
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:39,代码来源:TrampXMLModel.java

示例4: getSkolemFromAtom

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public SKFunction getSkolemFromAtom (MappingType m, boolean foreach, 
		int atomPos, int argPos) throws Exception {
	MapExprType clause = foreach ? m.getForeach() : m.getExists();
	RelAtomType atom = clause.getAtomArray(atomPos);
	XmlCursor c = atom.newCursor();
	c.toChild(argPos);
	XmlObject o = (XmlObject) c.getObject();
	if (!(o instanceof SKFunction))
		throw new Exception ("Expected an SK function: " + o.toString());
	return (SKFunction) o; 
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:12,代码来源:PartialMapping.java

示例5: argsToString

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void argsToString(XmlCursor c, StringBuilder b, int numElements)
		throws Exception {
	b.append("(");

	c.toChild(0);
	for(int i = 0; i < numElements; i++) {
		XmlObject o = (XmlObject) c.getObject();
		b.append(atomArgToString(o) + ", ");
		c.toNextSibling();
	}
	
	b.delete(b.length() - 2, b.length());
	b.append(")");
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:15,代码来源:XSMLWriter.java

示例6: assertEquals

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Uses cursors to compare two XML documents, ignoring whitespace and
 * ordering of attributes.  Fails the JUnit test if they're different.
 *
 * @param message to display on test failure (may be null)
 * @param expected
 * @param actual
 */
public static void assertEquals(String message, XmlCursor expected, XmlCursor actual)
{
  for (int child = 0; true; child++)
  {
    boolean child1 = expected.toChild(child);
    boolean child2 = actual.toChild(child);
    if (child1 != child2)
    {
      fail(message, "Different XML structure near " + QNameHelper.pretty(expected.getName()));
    }
    else if (expected.getName() != null && !expected.getName().equals(actual.getName()))
    {
      fail(message, "Expected element: '" + expected.getName()
        + "' differs from actual element: '" + actual.getName() + "'");
    }
    else if (child == 0 && !child1)
    {
      if (!(expected.getTextValue().equals(actual.getTextValue())))
      {
        fail(message, "Expected value for element " + QNameHelper.pretty(expected.getName()) + " -> '"
          + expected.getTextValue() + "' differs from actual value '" + actual.getTextValue() + "'");
      }
      break;
    }
    else if (child1)
    {
      assertEquals(message, expected, actual);
      expected.toParent();
      actual.toParent();
    }
    else
    {
      break;
    }
  }

  assertAttributesEqual(message, expected, actual);
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:47,代码来源:XmlBeanAssert.java

示例7: encodeMixtureModel

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private MixtureModelDocument encodeMixtureModel(MixtureModel element) throws UnsupportedUncertaintyTypeException {
    MixtureModelDocument xb_mmDoc = MixtureModelDocument.Factory.newInstance();
    MixtureModelType xb_mmType = xb_mmDoc.addNewMixtureModel();
    XmlCursor cursor = null;
    for (WeightedDistribution w : element) {
        if (w.getDistribution() instanceof HypergeometricDistribution) {
            System.out.println();
        }
        Component c = xb_mmType.addNewComponent();
        c.setWeight(w.getWeight());
        AbstractDistributionType adt = c.addNewAbstractDistribution();
        AbstractDistributionDocument result = encodeDistribution(w.getDistribution());

        cursor = c.newCursor();
        adt.set(result.getAbstractDistribution());

        //renaming of element and removal of xsi:type attribute
        String elementName = result.getClass().getSimpleName().replace("DocumentImpl", "");
        cursor.toChild(new QName(NAMESPACE, "AbstractDistribution"));
        cursor.setName(new QName(NAMESPACE, elementName));
        cursor.removeAttribute(new QName("http://www.w3.org/2001/XMLSchema-instance", "type"));

    }

    return xb_mmDoc;

}
 
开发者ID:52North,项目名称:uncertml-api,代码行数:28,代码来源:XMLEncoder.java

示例8: validateSoapMessage

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Validate a soap message accordingly to its WSDL and linked XSD resources. The validation is
 * done for a specified message part (maybe be the input, output or fault of an operation).
 * @param partName The name of the part to validate ie. name of the input, output or fault part (ex: sayHello)
 * @param partNamespace The namespace of the part to validate (ex: http://www.mma.fr/test/service)
 * @param message The full soap message as a string
 * @param wsdlUrl The URL where we can resolve service and operation WSDL
 * @param validateMessageBody Should we validate also the body ? If false, only Soap envelope is validated.
 * @return The list of validation failures. If empty, message is valid !
 * @throws org.apache.xmlbeans.XmlException if given message is not a valid Xml document
 */
public static List<XmlError> validateSoapMessage(String partName, String partNamespace, String message, String wsdlUrl, boolean validateMessageBody) 
      throws XmlException {
   //
   WsdlContext ctx = new WsdlContext(wsdlUrl);
   List<XmlError> errors = new ArrayList<XmlError>();
   ctx.getSoapVersion().validateSoapEnvelope(message, errors);
   
   log.debug("SoapEnvelope validation errors: " + errors.size());

   if (validateMessageBody){
      // Create XmlBeans object for the soap message.
      XmlOptions xmlOptions = new XmlOptions();
      xmlOptions.setLoadLineNumbers();
      xmlOptions.setLoadLineNumbers( XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT );
      XmlObject xml = XmlUtils.createXmlObject(message, xmlOptions);

      // Build the QName string of the part name. Ex: {http://www.github.com/lbroudoux/service}sayHello
      String fullPartName = "{" + partNamespace + "}" + partName;
      
      // Extract the corresponding part from soap body.
      XmlObject[] paths = xml.selectPath( "declare namespace env='" + ctx.getSoapVersion().getEnvelopeNamespace() + "';" 
            + "declare namespace ns='" + partNamespace + "';" + "$this/env:Envelope/env:Body/ns:" + partName);
         
      SchemaGlobalElement elm;
      try {
         elm = ctx.getSchemaTypeLoader().findElement(QName.valueOf(fullPartName));
      } catch (Exception e) {
         log.error("Exception while loading schema information for " + fullPartName, e);
         throw new XmlException("Exception while loading schema information for " + fullPartName, e);
      }
      
      if ( elm != null ){
         validateMessageBody(ctx, errors, elm.getType(), paths[0]);
   
         // Ensure no other elements in body.
         NodeList children = XmlUtils.getChildElements((Element) paths[0].getDomNode().getParentNode());
         for (int c = 0; c < children.getLength(); c++){
            QName childName = XmlUtils.getQName(children.item(c));
            // Compare child QName to full part QName.
            if (!fullPartName.equals(childName.toString())){
               XmlCursor cur = paths[0].newCursor();
               cur.toParent();
               cur.toChild( childName );
               errors.add( XmlError.forCursor( "Invalid element [" + childName + "] in SOAP Body", cur ) );
               cur.dispose();
            }
         }
      }
      log.debug("SoapBody validation errors: " + errors.size());
   } 
   return errors;
}
 
开发者ID:microcks,项目名称:microcks,代码行数:64,代码来源:SoapMessageValidator.java


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