/// <summary>
        /// Function converts an instance to and xml string
        /// </summary>
        /// <returns>The xml string representing the instance</returns>
        public override string ToXml()
        {
            XmlDocument doc  = DamlContainer.BuildDamlDocumentTemplate(false);
            XmlNode     root = doc.DocumentElement;

            // Create the document root
            XmlNode damlClassNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
            // Create an attribute to hold the name of the damlClass
            XmlAttribute damlClassAtt = doc.CreateAttribute(DamlConstants.RDF_ID, DamlConstants.RDF_NS_URI);

            // Set attribute value
            damlClassAtt.Value = this.m_strName;
            // Append attribute to damlClass node
            damlClassNode.Attributes.Append(damlClassAtt);

            // Create rdfsSubClassOf node
            XmlNode damlTypeNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDFS_SUBCLASSOF, DamlConstants.RDFS_NS_URI);
            // Create attribute to set the value
            XmlAttribute damlTypeNodeAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);

            // Set the value
            damlTypeNodeAtt.Value = this.Value;
            // Append attribute to node
            damlTypeNode.Attributes.Append(damlTypeNodeAtt);

            damlClassNode.AppendChild(damlTypeNode);
            root.AppendChild(damlClassNode);
            // Return xml document
            return(doc.OuterXml);
        }
        /// <summary>
        /// Function converts an instance to and xml string
        /// </summary>
        /// <returns>The xml string representing the instance</returns>
        public override string ToXml()
        {
            XmlDocument doc  = DamlContainer.BuildDamlDocumentTemplate(false);
            XmlNode     root = doc.DocumentElement;

            // Create the document root
            XmlNode damlClassNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
            // Create an attribute to hold the name of the damlClass
            XmlAttribute damlClassAtt = doc.CreateAttribute(DamlConstants.RDF_ID, DamlConstants.RDF_NS_URI);

            // Set attribute value
            damlClassAtt.Value = this.m_strName;
            // Append attribute to damlClass node
            damlClassNode.Attributes.Append(damlClassAtt);

            // Create daml:UnionOf node
            XmlNode damlTypeNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_UNION_OF, DamlConstants.DAML_NS_URI);
            // Create attribute to set the parseType
            XmlAttribute damlTypeNodeAtt = doc.CreateAttribute(DamlConstants.RDF_PARSE_TYPE, DamlConstants.RDF_NS_URI);

            // Set attribute value
            switch (this.m_parseType)
            {
            case enuRdfParseType.damlCollection:
                damlTypeNodeAtt.Value = DamlConstants.DAML_COLLECTION;
                break;

            default: throw new Exception("Unknown rdfParseType");
            }
            // Append attribute to node
            damlTypeNode.Attributes.Append(damlTypeNodeAtt);

            // Scroll thru the options creating a daml:Class rdf:about node
            // adding each one to the damlTypeNode
            IDictionaryEnumerator it = this.m_options.GetEnumerator();

            while (it.MoveNext())
            {
                // Create node
                XmlNode rdfAboutNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
                // Create attribute
                XmlAttribute rdfAboutAtt = doc.CreateAttribute(DamlConstants.RDF_ABOUT, DamlConstants.RDF_NS_URI);
                // Set attribute value
                rdfAboutAtt.Value = (string)it.Key;
                // Add attribute to node
                rdfAboutNode.Attributes.Append(rdfAboutAtt);

                // Add node to the damlTypeNode
                damlTypeNode.AppendChild(rdfAboutNode);
            }

            damlClassNode.AppendChild(damlTypeNode);
            root.AppendChild(damlClassNode);
            // Return xml string
            return(doc.OuterXml);
        }
        /// <summary>
        /// Function builds a basic Daml Document Template
        /// </summary>
        /// <param name="bAddOntologyImports">Indicates whether to include the ontology imports</param>
        /// <returns>The basoc Daml Document Template</returns>
        public static XmlDocument BuildDamlDocumentTemplate(bool bAddOntologyImports)
        {
            // Build the basic root tag
            string strDamlDocRoot = DamlContainer.BuildDamlDocRoot();

            // Create an XmlDocument and set the Document Element
            XmlDocument doc = new XmlDocument();

            // Load Xml into XmlDocument
            doc.LoadXml(strDamlDocRoot);
            // Get Document Element, this is our document root node
            XmlNode root = doc.DocumentElement;

            // If asked to add ontology imports...
            if (bAddOntologyImports)
            {
                // Create a new node for the ontologies
                XmlNode ontologyNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_ONTOLOGY, DamlConstants.DAML_NS_URI);

                // Add attribute to Ontology node
                XmlAttribute ontologyAttribute = doc.CreateAttribute(DamlConstants.RDF_ABOUT, DamlConstants.RDF_NS_URI);
                // Add ontology attribute
                ontologyNode.Attributes.Append(ontologyAttribute);

                // Add daml imports to ontology node

                // Import daml+oil
                XmlNode      damlImport    = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_IMPORTS, DamlConstants.DAML_NS_URI);
                XmlAttribute damlImportAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                damlImportAtt.Value = DamlConstants.DAML_NS_URI;
                damlImport.Attributes.Append(damlImportAtt);

                // Import time
                XmlNode      timeImport    = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_IMPORTS, DamlConstants.DAML_NS_URI);
                XmlAttribute timeImportAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                timeImportAtt.Value = DamlConstants.TIME_NS_URI;
                timeImport.Attributes.Append(timeImportAtt);

                // Import Service
                XmlNode      serviceImport    = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_IMPORTS, DamlConstants.DAML_NS_URI);
                XmlAttribute serviceImportAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                serviceImportAtt.Value = DamlConstants.SERVICE_NS_URI;
                serviceImport.Attributes.Append(serviceImportAtt);

                // Import Process
                XmlNode      processImport    = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_IMPORTS, DamlConstants.DAML_NS_URI);
                XmlAttribute processImportAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                processImportAtt.Value = DamlConstants.PROCESS_NS_URI;
                processImport.Attributes.Append(processImportAtt);

                // Add Imports to ontology node
                ontologyNode.AppendChild(damlImport);
                ontologyNode.AppendChild(timeImport);
                ontologyNode.AppendChild(serviceImport);
                ontologyNode.AppendChild(processImport);

                // Add the ontology node to our document
                root.AppendChild(ontologyNode);
            }

            // Return the basic daml document template creates
            return(doc);
        }
        public string ToXml(bool bAddTypeDefintions)
        {
            XmlDocument doc  = DamlContainer.BuildDamlDocumentTemplate(true);
            XmlNode     root = doc.DocumentElement;

            // Add DAML Process body

            // Add this process' details name etc., if this process is complex
            // there is additional data we must add

            // Given a document (by ref) and an array of RDF properties
            // we repeat the same basic steps

            // Add Inputs (if any)
            if (this.m_arrInputs.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrInputs.ToArray(typeof(RdfProperty)), enuIOPEType.Input);
            }

            // Add Outputs (if any)
            if (this.m_arrOutputs.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrOutputs.ToArray(typeof(RdfProperty)), enuIOPEType.Output);
            }

            // Add Preconditions (if any)
            if (this.m_arrPreconditions.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrPreconditions.ToArray(typeof(RdfProperty)), enuIOPEType.Precondition);
            }

            // Add Effects (if any)
            if (this.m_arrEffects.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrEffects.ToArray(typeof(RdfProperty)), enuIOPEType.Effect);
            }

            // Add CoConditions (if any)
            if (this.m_arrCoConditions.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrCoConditions.ToArray(typeof(RdfProperty)), enuIOPEType.CoCondition);
            }

            // Add ConditionalOutputs (if any)
            if (this.m_arrConditionalOutputs.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrConditionalOutputs.ToArray(typeof(RdfProperty)), enuIOPEType.ConditionalOutput);
            }

            // Add CoOutputs (if any)
            if (this.m_arrCoOutputs.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrCoOutputs.ToArray(typeof(RdfProperty)), enuIOPEType.CoOutput);
            }

            // Add Parameters (if any)
            if (this.m_arrParameters.Count > 0)
            {
                AddRdfProperties(ref doc, (RdfProperty[])this.m_arrParameters.ToArray(typeof(RdfProperty)), enuIOPEType.Parameter);
            }

            // Create process node
            XmlNode processNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
            // Create process attribute
            XmlAttribute processAtt = doc.CreateAttribute(DamlConstants.RDF_ID, DamlConstants.RDF_NS_URI);

            // Set attribute value (process name)
            processAtt.Value = this.m_strName;
            // Add attribute to node
            processNode.Attributes.Append(processAtt);

            // Specify what type of process this is - this will be a child of processNode
            // Create process type node (rdfs:subClassOf)
            XmlNode processTypeNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDFS_SUBCLASSOF, DamlConstants.RDFS_NS_URI);
            // Create process type node attribute
            XmlAttribute processTypeAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);

            // Set the type of process
            switch (this.ProcessType)
            {
            case enuProcessType.AtomicProcess:
                processTypeAtt.Value = DamlConstants.ATOMIC_PROCESS_URI; break;

            case enuProcessType.SimpleProcess:
                processTypeAtt.Value = DamlConstants.SIMPLE_PROCESS_URI; break;

            case enuProcessType.CompositeProcess:
                processTypeAtt.Value = DamlConstants.COMPOSITE_PROCESS_URI; break;

            default: throw new ArgumentException("Unknown process type");
            }
            // Add attribute to process type node
            processTypeNode.Attributes.Append(processTypeAtt);

            // Add the processType node as a child of the process node
            processNode.AppendChild(processTypeNode);

            // Add restrictions to process node if any

            DamlRestriction[] arrRestrictions = this.GetRestrictions(enuIOPEType.Input);

            for (int j = 0; j < arrRestrictions.Length; j++)
            {
                if (arrRestrictions[j].Owner == this.Name)
                {
                    // Create subClassOf node
                    XmlNode subClassOfNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDFS_SUBCLASSOF, DamlConstants.RDFS_NS_URI);
                    // Create a node for each restriction (child of subClassOfNode)
                    XmlNode restrictionNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_RESTRICTION, DamlConstants.DAML_NS_URI);
                    // Fill in restrictionNode data

                    // Add cardinality attribute if value has been set
                    if (arrRestrictions[j].Cardinality != DamlRestriction.NO_CARDINALITY)
                    {
                        // Create attribute
                        XmlAttribute cardinalityAtt = doc.CreateAttribute(DamlConstants.DAML_CARDINALITY, DamlConstants.DAML_NS_URI);
                        // Set attribute value
                        cardinalityAtt.Value = arrRestrictions[j].Cardinality.ToString();
                        // Add attribute to node
                        restrictionNode.Attributes.Append(cardinalityAtt);
                    }

                    // Create onPropertyNode
                    XmlNode onPropertyNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_ON_PROPERTY, DamlConstants.DAML_NS_URI);
                    // Create onProperty attribute
                    XmlAttribute onPropertyAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                    // Set attribute value
                    onPropertyAtt.Value = arrRestrictions[j].OnProperty;
                    // Add attribute to node
                    onPropertyNode.Attributes.Append(onPropertyAtt);

                    // Add onPropertyNode to restrictionNode
                    restrictionNode.AppendChild(onPropertyNode);

                    // If this instance is a composite process add extra nodes
                    // to the (composedOf) restriction node
                    if (this.ProcessType == enuProcessType.CompositeProcess && arrRestrictions[j].OnProperty == DamlConstants.PROCESS_COMPOSED_OF_URI)
                    {
                        XmlNode toClassNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_TO_CLASS, DamlConstants.DAML_NS_URI);
                        XmlNode classNode   = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
                        // Create intersection of node
                        XmlNode intersectionOfNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_INTERSECTION_OF, DamlConstants.DAML_NS_URI);
                        // Create intersectionOf node attribute
                        XmlAttribute intersectionOfAtt = doc.CreateAttribute(DamlConstants.RDF_PARSE_TYPE, DamlConstants.RDF_NS_URI);
                        // Set attribute value
                        intersectionOfAtt.Value = DamlConstants.DAML_COLLECTION;
                        // Add attribute to intersecionOfNode
                        intersectionOfNode.Attributes.Append(intersectionOfAtt);

                        // Add a Daml class node and another restriction node
                        // to the intersectionOfNode
                        // Create a node to store the type of sub task "list" we have
                        // one of enuProcessSubTaskType
                        XmlNode subTaskTypeNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
                        // Create an attribute for the subTaskType node
                        XmlAttribute subTaskTypeAtt = doc.CreateAttribute(DamlConstants.RDF_ABOUT, DamlConstants.RDF_NS_URI);

                        // Set the atribute value
                        switch (this.SubTaskType)
                        {
                        case enuProcessSubTaskType.Choice:
                            subTaskTypeAtt.Value = DamlConstants.PROCESS_CHOICE; break;

                        case enuProcessSubTaskType.Sequence:
                            subTaskTypeAtt.Value = DamlConstants.PROCESS_SEQUENCE; break;

                        default: throw new Exception("Unknown process sub-task type");
                        }

                        // Add subTaskTypeAtt attribute to subTaskType node
                        subTaskTypeNode.Attributes.Append(subTaskTypeAtt);

                        // Add a restriction to the intersectionOf node
                        // this is where we list the names of the subprocesses
                        XmlNode subProcessRestrictionNode           = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_RESTRICTION, DamlConstants.DAML_NS_URI);
                        XmlNode subProcessRestrictionOnPropertyNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_ON_PROPERTY, DamlConstants.DAML_NS_URI);
                        // Add attribute
                        XmlAttribute subProcessRestrictionOnPropertyAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                        // Set attribute value
                        subProcessRestrictionOnPropertyAtt.Value = DamlConstants.PROCESS_COMPONENTS_URI;
                        // Add attribute to node
                        subProcessRestrictionOnPropertyNode.Attributes.Append(subProcessRestrictionOnPropertyAtt);

                        // last daml:toClass/daml:Class construct added to the subProcessRestrictionNode
                        XmlNode processListToClassNode     = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_TO_CLASS, DamlConstants.DAML_NS_URI);
                        XmlNode processListClassNode       = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
                        XmlNode processListOfInstancesNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_LIST_OF_INSTANCES_OF, DamlConstants.DAML_NS_URI);
                        // Add attribute
                        XmlAttribute processListOfInstancesAtt = doc.CreateAttribute(DamlConstants.RDF_PARSE_TYPE, DamlConstants.RDF_NS_URI);
                        // Set attribute value
                        processListOfInstancesAtt.Value = DamlConstants.DAML_COLLECTION;
                        // Add attribute to node
                        processListOfInstancesNode.Attributes.Append(processListOfInstancesAtt);

                        for (int i = 0; i < this.m_arrSubProcesses.Count; i++)
                        {
                            // Create process name node
                            XmlNode processNameNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_CLASS, DamlConstants.DAML_NS_URI);
                            // Create process name attribute
                            XmlAttribute processNameAtt = doc.CreateAttribute(DamlConstants.RDF_ABOUT, DamlConstants.RDF_NS_URI);
                            // Set processNameAtt value
                            processNameAtt.Value = "#" + ((DamlProcess)this.m_arrSubProcesses[i]).Name;
                            // Add attribute to node
                            processNameNode.Attributes.Append(processNameAtt);
                            // Add to list of instances node
                            processListOfInstancesNode.AppendChild(processNameNode);
                        }

                        processListClassNode.AppendChild(processListOfInstancesNode);
                        processListToClassNode.AppendChild(processListClassNode);
                        subProcessRestrictionNode.AppendChild(subProcessRestrictionOnPropertyNode);
                        subProcessRestrictionNode.AppendChild(processListToClassNode);
                        intersectionOfNode.AppendChild(subTaskTypeNode);
                        intersectionOfNode.AppendChild(subProcessRestrictionNode);
                        classNode.AppendChild(intersectionOfNode);
                        toClassNode.AppendChild(classNode);
                        restrictionNode.AppendChild(toClassNode);
                    }

                    // Add restrictionNode to subClassOfNode
                    subClassOfNode.AppendChild(restrictionNode);
                    //Add subClassOfNode to root
                    processNode.AppendChild(subClassOfNode);
                }
            }

            // Add process node to root
            root.AppendChild(processNode);

            if (bAddTypeDefintions)
            {
                // Add data type definitions
                IDictionaryEnumerator it = this.m_dataTypeDefinitionMap.GetEnumerator();

                while (it.MoveNext())
                {
                    // Ask each type definition to ToXml() itself
                    // this gives us the nodes to add to our document
                    DamlTypeDefinition definition = (DamlTypeDefinition)it.Value;
                    XmlDocument        typeDoc    = new XmlDocument();
                    // Load the xml of the type definition
                    typeDoc.LoadXml(definition.ToXml());
                    // Get the document element
                    XmlNode typeDocRoot = typeDoc.DocumentElement;
                    // Import the first child of the root into the damlProcess xml document
                    // being created
                    XmlNode temp = doc.ImportNode(typeDocRoot.FirstChild, true);
                    // Append that node to our current document root
                    root.AppendChild(temp);
                }
            }

            return(root.OuterXml);
        }
        public string ToXml()
        {
            // Get a document template
            XmlDocument doc = DamlContainer.BuildDamlDocumentTemplate(true);

            // Get the document element (document root)
            XmlNode root = doc.DocumentElement;

            // DamlProcessWriter may have to control the datatypes
            // being written out by each DamlProcess, multiple processes in
            // a proces model may share data types, we only need one
            // data type definition

            IDictionaryEnumerator it = this.m_processMap.GetEnumerator();

            while (it.MoveNext())
            {
                DamlProcess proc = (DamlProcess)it.Value;

                XmlDocument processDoc = new XmlDocument();
                // DO NOT add type defintions to xml document we create
                // the ProcessModel should keep track of all the data types
                // in each process to ensure each type definition gets written
                // only once since multiple process in a process model may share
                // data types an as such could cause duplicate definitions
                // to be written out in the process model xml document
                processDoc.LoadXml(proc.ToXml(false));

                XmlNode processDocRoot = processDoc.DocumentElement;

                XmlNodeList lstChildren = processDocRoot.ChildNodes;

                foreach (XmlNode child in lstChildren)
                {
                    // Add every child to our document root except the ontology imports
                    // since we already have these from the DamlDocumentTemplate
                    if (child.Name != DamlConstants.DAML_ONTOLOGY)
                    {
                        XmlNode temp = doc.ImportNode(child, true);
                        root.AppendChild(temp);
                    }
                }

                // Get the data types we have not seen as yet
                DamlTypeDefinition[] arrDefinitions = proc.TypeDefinitions;
                for (int i = 0; i < arrDefinitions.Length; i++)
                {
                    if (!this.m_dataTypeDefinitionMap.ContainsKey(arrDefinitions[i].Name))
                    {
                        this.m_dataTypeDefinitionMap.Add(arrDefinitions[i].Name, arrDefinitions[i]);
                    }
                }
            }

            // Write data type map last
            IDictionaryEnumerator typeIt = this.m_dataTypeDefinitionMap.GetEnumerator();

            while (typeIt.MoveNext())
            {
                DamlTypeDefinition definition = (DamlTypeDefinition)typeIt.Value;
                XmlDocument        typeDoc    = new XmlDocument();
                // Load the xml of the type definition
                typeDoc.LoadXml(definition.ToXml());
                // Get the document element
                XmlNode typeDocRoot = typeDoc.DocumentElement;
                // Import the first child of the root into the damlProcess xml document
                // being created
                XmlNode temp = doc.ImportNode(typeDocRoot.FirstChild, true);
                // Append that node to our current document root
                root.AppendChild(temp);
            }

            return(doc.OuterXml);
        }
