Package org.xmlpull.infoset

Examples of org.xmlpull.infoset.XmlElement


                    String warning = "The XML for the default value is not valid.";
                    this.engine.getErrorWindow().error(warning, e);
                }
            }
        }
        XmlElement metadata;
        if (metadataText.length() == 0) {
            metadata = null;
        } else {
            try {
                metadata = XMLUtil.stringToXmlElement(metadataText);
View Full Code Here


        try {
            // This code doesn't work when the output is a complex type.
            // Object output = this.outputMessage.getObjectPart(name);
            // return output;

            XmlElement outputElement = (XmlElement) element;
            Iterator valueElementItr = outputElement.elements(null, name).iterator();
            LinkedList<String> ret = new LinkedList<String>();
            while(valueElementItr.hasNext()){
              XmlElement valueElement = (XmlElement) valueElementItr.next();
              Iterator childIt = valueElement.children().iterator();
               int numberOfChildren = 0;
                 while (childIt.hasNext()) {
                     childIt.next();
                     numberOfChildren++;
                 }
                 if (numberOfChildren == 1) {
                     Object child = valueElement.children().iterator().next();
                     if (child instanceof String) {
                         // Value is a simple type. Return the string.
                         String value = (String) child;
                         ret.add(value);
                     }
View Full Code Here

    graphElement.setAttributeValue(GraphSchema.NS,
        GraphSchema.GRAPH_TYPE_ATTRIBUTE, GraphSchema.GRAPH_TYPE_WS);

    if (this.metadata != null) {
      XmlElement metadataElement = graphElement.addElement(
          GraphSchema.NS, GraphSchema.GRAPH_METADATA_TAG);
      // Clone the metadata to avoid parent problem because this can be
      // called multiple times.
      metadataElement.addChild(XMLUtil.deepClone(this.metadata));
    }

    if (this.inputMetadata != null) {
      XmlElement metadataElement = graphElement.addElement(
          GraphSchema.NS, GraphSchema.GRAPH_INPUT_METADATA_TAG);
      // Clone the metadata to avoid parent problem because this can be
      // called multiple times.
      metadataElement.addChild(XMLUtil.deepClone(this.inputMetadata));
    }

    if (this.outputMetadata != null) {
      XmlElement metadataElement = graphElement.addElement(
          GraphSchema.NS, GraphSchema.GRAPH_OUTPUT_METADATA_TAG);
      // Clone the metadata to avoid parent problem because this can be
      // called multiple times.
      metadataElement.addChild(XMLUtil.deepClone(this.outputMetadata));
    }
  }
View Full Code Here

   */
  @Override
  protected void parse(XmlElement graphElement) throws GraphException {
    super.parse(graphElement);

    XmlElement metadataElement = graphElement
        .element(GraphSchema.GRAPH_METADATA_TAG);
    if (metadataElement != null) {
      for (XmlElement appinfo : metadataElement.requiredElementContent()) {
        this.metadata = appinfo;
        // It should have only one element.
        break;
      }
    }

    XmlElement inputMetadataElement = graphElement
        .element(GraphSchema.GRAPH_INPUT_METADATA_TAG);
    if (inputMetadataElement != null) {
      for (XmlElement appinfo : inputMetadataElement
          .requiredElementContent()) {
        this.inputMetadata = appinfo;
        // It should have only one element.
        break;
      }
    }

    XmlElement outputMetadataElement = graphElement
        .element(GraphSchema.GRAPH_OUTPUT_METADATA_TAG);
    if (outputMetadataElement != null) {
      for (XmlElement appinfo : outputMetadataElement
          .requiredElementContent()) {
        this.outputMetadata = appinfo;
        // It should have only one element.
        break;
      }
View Full Code Here

//  public void setClassName(String className) {
//    this.getComponent().setClassName(className);
//  }

  public XmlElement toXML() {
    XmlElement nodeElement = XMLUtil.BUILDER.newFragment(GraphSchema.NS,
        GraphSchema.NODE_TAG);

    nodeElement.setAttributeValue(GraphSchema.NODE_TYPE_ATTRIBUTE,
        GraphSchema.NODE_TYPE_CEP);
    XmlElement idElement = nodeElement.addElement(GraphSchema.NS,
        GraphSchema.NODE_ID_TAG);
    idElement.addChild(getID());

    XmlElement nameElement = nodeElement.addElement(GraphSchema.NS,
        GraphSchema.NODE_NAME_TAG);
    nameElement.addChild(getName());

    List<DataPort> outputPorts = getOutputPorts();
    // Output ports
    for (PortImpl port : outputPorts) {
      XmlElement portElement = nodeElement.addElement(GraphSchema.NS,
          GraphSchema.NODE_OUTPUT_PORT_TAG);
      portElement.addChild(port.getID());
    }

    List<DataPort> inputPorts = getInputPorts();
    // Input ports
    for (PortImpl port : inputPorts) {
      XmlElement portElement = nodeElement.addElement(GraphSchema.NS,
          GraphSchema.NODE_INPUT_PORT_TAG);
      portElement.addChild(port.getID());
    }

    // Control-in port
    if (getControlInPort() != null) {
      XmlElement portElement = nodeElement.addElement(GraphSchema.NS,
          GraphSchema.NODE_CONTROL_IN_PORT_TAG);
      portElement.addChild(getControlInPort().getID());
    }

    List<ControlPort> controlOutPorts = getControlOutPorts();
    // Control-out ports
    for (PortImpl port : controlOutPorts) {
      XmlElement portElement = nodeElement.addElement(GraphSchema.NS,
          GraphSchema.NODE_CONTROL_OUT_PORT_TAG);
      portElement.addChild(port.getID());
    }

    XmlElement xElement = nodeElement.addElement(GraphSchema.NS,
        GraphSchema.NODE_X_LOCATION_TAG);
    xElement.addChild(Integer.toString(getPosition().x));

    XmlElement yElement = nodeElement.addElement(GraphSchema.NS,
        GraphSchema.NODE_Y_LOCATION_TAG);
    yElement.addChild(Integer.toString(getPosition().y));

    addConfigurationElement(nodeElement);

    return nodeElement;
  }
View Full Code Here

      String valueString;
      if (value == null) {
        valueString = "";
      } else {
        if (value instanceof XmlElement) {
          XmlElement valueElement = (XmlElement) value;
          valueString = XMLUtil.xmlElementToString(valueElement);
        } else {
          // Only string comes here for now.
          valueString = value.toString();
        }
View Full Code Here

    /**
     * @see edu.indiana.extreme.xbaya.graph.impl.PortImpl#toXML()
     */
    @Override
    protected XmlElement toXML() {
        XmlElement portElement = super.toXML();
        portElement.setAttributeValue(GraphSchema.NS,
                GraphSchema.PORT_TYPE_ATTRIBUTE, GraphSchema.PORT_TYPE_CONTROL);
        return portElement;
    }
View Full Code Here

        }

        // annotation
        this.annotation = element.element(null, WSConstants.ANNOTATION_TAG);
        if (this.annotation != null) {
            XmlElement documentationElement = this.annotation.element(null,
                    WSConstants.DOCUMENTATION_TAG);
            if (documentationElement != null) {
                // Sets the documentation.
                this.description = documentationElement.requiredText();
            }
            this.appinfo = this.annotation.element(null,
                    WSConstants.APPINFO_TAG);
        }

        // defaut value
        this.defaultValue = element
                .attributeValue(WSConstants.DEFAULT_ATTRIBUTE);
        if (this.defaultValue == null && this.annotation != null) {
            XmlElement defaultElement = this.annotation.element(null, DEFAULT);
            if (defaultElement != null) {
                for (Object child : defaultElement.children()) {
                    if (child instanceof XmlElement) {
                        this.defaultValue = XMLUtil
                                .xmlElementToString((XmlElement) child);
                    }
                }
View Full Code Here

    }

    private void parseType(String typeName, List<WSComponentPort> parts)
            throws ComponentException {

        XmlElement typesElement = this.wsdl.getTypes();
        if (typesElement == null) {
            throw new ComponentException("No types is defined.");
        }
       
        if (typesElement.element(null, WSConstants.SCHEMA_TAG) == null) {
            throw new ComponentException("No schema is defined.");
        }
       
        XmlElement elementElement = null;
        XmlElement schemaElement = null;
       
        Iterable<XmlElement> schemaElements = typesElement.elements(null, WSConstants.SCHEMA_TAG);
        for (XmlElement elemt : schemaElements) {
          schemaElement = elemt;
          elementElement = findElementElement(typeName, elemt);
          if (null != elementElement){
            break;
          }
    }
       
       
        if (elementElement == null) {
            throw new ComponentException("No element is defined for "
                    + typeName);
        }
        String typesTargetNamespace = schemaElement
                .attributeValue(WSConstants.TARGET_NAMESPACE_ATTRIBUTE);
        String elementType = elementElement
                .attributeValue(WSConstants.TYPE_ATTRIBUTE);

        XmlElement sequenceElement;
        if (elementType == null) {
            // anonymous type
            XmlElement complexElement = elementElement.element(null,
                    WSConstants.COMPLEX_TYPE_TAG);
            if (complexElement == null) {
                throw new ComponentException(
                        "We only support complexType as annonymous type: "
                                + XMLUtil.xmlElementToString(elementElement));
            }
            sequenceElement = complexElement.element(null,
                    WSConstants.SEQUENCE_TAG);
            // TODO Check if there is any other defined.
        } else {
            // named complexType
            String elementTypeName = XMLUtil.getLocalPartOfQName(elementType);
            XmlElement typeElement = findTypeElement(elementTypeName,
                    schemaElement);
            sequenceElement = typeElement.element(null,
                    WSConstants.SEQUENCE_TAG);
            // TODO Check if there is any other defined.
        }

        if (sequenceElement == null) {
            // Assume that there is no input/output.
            logger.info("There is no sequence defined.");
        } else {
            // Only supports elements in the sequence now.
            for (XmlElement element : sequenceElement.elements(null,
                    WSConstants.ELEMENT_TAG)) {
                WSComponentPort componentPort = new WSComponentPort(element,
                        typesTargetNamespace, this);
                // Check if the type is defined in types
                QName paramType = componentPort.getType();
                if (!(WSConstants.XSD_NS_URI.equalsIgnoreCase(paramType
                        .getNamespaceURI()))) {
                    XmlElement typeDefinition = WSDLUtil.getTypeDefinition(
                            this.wsdl, paramType);
                    if (typeDefinition == null) {
                        throw new ComponentException(
                                "could not find definition for type "
                                        + paramType + " in " + this.wsdlQName);
View Full Code Here

        // Load a workflow template from the GPEL Engine.
        Workflow workflow = client.load(templateID);

        // Get the metadata for input.
        XmlElement inputAppinfo = workflow.getInputMetadata();
        logger
                .info("inputAppinfo: "
                        + XMLUtil.xmlElementToString(inputAppinfo));

        // Get the input information
        List<WSComponentPort> inputs = workflow.getInputs();

        for (WSComponentPort input : inputs) {
            // Show the information of each input.

            // Name
            String name = input.getName();
            logger.info("name: " + name);

            // Type
            QName type = input.getType();
            logger.info("type: " + type);

            // Metadata as XML
            XmlElement appinfo = input.getAppinfo();
            logger.info("appinfo: " + XMLUtil.xmlElementToString(appinfo));
            if (appinfo != null) {
                // Parse the simple case.
                for (XmlElement element : appinfo.requiredElementContent()) {
                    String tag = element.getName();
                    String value = element.requiredText();
                    logger.info(tag + " = " + value);
                }
            }
View Full Code Here

TOP

Related Classes of org.xmlpull.infoset.XmlElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.