OPCFoundation / UA-ModelCompiler

ModelCompiler converts XML files into C# and ANSI C
MIT License
151 stars 94 forks source link

Trouble compiling multiple XML model files #175

Closed ancapaul closed 6 months ago

ancapaul commented 6 months ago

Hello,

I am trying to compile multiple models but running into an error. The below two files are just a sample to reproduce the problem.

The following model is contained in a file called MachineFramework.xml

<?xml version="1.0" encoding="utf-8" ?>
<opc:ModelDesign
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:opc="http://opcfoundation.org/UA/ModelDesign.xsd"
  xmlns:ua="http://opcfoundation.org/UA/"
  xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
    xmlns="http://www.anca.com/UA/MachineFramework/"
  TargetXmlNamespace="http://www.anca.com/UA/MachineFramework/"
  TargetNamespace="http://www.anca.com/UA/MachineFramework/">
  <opc:Namespaces>
    <opc:Namespace Name="OpcUa" Prefix="Opc.Ua" XmlNamespace="http://opcfoundation.org/UA/2008/02/Types.xsd">http://opcfoundation.org/UA/</opc:Namespace>
    <opc:Namespace Name="MachineFramework" Prefix="MachineFramework" InternalPrefix="MachineFramework">http://www.anca.com/UA/MachineFramework/</opc:Namespace>
  </opc:Namespaces>

  <opc:ObjectType SymbolicName="IClient" BaseType="ua:BaseInterfaceType">
  </opc:ObjectType>
</opc:ModelDesign>

The following model is contained in a file called Fridge.xml uses types defined in the above model.

<?xml version="1.0" encoding="utf-8" ?>
<opc:ModelDesign
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:opc="http://opcfoundation.org/UA/ModelDesign.xsd"
    xmlns:ua="http://opcfoundation.org/UA/"
    xmlns:mf="http://www.anca.com/UA/MachineFramework/"
    xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
    xmlns="http://www.anca.com/UA/MachineFramework/Fridge/"
    TargetNamespace="http://www.anca.com/UA/MachineFramework/Fridge/">
    <opc:Namespaces>
        <opc:Namespace Name="OpcUa" Prefix="Opc.Ua" XmlNamespace="http://opcfoundation.org/UA/2008/02/Types.xsd">http://opcfoundation.org/UA/</opc:Namespace>
        <opc:Namespace Name="Fridge" Prefix="MachineFramework.Fridge" InternalPrefix="MachineFramework.Fridge">http://www.anca.com/UA/MachineFramework/Fridge/</opc:Namespace>
        <opc:Namespace Name="MachineFramework" Prefix="MachineFramework" InternalPrefix="MachineFramework" FilePath="MachineFramework.xml">http://www.anca.com/UA/MachineFramework/</opc:Namespace>
    </opc:Namespaces>
    <opc:ObjectType SymbolicName="ISubClient" BaseType="mf:IClient">
    </opc:ObjectType>
</opc:ModelDesign>

I am compiling the two XML files using the following commands:

Opc.Ua.ModelCompiler.exe compile -d2 .\MachineFramework.xml -cg MachineFrameworkIdentfiers.csv -version v105 -o2 .\ Opc.Ua.ModelCompiler.exe compile -d2 .\Fridge.xml -cg FridgeIdentfiers.csv -version v105 -o2 .\

From everything I have read the above should work but I am getting the following error: [InvalidOperationException] The BaseType reference for node ISubClient is not valid: IClient.

Any ideas on what I am doing wrong? Any help will be greatly appreciated.

opcfoundation-org commented 6 months ago

Add dependencies on the command line like this:

compile
-d2
.\MachineFramework.xml 
-d2
.\Fridge.xml 
-version
v105
-c"
MachineFrameworkIdentfiers.csv 
-o2
 .\
ancapaul commented 6 months ago

Thank you that solved the problem.