Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: nshala on May 04, 2015, 09:34:57 pm
-
Hi,
is it possible to write a batch job that generates XSDs from one package? Can I write a script that executes the menu item action: Package->XML Technologies->Generate XSD
Best regards
Nol
-
Yes that is possible.
You can use the operation Project Interface.GenerateXSD
The only difficulty is to run it as a batch. In order to use the API you have to have a user logged in on the machine that will execute batch process.
There are a couple of discussions here and on StackOverflow on the subject.
Geert
-
Hi,
I wrote a small .NET C# console application including Interop.EA to generate XSDs. But the Schema-Location is not being exported even though it is properly in XSD contained. If I generate XSD in EA manually it works fine.
Any suggestion?
Best regards
Nol
-
Without insight into the code this is like poking around in London mist.
q.
-
Hi,
here is a sample .NET C# Method for generating XSDs from EA-Packages.
void SmallDemo()
{
Repository repository = new Repository();
repository.OpenFile(@"D:\Temp\test.eap");
var testDic = new Dictionary<string, string>();
foreach (Package package in repository.Models)
{
foreach (Package testPackage in package.Packages)
{
testDic.Add(testPackage.PackageGUID, testPackage.Name);
}
}
Project project = repository.GetProjectInterface();
foreach (KeyValuePair<string, string> xsd in testDic)
{
if (project.GenerateXSD(xsd.Key, @"D:\Temp\TestXSD\" + xsd.Value + ".xsd", "UTF-8", "GenGlobalElement=1"))
Console.WriteLine("Generated:" + xsd.Value);
}
}
All EA-Packages have a SchemaLocation, but these are not being generated in XSDs.
To be more concrete, it is a BiPRO-Insurance-Model package (bipro.net).
Best regards
Nol
-
To be more exact, I would like the "Referenced Package Options"
- Generate XSD for Referenced packages
- Use relative-path to reference XSDs (if 'schemaLocation' tag is empty)
from EA UI (Generate XSD) to set programmatic.
Best regards
Nol
-
IIRC the projectInterface accepts only GUIDs which are formatted with projectInterface.GUIDtoXML
q.
-
Well, your answer has nothing to do with my question. I'm able to generate XSDs with SmallDemo() method. Converting GUIDs to XML-format is not the problem.
My question is, how can I set options like:
- Generate XSD for Referenced packages
- Use relative-path to reference XSDs (if 'schemaLocation' tag is empty)
programmaticaly over EA API (the same way as in EA UI corporate edition)
Best regards
Nol
-
Well, your answer has nothing to do with my question
... the Schema-Location is not being exported even though it is properly in XSD contained. If I generate XSD in EA manually it works fine....
Well, that was your question.
You can not pass further parameters via the API. Send a feature request.
q.
-
Hi Nol,
I've tested your code and it is generating the schemaLocation for all my XSD schemas.
I have couple questions for you:
1. what EA version are you using?
2. How are you creating your XSD schemas in EA? (i.e. are you using the MDA approach? or are you manually creating the XSD models?)
Regarding your questions, the only option that the documentation says that is available at the moment is the GenGlobalElement for "Global elements for all global ComplexTypes" (a.k.a. Garden of Eden style).
IMHO, I don't think you need these options as you can programatically set the schemaLocation and you are generating all the XSD schemas anyway.
Cheers,
Rod