Book a Demo

Author Topic: Batch Job for XML Technologies -> Generate XSD  (Read 5955 times)

nshala

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Batch Job for XML Technologies -> Generate XSD
« 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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #1 on: May 04, 2015, 10:17:47 pm »
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

nshala

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #2 on: May 06, 2015, 01:30:16 am »
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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #3 on: May 06, 2015, 03:33:02 am »
Without insight into the code this is like poking around in London mist.

q.

nshala

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #4 on: May 06, 2015, 04:31:25 pm »
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

nshala

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Batch Job for XML Technologies -> Generate
« Reply #5 on: May 06, 2015, 05:00:35 pm »
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
« Last Edit: May 06, 2015, 05:01:42 pm by nshala »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #6 on: May 06, 2015, 06:49:52 pm »
IIRC the projectInterface accepts only GUIDs which are formatted with projectInterface.GUIDtoXML

q.

nshala

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #7 on: May 06, 2015, 09:41:31 pm »
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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #8 on: May 06, 2015, 10:34:36 pm »
Quote
Well, your answer has nothing to do with my question

Quote
... 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.

Rodrigo Nascimento

  • EA User
  • **
  • Posts: 33
  • Karma: +3/-0
    • View Profile
Re: Batch Job for XML Technologies -> Generate XSD
« Reply #9 on: May 29, 2015, 04:08:26 am »
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
Please check my blog for more EA related articles!

http://connection.rnascimento.com