05/06/2020
Hi,
is this still relevant https://opcfoundation.org/foru.....eset2-xml/ , given the ModelCompiler now supports NodeSet2.xml natively as input?
I am confronted with the situation that there is a third-party NodeSet2.xml that I'd like to use and extend.
I also was thinking that it would be required to reverse compile the given NodeSet2.xml, edit the resulting ModelDesign.xml and recompile as a whole.
On the other hand, it seems pretty normal to reference a in a ModelDesign.xml external NodeSet2.xml types. But just beginning, I could net get it to work yet at all. Tried to call ModelCompiler with -d2 ModelDesign.xml -d2 GivenNodeSet2.xml with the ModelDesign having an object with TypeDefinition equal to some Type in GivenNodeSet2.xml but it gives an error ( "The TypeDefinition reference for node Cat2 is not valid: CatType." Am am experimenting with the animals example for now.)
Best
05/30/2017
The model compiler allows you to mix dependencies.
i.e. a ModelDesign can import types from a NodeSet2 and vise versa.
Opc.Ua.ModelCompiler compile -d2 .\Opc.Ua.Machinery.NodeSet2.xml,Opc.Ua.Machinery,Machinery -d2 Opc.Ua.Di.NodeSet2.xml,Opc.Ua.DI,DI -version v105 -exclude Draft -o2 .\output
Where the target is always the first one.
If a reference is not found check your namespace prefixes.
05/06/2020
Hi Randy,
thanks for your reply.
I tried to follow your advice and understand the namespace handling better.
In order to do so, I created a very simplistic Model Design and compiled it successfully:
<ModelDesign
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://simple.com/simple2/"
TargetNamespace="https://simple.com/simple2/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd">https://simple.com/simple2/
https://opcfoundation.org/UA/Base type for all Simplers
Name of the Simple
It compiles by:
Opc.Ua.ModelCompiler.exe compile -d2 .\simple.xml -cg .\simple_gen.csv -o2 ./simple
Then I tried to "include" the resulting simpler.NodeSet2.xml into another Model user.xml (omitted for now, as it seems to not yet matter)
compile -d2 .\user.xml -d2 .\simple\simpler.NodeSet2.xml,Simple -cg .\user_gen.csv -o2 ./user
This results in:
[ArgumentOutOfRangeException] startIndex cannot be larger than length of string. (Parameter 'startIndex')
========================
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex)
at ModelCompiler.NodeSetToModelDesign.CreateNamespace(ModelTableEntry model) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\NodeSetToModelDesign.cs:line 181
at ModelCompiler.NodeSetToModelDesign.LoadNamespaces(String filePath) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\NodeSetToModelDesign.cs:line 227
at ModelCompiler.ModelCompilerValidator.GetNamespaceList(IList`1 designFilePaths) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\ModelDesignerValidator.cs:line 1226
at ModelCompiler.ModelCompilerValidator.ValidateModel(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\ModelDesignerValidator.cs:line 1307
at ModelCompiler.ModelCompilerValidator.Validate(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\ModelDesignerValidator.cs:line 1024
at ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList`1 designFilePaths, String identifierFilePath, UInt32 startId, String specificationVersion, Boolean useAllowSubtypes, IList`1 exclusions, String modelVersion, String modelPublicationDate, Boolean releaseCandidate, Boolean extractIdentifiers) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\ModelGenerator2.cs:line 125
at ModelCompiler.ModelCompilerApplication.<>c__DisplayClass13_0.b__0() in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\ModelCompilerApplication.cs:line 480
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at ModelCompiler.ModelCompilerApplication.Run(String[] args) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\ModelCompilerApplication.cs:line 31
at Program.
$(String[] args) in C:\Repositories\UA-ModelCompiler-master\UA-ModelCompiler-master\Opc.Ua.ModelCompiler\Program.cs:line 27
========================
I thought maybe I could narrow down by simply recompiling the .\simple\simpler.NodeSet2.xml
compile -d2 .\simple\simpler.NodeSet2.xml -cg .\user_gen.csv -o2 ./user
And I get the same error which for me means, I put in a valid ModelDesign simple.xml, but the output of ModelCompiler is not accepted as input itself (I noted from call trace, ModelCompiler internally used the NodeSetToModelDesign functionality as discussed initially).
[Just for completeness, the user.xml but it seems not yet being processed:
<ModelDesign
xmlns:uax="https://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://simple.com/simpler2/"
xmlns:user="https://simple.com/user/"
TargetNamespace="https://simple.com/user/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd">
https://simple.com/user/
https://simple.com/simple2/
https://opcfoundation.org/UA/
A simple object
Simplistic
]
05/06/2020
On editing my previous post, the forum software seems to have malformed the xml (if it gets interpreted internally unintentionally, this could be exploited, be aware forum admins).
So again the two files:
simple.xml
<?xml version="1.0" encoding="utf-8"?>
<ModelDesign
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://simple.com/simple2/"
TargetNamespace="https://simple.com/simple2/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd"><Namespaces>
<Namespace Name="Simple" Prefix="simpler" XmlNamespace="https://opcua.rocks/UA/simple2/Types.xsd" XmlPrefix="simple">https://simple.com/simple2/<.....ce>
<Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z" Prefix="Opc.Ua" InternalPrefix="Opc.Ua.Server" XmlNamespace="https://opcfoundation.org/UA/2008/02/Types.xsd" XmlPrefix="OpcUa">https://opcfoundation.org/UA/&l.....ce>
</Namespaces><ObjectType SymbolicName="simple:SimpleType" BaseType="ua:BaseObjectType" IsAbstract="true" SupportsEvents="true">
<Description>Base type for all Simplers</Description>
<Children>
<Property SymbolicName="simple:Name" DataType="ua:String" ValueRank="Scalar" ModellingRule="Mandatory">
<Description>Name of the Simple</Description>
</Property>
</Children>
</ObjectType></ModelDesign>
user.xml
<?xml version="1.0" encoding="utf-8"?>
<ModelDesign
xmlns:uax="https://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://simple.com/simpler2/"
xmlns:user="https://simple.com/user/"
TargetNamespace="https://simple.com/user/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd"><Namespaces>
<Namespace Prefix="user">https://simple.com/user/</N.....ce>
<Namespace>https://simple.com/simple2/<.....ce>
<Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z" Prefix="Opc.Ua" InternalPrefix="Opc.Ua.Server" XmlNamespace="https://opcfoundation.org/UA/2008/02/Types.xsd" XmlPrefix="OpcUa">https://opcfoundation.org/UA/&l.....ce>
</Namespaces><Object SymbolicName="user:Insta" TypeDefinition="simple:SimpleType">
<Description>A simple object</Description>
<Children>
<Property SymbolicName="user:Name" DataType="ua:String" AccessLevel="Read">
<DefaultValue>
<uax:String>Simplistic</uax:String>
</DefaultValue>
</Property>
</Children>
</Object></ModelDesign>
05/06/2020
Hm, again alternated by forum at namespace closure. maybe without the quote function...? :
<?xml version="1.0" encoding="utf-8"?>
<ModelDesign
xmlns:uax="https://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://simple.com/simpler2/"
xmlns:user="https://simple.com/user/"
TargetNamespace="https://simple.com/user/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd">
<Namespaces>
<Namespace Prefix="user">https://simple.com/user/</N.....ce>
<Namespace>https://simple.com/simple2/<.....ce>
<Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z" Prefix="Opc.Ua" InternalPrefix="Opc.Ua.Server" XmlNamespace="https://opcfoundation.org/UA/2008/02/Types.xsd" XmlPrefix="OpcUa">https://opcfoundation.org/UA/&l.....ce>
</Namespaces>
<Object SymbolicName="user:Insta" TypeDefinition="simple:SimpleType">
<Description>A simple object</Description>
<Children>
<Property SymbolicName="user:Name" DataType="ua:String" AccessLevel="Read">
<DefaultValue>
<uax:String>Simplistic</uax:String>
</DefaultValue>
</Property>
</Children>
</Object>
</ModelDesign>
05/30/2017
Do you have access to the member only repo?
05/30/2017
Bug fixes are first pushed to the member-only repo. There are some bugs which have already been fixed there.
Try using a NamespaceUri that starts with https://opcfoundation.org/UA/
A fix for this bug is in progress.
05/06/2020
Ok, with opcfoundation.org it proceeds and the reflexive compile works.
But now I am back at my initial state with the invalid reference:
Opc.Ua.ModelCompiler.exe compile -d2 .\user.xml -d2 .\simple\simpler.NodeSet2.xml -cg .\user_gen.csv -o2 ./user
[InvalidOperationException] The TypeDefinition reference for node Insta is not valid: SimpleType.
user.xml:
<?xml version="1.0" encoding="utf-8"?>
<ModelDesign
xmlns:uax="https://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://opcfoundation.org/UA/simpler2/"
xmlns:user="https://opcfoundation.org/UA/user/"
TargetNamespace="https://opcfoundation.org/UA/user/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd">
<Namespaces>
<Namespace Prefix="user">https://opcfoundation.org/UA/user/</Namespace>
<Namespace>https://opcfoundation.org/UA/simple2/</Namespace>
<Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z" Prefix="Opc.Ua" InternalPrefix="Opc.Ua.Server" XmlNamespace="https://opcfoundation.org/UA/2008/02/Types.xsd" XmlPrefix="OpcUa">https://opcfoundation.org/UA/</Namespace>
</Namespaces>
<Object SymbolicName="user:Insta" TypeDefinition="simple:SimpleType">
<Description>A simple object</Description>
<Children>
<Property SymbolicName="user:Name" DataType="ua:String" AccessLevel="Read">
<DefaultValue>
<uax:String>Simplistic</uax:String>
</DefaultValue>
</Property>
</Children>
</Object>
</ModelDesign>
simple.xml:
<?xml version="1.0" encoding="utf-8"?>
<ModelDesign
xmlns:ua="https://opcfoundation.org/UA/"
xmlns:simple="https://opcfoundation.org/UA/simple2/"
TargetNamespace="https://opcfoundation.org/UA/simple2/"
xmlns="https://opcfoundation.org/UA/ModelDesign.xsd">
<Namespaces>
<Namespace Name="Simple" Prefix="simpler" XmlNamespace="https://opcua.rocks/UA/simple2/Types.xsd" XmlPrefix="simple">https://opcfoundation.org/UA/simple2/</Namespace>
<Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z" Prefix="Opc.Ua" InternalPrefix="Opc.Ua.Server" XmlNamespace="https://opcfoundation.org/UA/2008/02/Types.xsd" XmlPrefix="OpcUa">https://opcfoundation.org/UA/</Namespace>
</Namespaces>
<ObjectType SymbolicName="simple:SimpleType" BaseType="ua:BaseObjectType" IsAbstract="true" SupportsEvents="true">
<Description>Base type for all Simplers</Description>
<Children>
<Property SymbolicName="simple:Name" DataType="ua:String" ValueRank="Scalar" ModellingRule="Mandatory">
<Description>Name of the Simple</Description>
</Property>
</Children>
</ObjectType>
</ModelDesign>
05/06/2020
It works now! Thanks Randy.
I intentionally alternated the namespaces everywhere to be able to trace its handling. It's a bit unobvious in the beginning what needs to match what.
For this specific case, however, it was a clear mistake on my side during this process.
And yet, there is xmlns for namespace URI and Types.xsd URI, Attributes: TargetNamespace, Name, Prefix, InternalPrefix, XmlNamespace, XmlPrefix; Actual URI value.
Not all seem really mattering / purpose mostly unclear for me at least 🙂
But anyhow, with this simple setup working, I can proceed
Best
1 Guest(s)