Hi all,


I used scomp to generate a parser for an XML file which root element is expected to be "WorkflowManagerInstanceDescriptor". The input file for scomp is the attached "WorkflowManager.xsd" file. I created an XML file (UnsecureWorkflow1.xml) and validated it against the schema using both Eclipse and Oxygen. For that reason, I believe the XML file is valid. However, when parsing it using the generated XMLBeans parser, I can't retrieve the information. Executing the attached java class gives an error message that claims the XML file isn't valid. So, have scomp not generated the parser appropriately or is one of my files invalid?




error: cvc-complex-type.2.4a: Expected element '[EMAIL PROTECTED]://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService' instead of '[EMAIL PROTECTED]://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService' here error: cvc-complex-type.2.4c: Expected element '[EMAIL PROTECTED]://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService' before the end of the content








<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService";
	xmlns:helper="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService"; xmlns:tns="http://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService";
	xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing";
	xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
	attributeFormDefault="unqualified">
	<xs:import namespace="http://schemas.xmlsoap.org/ws/2004/03/addressing"; schemaLocation="./WS-Addressing.xsd"></xs:import>
	<xs:import namespace="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService"; schemaLocation="./WorkflowHelper.xsd"></xs:import>
	
	
	
	<xs:element name="RootElement" type="tns:RootElement"></xs:element>
	<xs:complexType name="RootElement">
		<xs:sequence>
			<xs:element name="workflowManagerInstanceDescriptor" type="tns:WorkflowManagerInstanceDescriptor"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	
	<!-- Workflow metadata -->
	<xs:element name="WorkflowManagerInstanceDescriptor" type="tns:WorkflowManagerInstanceDescriptor" />
	<xs:complexType name="WorkflowManagerInstanceDescriptor">
		<xs:sequence>
			<xs:element name="localWorkflows" type="tns:WorkflowPortionsDescriptor"></xs:element>
			<xs:element name="inputs" type="tns:WorkflowInputParameters" />
			<xs:element name="outputDesc" type="tns:WorkflowOutputTransportDescriptor" />
		</xs:sequence>
	</xs:complexType>
	
	
	<xs:element name="WorkflowStageDescriptor" type="tns:WorkflowStageDescriptor"/>
	<xs:complexType name="WorkflowStageDescriptor">
		<xs:sequence>
			<xs:element name="basicDescription" type="helper:WorkflowInvocationHelperDescriptor"/>
			<xs:element name="inputsDescription" type="helper:OperationInputMessageDescriptor"/>
			<xs:element name="outputTransportDescriptor" type="helper:OperationOutputTransportDescriptor"/>
			<xs:element name="GlobalUniqueIdentifier" type="int" />
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="WorkflowPortionsDescriptor" type="tns:WorkflowPortionsDescriptor" />
	<xs:complexType name="WorkflowPortionsDescriptor">
		<xs:sequence>
			<xs:element name="localWorkflowDesc" type="tns:WorkflowPortionDescriptor" minOccurs="1" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="WorkflowPortionDescriptor" type="tns:WorkflowPortionDescriptor" />
	<xs:complexType name="WorkflowPortionDescriptor">
		<xs:sequence>
			<xs:element name="WorkflowHelperServiceLocation" type="string" />
			<xs:element name="instanceHelperDesc" type="helper:WorkflowInstanceHelperDescriptor"></xs:element>
			<xs:element name="invocationHelperDescs" type="tns:WorkflowStageDescriptor" minOccurs="1" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	
	
	<!-- Inputs of a workflow -->
	<xs:element name="WorkflowInputParameters" type="tns:WorkflowInputParameters"></xs:element>
	<xs:complexType name="WorkflowInputParameters">
		<xs:sequence>
			<xs:element name="parameter" type="tns:WorkflowInputParameter" minOccurs="0" maxOccurs="unbounded"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	
	
	<xs:element name="WorkflowInputParameter" type="tns:WorkflowInputParameter"></xs:element>
	<xs:complexType name="WorkflowInputParameter">
		<xs:sequence>
			<xs:element name="paramDescription" type="helper:InputParameter"></xs:element>
			<xs:element name="paramDestinationGUID" type="int"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	
	<!-- Transportation of the outputs of a workflow -->
	<xs:element name="WorkflowOutputTransportDescriptor" type="tns:WorkflowOutputTransportDescriptor" />
	<xs:complexType name="WorkflowOutputTransportDescriptor">
		<xs:sequence>
			<xs:element name="paramDescriptor" type="tns:WorkflowOutputParameterTransportDescriptor" minOccurs="0"
				maxOccurs="unbounded"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="WorkflowOutputParameterTransportDescriptor" type="tns:WorkflowOutputParameterTransportDescriptor" />
	<xs:complexType name="WorkflowOutputParameterTransportDescriptor">
		<xs:sequence>
			<xs:element name="paramDescription" type="helper:OperationOutputParameterTransportDescriptor"></xs:element>
			<xs:element name="sourceGUID" type="int"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