Пример #6
0
        /// <summary>
        /// Function converts an instance to and xml string
        /// </summary>
        /// <returns>The xml string representing the instance</returns>
        public override string ToXml()
        {
            XmlDocument doc  = DamlContainer.BuildDamlDocumentTemplate(false);
            XmlNode     root = doc.DocumentElement;

            // Create rdfPropertyNode
            XmlNode rdfPropertyNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDF_PROPERTY, DamlConstants.RDF_NS_URI);
            // Create attribute
            XmlAttribute rdfPropertyAtt = doc.CreateAttribute(DamlConstants.RDF_ID, DamlConstants.RDF_NS_URI);

            // Set attribute value
            rdfPropertyAtt.Value = this.m_strName;
            // Add attribute to node
            rdfPropertyNode.Attributes.Append(rdfPropertyAtt);

            // Create node for subPropertyOf (only if it has been set)
            if (this.m_strSubPropertyOf.Length > 0)
            {
                XmlNode subPropertyOfNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDFS_SUBPROPERTYOF, DamlConstants.RDFS_NS_URI);
                // Create attribute
                XmlAttribute subPropertyOfAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                // Set attribute value
                subPropertyOfAtt.Value = this.m_strSubPropertyOf;
                // Add attribute to node
                subPropertyOfNode.Attributes.Append(subPropertyOfAtt);

                rdfPropertyNode.AppendChild(subPropertyOfNode);
            }

            // Create node for domain
            XmlNode domainNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDFS_DOMAIN, DamlConstants.RDFS_NS_URI);
            // Create attribute
            XmlAttribute domainAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);

            // Set attribute value
            domainAtt.Value = this.m_strDomain.StartsWith("#") ? this.m_strDomain : "#" + this.m_strDomain;
            // Add attribute to node
            domainNode.Attributes.Append(domainAtt);

            rdfPropertyNode.AppendChild(domainNode);

            // Create node for range
            XmlNode rangeNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.RDFS_RANGE, DamlConstants.RDFS_NS_URI);
            // Create attribute
            XmlAttribute rangeAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);

            // Set attribute value
            rangeAtt.Value = this.m_strRange;
            // Add attribute to node
            rangeNode.Attributes.Append(rangeAtt);

            rdfPropertyNode.AppendChild(rangeNode);

            // Create node for sameValueAs (only if it has been set)
            if (this.m_strSameValueAs.Length > 0)
            {
                XmlNode sameValueAsNode = doc.CreateNode(XmlNodeType.Element, DamlConstants.DAML_SAMEVALUESAS, DamlConstants.DAML_NS_URI);
                // Create attribute
                XmlAttribute sameValueAsAtt = doc.CreateAttribute(DamlConstants.RDF_RESOURCE, DamlConstants.RDF_NS_URI);
                // Set attribute value
                sameValueAsAtt.Value = this.m_strSameValueAs;
                // Add attribute to node
                sameValueAsNode.Attributes.Append(sameValueAsAtt);

                rdfPropertyNode.AppendChild(sameValueAsNode);
            }

            root.AppendChild(rdfPropertyNode);
            // Return xml string
            return(doc.OuterXml);
        }