Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 396557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:33:51+00:00 2026-05-12T16:33:51+00:00

In recent versions of the free and open source Eclipse IDE you can generate

  • 0

In recent versions of the free and open source Eclipse IDE you can generate XML documents from DTD and XSD files. Right-click on a given *.dtd or *.xsd file and select “Generate -> XML File…”. You can choose which root element to generate and whether optional attributes and elements should be generated.

Can i use this headless (without starting eclipse)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:33:51+00:00Added an answer on May 12, 2026 at 4:33 pm

    You can create a headless RCP application that contains only those plugins needed to do the actual generation. These are largely WTP plugins with a couple of the core plugins needed for managing extension points and such.

    The RCP app can be run from the command line, and passed arguments for the schema to generate from and the output file name. It is missing much of the validation you might want in a production implementation, but shows you how it can be done.
    It also hardcodes the charset to UTF-8, you can extend the argument processing to make that an optional parameter or something.

    The snippets below can be incorporated into a new headless RCP application. To create the RCP application, first create a new Plugin project:

    • Right-click->New->Other…->Plug-in Development->Plug-in Project, select Next
    • Enter a name for the project (e.g. name.seller.rich.xmlgen) and select Next
    • Uncheck This plug-in will make contributions to the UI and select Yes under Rich Client Application then click Finish
    • To add the required dependencies, double-click on META-INF/Manifest.MF and select the Dependencies tab of the editor add the following plugins to the Required Plug-ins section (click on Add… and add each one)
      • org.eclipse.core.runtime,
      • org.eclipse.core.resources;bundle-version=”3.5.0″,
      • org.eclipse.wst.common.uriresolver;bundle-version=”1.1.301″,
      • org.eclipse.wst.sse.core;bundle-version=”1.1.400″,
      • org.eclipse.wst.xml.core;bundle-version=”1.1.400″,
      • org.eclipse.wst.xml.ui;bundle-version=”1.1.0″,
      • org.eclipse.xsd;bundle-version=”2.5.0″,
      • com.ibm.icu;bundle-version=”4.0.1″,
      • org.eclipse.wst.xsd.core;bundle-version=”1.1.401″,
      • org.eclipse.wst.xsd.ui;bundle-version=”1.2.204″,
      • org.eclipse.emf.ecore;bundle-version=”2.5.0″
    • In the project you should see an Application class, copy the Java content below into the start() method of the Application source (and the imports to the top of the file).

      import java.io.ByteArrayOutputStream;
      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileOutputStream;
      import java.io.FileWriter;
      import java.net.URI;
      import java.net.URL;

      import org.eclipse.core.internal.utils.FileUtil;
      import org.eclipse.core.runtime.Platform;
      import org.eclipse.emf.ecore.plugin.EcorePlugin;
      import org.eclipse.equinox.app.IApplication;
      import org.eclipse.equinox.app.IApplicationContext;
      import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
      import org.eclipse.wst.xml.ui.internal.wizards.NewXMLGenerator;

      public Object start(IApplicationContext context) throws Exception {
      String[] args = Platform.getCommandLineArgs();

      String schemaFileName = args[0];// e.g. "C:\test\test.xsd"
      String xmlFileName = args[1];// e.g. "C:\test\test.xml"
      String rootName = args[2];//"myTestRoot";
      String charsetName = "UTF-8";
      
      try {
          //get the URI as a full URL path
          URI schemaUri = new File(schemaFileName).toURI();
          schemaFileName = schemaUri.toURL().toString();
      
          //TODO handle any errorInfo set into this array
          String[] errorInfo = new String[2];
          CMDocument cmDocument = NewXMLGenerator.createCMDocument(schemaFileName,
                  errorInfo);
          NewXMLGenerator generator = new NewXMLGenerator(schemaFileName,
                  cmDocument);
      
          generator.setRootElementName(rootName);
      
          ByteArrayOutputStream out = generator.createXMLDocument(xmlFileName,
                  charsetName);
      
          //output the content to the file.
          File outFile = new File(xmlFileName);
      
          outFile.getParentFile().mkdirs();
      
          FileWriter writer = new FileWriter(outFile);
      
          writer.write(out.toString(charsetName));
      
          writer.flush();
          writer.close();
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      
      return IApplication.EXIT_OK;
      

      }

    To create a standalone application, you also need to create a Product Configuration.

    • Right-click->New->Other…->Plug-in Development->Product Configuration
    • Select the RCP plugin project
    • Enter config in the File Name: field and click Finish.
    • Enter some suitable values in the config.product editor ID, version and Name fields (they don’t really matter as it is a headless product).
    • In Product Definition section, select New… button next to the Product: field, the default values should be fine (double check the Defining Plug-in is your RCP plug-in), select OK
    • Save the product

    You now need to export the RCP application.

    • Right click on the project->Export…->Plug-in Development->Eclipse product
    • Enter a destination directory for the application, and select OK

    You should now have a standalone application that you can invoke as you would any other application, passing command-line parameters to generate an XML file from a schema.

    The expected parameters are, in order:

    • Fully-qualified path to the schema to generate from
    • Fully-qualified name of the file to create (parent directories will also be created).
    • The root element name (same as in the wizard, this is the name of the element you want to generate content below).

    NOTE This process will only generate a file from a single schema, if your schema references other schemas it will currently fail. It would be possible to extend the process to take a properties file listing all the referenced schema locations, and resolve those as catalog contributions so the process can resolve the schemas. Some notes on how and why you’d do this below.
    If I get the chance I’ll look into implementing this and update my answer accordingly.


    If you have, for example, a Spring schema you may want to include the various Spring namespace schema in your schema file. In Eclipse the Catalog contributions provide a means to map those schema IDs to the schema file location so it can be parsed. If you have plugins for them, they could be bundled with the application and define catalog contributions (see the help for pointers on contributing them).

    If you don’t have catalog contributions available, the process would instead define key-value pairs in the properties file to reference the schema locations on the drive.

    Example contents:

     http://www.springframework.org/schema/beans=c:\\schema\\spring-beans.xsd
     http://www.springframework.org/schema/tool=c:\\schema\\spring-tool.xsd
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from my recent question on Large, Complex Objects as a Web Service
On a recent Java project, we needed a free Java based real-time data plotting
I have a menu list that displays correctly on the most recent versions of
Recent conversations with colleagues have produced varying points of view on this matter. What
The Recent Projects panel on the Start Page of VS2008 Professional doesn't appear to
A recent article on Ars Technica discusses a recent study performed by the Psychology
A recent question about string literals in .NET caught my eye. I know that
A recent question came up about using String.Format(). Part of my answer included a
A recent question about StyleCop alerted me to the use of tools to enforce
This recent question about sorting randomly using C# got me thinking about the way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.