</xs:schema>
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";
	xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"; xmlns:tns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";
	xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
	attributeFormDefault="unqualified">
	<xs:import namespace="http://schemas.xmlsoap.org/ws/2004/03/addressing"; schemaLocation="./WS-Addressing.xsd"></xs:import>
	<xs:element name="WorkflowHelperInstanceStatus" type="tns:WorkflowHelperInstanceStatus" />
	
	<xs:complexType name="WorkflowHelperInstanceStatus">
		<xs:sequence>
			<xs:element name="Status" type="tns:Status"></xs:element>
			<xs:element name="message" type="string"></xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="Status" type="tns:Status" />
	<xs:simpleType name="Status">
		<xs:restriction base="xs:string">
			<xs:enumeration value="UNCONFIGURED" />
			<xs:enumeration value="INPUTCONFIGURED" />
			<xs:enumeration value="INPUTOUTPUTCONFIGURED" />
			<xs:enumeration value="WAITING" />
			<xs:enumeration value="RUNNING" />
			<xs:enumeration value="FINISHED" />
			<xs:enumeration value="PAUSED" />
			<xs:enumeration value="READY" />
			<xs:enumeration value="ERROR" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:element name="TimestampedStatus" type="tns:TimestampedStatus"/>
		
	<xs:complexType name="TimestampedStatus">
		<xs:sequence>
			<xs:element name="status" type="tns:Status" />
			<xs:element name="timestamp" type="int" />
		</xs:sequence>
	</xs:complexType>
	
	
	
	<xs:element name="WorkflowInstanceHelperDescriptor" type="tns:WorkflowInstanceHelperDescriptor" />
	<xs:complexType name="WorkflowInstanceHelperDescriptor">
		<xs:sequence>
			<xs:element name="WorkflowManagerEPR" type="wsa:EndpointReferenceType" minOccurs="0" maxOccurs="1"></xs:element>
			<xs:element name="WorkflowID" type="string" minOccurs="0" maxOccurs="1"></xs:element>
			<xs:element name="ProxyEPR" type="wsa:EndpointReferenceType" minOccurs="0" maxOccurs="unbounded"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	
	
	
	<xs:element name="WorkflowInvocationHelperDescriptor" type="tns:WorkflowInvocationHelperDescriptor" />
	<xs:complexType name="WorkflowInvocationHelperDescriptor">
		<xs:sequence>
			<xs:element name="WorkflowManagerEPR" type="wsa:EndpointReferenceType"></xs:element>
			<xs:element name="WorkflowID" type="string"></xs:element>
			<xs:element name="ServiceURL" type="string"></xs:element>
			<xs:element name="operationQName" type="QName"></xs:element>
			<xs:element name="outputType" type="QName" minOccurs="0" maxOccurs="1"></xs:element><!-- Knowing the output type (if any) allows us to do streaming bewteen stages -->
			<xs:element name="WorkflowInvocationSecurityDescriptor" type="tns:WorkflowInvocationSecurityDescriptor" minOccurs="0" maxOccurs="1"></xs:element>			
		</xs:sequence>
	</xs:complexType>
	
	
	<!-- BEGIN security settings structures  -->
	<xs:element name="TLSInvocationSecurityDescriptor" type="tns:TLSInvocationSecurityDescriptor" />
	
	<xs:complexType name="TLSInvocationSecurityDescriptor">
		<!--xs:complexContent>
			<xs:extension base="tns:WorkflowInvocationSecurityDescriptor"-->
				<xs:sequence>
					<xs:element name="ChannelProtection" type="tns:ChannelProtection" minOccurs="1" maxOccurs="1"></xs:element>
					<xs:choice minOccurs="1" maxOccurs="1">
						<xs:element name="AnonymousAuthenticationMethod" type="tns:AnonymousAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>
						<xs:element name="ServiceAuthenticationMethod" type="tns:ServiceAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>
						<xs:element name="CDSAuthenticationMethod" type="tns:CDSAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>						
					</xs:choice>		
				</xs:sequence>
			<!--/xs:extension>
		</xs:complexContent-->
	</xs:complexType>
	
	<xs:element name="SecureConversationInvocationSecurityDescriptor" type="tns:SecureConversationInvocationSecurityDescriptor" />
	
	<xs:complexType name="SecureConversationInvocationSecurityDescriptor">
		<!--xs:complexContent>
			<xs:extension base="tns:WorkflowInvocationSecurityDescriptor"-->
				<xs:sequence>
					<xs:element name="ChannelProtection" type="tns:ChannelProtection" minOccurs="1" maxOccurs="1"></xs:element>
					<xs:choice minOccurs="1" maxOccurs="1">
						<xs:element name="NativeDelegationAuthenticationMethod" type="tns:NativeDelegationAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>
						<xs:element name="AnonymousAuthenticationMethod" type="tns:AnonymousAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>
						<xs:element name="ServiceAuthenticationMethod" type="tns:ServiceAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>
						<xs:element name="CDSAuthenticationMethod" type="tns:CDSAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>						
					</xs:choice>		
				</xs:sequence>
			<!--/xs:extension>
		</xs:complexContent-->
	</xs:complexType>
	
	<xs:element name="SecureMessageInvocationSecurityDescriptor" type="tns:SecureMessageInvocationSecurityDescriptor" />
	
	<xs:complexType name="SecureMessageInvocationSecurityDescriptor">
		<!--xs:complexContent>
			<xs:extension base="tns:WorkflowInvocationSecurityDescriptor"-->
				<xs:sequence>
					<xs:element name="ChannelProtection" type="tns:ChannelProtection" minOccurs="1" maxOccurs="1"></xs:element>
					<xs:choice minOccurs="1" maxOccurs="1">
						<xs:element name="ServiceAuthenticationMethod" type="tns:ServiceAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>
						<xs:element name="CDSAuthenticationMethod" type="tns:CDSAuthenticationMethod" minOccurs="1" maxOccurs="1"></xs:element>						
					</xs:choice>		
				</xs:sequence>
			<!--/xs:extension>
		</xs:complexContent-->
	</xs:complexType>
	
	<xs:complexType name="NativeDelegationAuthenticationMethod"/>
	<xs:complexType name="AnonymousAuthenticationMethod"/>
	<xs:complexType name="ServiceAuthenticationMethod"/>
	<xs:complexType name="CDSAuthenticationMethod">
		<xs:sequence>
			<xs:element name="ProxyEPR" type="wsa:EndpointReferenceType" minOccurs="0" maxOccurs="1"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="WorkflowInvocationSecurityDescriptor" type="tns:WorkflowInvocationSecurityDescriptor" />
	<xs:complexType name="WorkflowInvocationSecurityDescriptor" > <!-- abstract="true" /-->
		<xs:sequence>
			<xs:choice>
				<xs:element name="TLSInvocationSecurityDescriptor" type="tns:TLSInvocationSecurityDescriptor"/>
				<xs:element name="SecureConversationInvocationSecurityDescriptor" type="tns:SecureConversationInvocationSecurityDescriptor"/>
				<xs:element name="SecureMessageInvocationSecurityDescriptor" type="tns:SecureMessageInvocationSecurityDescriptor"/>
			</xs:choice>		
		</xs:sequence>	
	</xs:complexType>
	
	
	<xs:simpleType name="ChannelProtection">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Privacy" />
			<xs:enumeration value="Integrity" />
		</xs:restriction>
	</xs:simpleType>
	<!-- END security settings structures  -->
	
	
	<xs:element name="InputParameter" type="tns:InputParameter" />
	<xs:complexType name="InputParameter">
		<xs:sequence>
			<xs:element name="paramIndex" type="int"></xs:element>
			<xs:element name="data" type="string"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="OperationInputMessageDescriptor" type="tns:OperationInputMessageDescriptor" />
	<xs:complexType name="OperationInputMessageDescriptor">
		<xs:sequence>
			<xs:element name="inputParam" type="tns:InputParameterDescriptor" minOccurs="0" maxOccurs="unbounded"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="InputParameterDescriptor" type="tns:InputParameterDescriptor"/>
	<xs:complexType name="InputParameterDescriptor">
		<xs:sequence>
			<xs:element name="paramQName" type="QName"></xs:element>
			<xs:element name="paramType"  type="QName"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	
	<xs:element name="OperationOutputTransportDescriptor" type="tns:OperationOutputTransportDescriptor" />
	<xs:complexType name="OperationOutputTransportDescriptor">
		<xs:sequence>
			<xs:element name="paramDescriptor" type="tns:OperationOutputParameterTransportDescriptor" minOccurs="0"
				maxOccurs="unbounded"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="OperationOutputParameterTransportDescriptor" type="tns:OperationOutputParameterTransportDescriptor" />
	<xs:complexType name="OperationOutputParameterTransportDescriptor">
		<xs:sequence>
			<xs:element name="destinationGlobalUniqueIdentifier" type="int" />
			<xs:element name="destinationEPR" type="wsa:EndpointReferenceType" minOccurs="1" maxOccurs="unbounded"></xs:element>
			<xs:element name="deliveryPolicy" type="tns:DeliveryPolicy" ></xs:element>
			<xs:element name="paramIndex" type="int"></xs:element>
			<xs:element name="type" type="QName"></xs:element>
			<xs:element name="locationQuery" type="string"></xs:element>
			<xs:element name="queryNamespaces" type="QName" minOccurs="0" maxOccurs="unbounded"></xs:element>
		</xs:sequence>
	</xs:complexType>
	
		<xs:element name="DeliveryPolicy" type="tns:DeliveryPolicy" />
	<xs:simpleType name="DeliveryPolicy">
		<xs:restriction base="xs:string">
			<xs:enumeration value="BROADCAST" />
			<xs:enumeration value="ROUNDROBIN" />
			<xs:enumeration value="DEMANDDRIVEN" />
		</xs:restriction>
	</xs:simpleType>
	
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<WorkflowManagerInstanceDescriptor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService ../../../../../incubator/projects/workflowManager/schema/WorkflowManagerService/WorkflowManager.xsd"
 xmlns:svc4="http://service4.introduce.cagrid.org/Service4";
 xmlns="http://workflowmanagerservice.workflow.cagrid.org/WorkflowManagerService";>
	<localWorkflows>
		<localWorkflowDesc>
			<WorkflowHelperServiceLocation>http://localhost:8080/wsrf/services/cagrid/WorkflowHelper</WorkflowHelperServiceLocation>
			<instanceHelperDesc>
				<WorkflowID
					xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>Workflow1</WorkflowID>
			</instanceHelperDesc>
			<invocationHelperDescs>
				<basicDescription>
					<WorkflowManagerEPR
						xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>
						<Address
							xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing";>http://localhost:8080/WorkflowManagerService</Address>
					</WorkflowManagerEPR>
					<WorkflowID
						xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>
					</WorkflowID>
					<ServiceURL
						xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>http://localhost:8080/wsrf/services/cagrid/Service4</ServiceURL>
					<operationQName
						xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>svc4:PrintResultsRequest</operationQName>
				</basicDescription>
				<inputsDescription>
					<inputParam
						xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>
						<paramQName>result1</paramQName>
						<paramType>string</paramType>
					</inputParam>
					<inputParam
						xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>
						<paramQName>result2</paramQName>
						<paramType>string</paramType>
					</inputParam>
				</inputsDescription>
				<outputTransportDescriptor />
				<GlobalUniqueIdentifier>0</GlobalUniqueIdentifier>
			</invocationHelperDescs>
		</localWorkflowDesc>
	</localWorkflows>
	<inputs>
		<parameter>
			<paramDescription>
				<paramIndex
					xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>0</paramIndex>
				<data
					xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>String1</data>
			</paramDescription>
			<paramDestinationGUID>0</paramDestinationGUID>
		</parameter>
		<parameter>
			<paramDescription>
				<paramIndex
					xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>1</paramIndex>
				<data
					xmlns="http://workflowhelperservice.workflow.cagrid.org/WorkflowHelperService";>String2</data>
			</paramDescription>
			<paramDestinationGUID>0</paramDestinationGUID>
		</parameter>
	</inputs>
	<outputDesc />
</WorkflowManagerInstanceDescriptor>

package org.cagrid.workflow.manager.service.parser.workflowDescriptor;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.cagrid.workflow.manager.descriptor.WorkflowManagerInstanceDescriptor;

public class WorkflowDescriptorParser {


	private static Log logger = LogFactory.getLog(WorkflowDescriptorParser.class);


	/**
	 * Parse an XML description of a workflow into the WorkflowManagerInstance descriptor
	 * @throws Exception 
	 * */
	public static org.cagrid.workflow.manager.descriptor.WorkflowManagerInstanceDescriptor parseWorkflowDescriptor(
			String xmlWorkflowDescription) throws Exception {


		// Use parser generated by XMLBeans to parse the descriptor
		StringReader stringReader = new StringReader(xmlWorkflowDescription);
		org.cagrid.workflow.workflowmanagerservice.workflowManagerService.WorkflowManagerInstanceDescriptor managerInstanceDescriptor = null;
		try {
			Collection errors = new ArrayList();
			XmlOptions options = new XmlOptions();
			options.setErrorListener(errors);
			managerInstanceDescriptor = 
				org.cagrid.workflow.workflowmanagerservice.workflowManagerService.WorkflowManagerInstanceDescriptor.Factory.parse(stringReader);
			
			// Validate the file just read
			boolean isValidDescriptor = managerInstanceDescriptor.validate(options);
			
			if( !isValidDescriptor ){
				
				// Print errors
				Iterator errors_iter = errors.iterator();
				StringBuffer errorsbuf = new StringBuffer();
				while( errors_iter.hasNext() ){
					
					String curr_error = errors_iter.next().toString();
					errorsbuf.append("\n"+curr_error);
				}
				throw new Exception("File descriptor is not valid"+ errorsbuf.toString());
			}
			
		} catch (XmlException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} 


		// Convert the retrieved descriptor into the type generated by Introduce
//		org.cagrid.workflow.manager.descriptor.WorkflowManagerInstanceDescriptor convertedDescriptor = convertFromXMLBeans(managerInstanceDescriptor);

		return null;  //convertedDescriptor;
	}


	public static void main(String args[]){


		File testFile = new File(args[0]);
		int numBytes = (int) testFile.length();

		char[] fileBytes = null;
		try {
			FileReader testFileReader = new FileReader(testFile);
			fileBytes = new char[numBytes];
			testFileReader.read(fileBytes);
		} catch (IOException e) {
			e.printStackTrace();
		}


		String xmlWorkflowDescription = new String(fileBytes);
		WorkflowManagerInstanceDescriptor wfDesc = null;
		try {
			wfDesc = parseWorkflowDescriptor(xmlWorkflowDescription);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return;
	}

}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to