Custom XML formatter for Eclipse - eclipse

Is it possible to define a new XML formatter in an Eclipse plugin? I have some XML files that must follow specific formatting rules, but see how way of plugging in to the formatter engine.
I can tie this formatter to files that are part of a project with a specific facet.
For context, I am maintaining the Sling IDE Tooling for Eclipse, and part of that application is concerned with synchronising local state with a remote JCR repository.
The synchronisation is based on XML files and folders stored on disk, following a well defined format - FileVault DocView. These XML files can contain metadata attached to files and folders, but also arbitrary hierarchical data.
The CLI tool that is used as an alternative to the IDE tooling and almost always in production follows strict set of rules regarding indentation, XML attribute ordering, etc and also rewrites files when pushing them to the repository.
I would like to follow this model and allow the users of the IDE to format the XML files following the exact same preset. The formatting model is actually quite simple, shown below:
format = new OutputFormat("xml", "UTF-8", true);
format.setIndent(4);
format.setLineWidth(0);
format.setBreakEachAttribute(true);
format.setSortAttributeNamesBy(AttributeNameComparator.INSTANCE);
The name comparator is also quite simple, sorting xmlns instructions first, then the namespaced properties, and then the other properties.

This was requested in https://bugs.eclipse.org/460055 , but not implemented.

Related

Version controlled meta information such as tags and filters in EA

The goal is to have a fully version controlled EA model with the UML/SysML/... content aswell as metainformation like tags (inluding enum type specification) or configured filters.
Using the CVS-integration with SVN its easily possible to synchronize the general model data within the team. Tags can be defined by a developer as a enum with the valid values by adding the following snippet to "UML Typed" -> "Tagged Values Types":
Type=Enum;
Values=A, B, C;
I expect EA to synchronize the Tags enum definition using the VCS once created or after the first usage. However, EA seems to only sync the tags that have been applied to model elements without any meta information like enum-definitions or descriptions. I can confirm that the defined tag gets saved inside the "local model"-File of the EA-Project and is not saved in some user-only directory.
One possible solution I found is using the "Export/Import Reference Data" function of EA that is described here and to sync the data in a separate repository. It's a really clunky approach including several manual steps that can lead to faults - such as forgetting about exporting after a change of the tagged value types.
Is there a better solution that I just missed?
With the version control integration you are storing package information into an XMI file and upload that to the version control system (SVN in your case).
The tagged values definition is meta- information that is not stored in that package, and thus not part of the XMI file that is uploaded to SVN.
The best way to deal with things like this is to add tagged values to stereotypes in a UML profile, that is packaged into an MDG file.
MDG files can be considered as packaged meta-models. You can store the MDG file in your version control system as well, and instruct users to use the latest MDG file when using EA.

Sun Eclipse capabilities with Schema creation

I have two questions that pertian to each other. I have to switch from XML Spy over to Sun Eclipse and there are some things that XML Spy does magically for me that I want to know if Eclipse can handle the same way:
Given a sample XML document, generate a minimum XML Schema that it will comply with. It need not have type, occurrence or size restrictions, but it will have the structure. It will also take care of the element variations if present in the data, coming up with the greatest common structure.
Given an XML Schema with all its included type declarations, generate a sample XML document, with options to have or not have the optional elements, to include one or many occurrences of repeated elements.
Any Help....
You can create a sample XML from an XSD file in Eclipse. Here are the instructions for the Juno version of Eclipse (with Web Tools Platform):
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftcrexxsd.html
I'm not aware of a tool to go from an XML to an XSD file... you could search the Eclipse plugin market place for one...

Buildr: adding a path to the generated eclipse/idea files

I have a legacy java project that we have been moving to buildr/artifactory from ant/jars in svn.
The primary code is in the default (src/main/java) folder, but we have a few external source paths, for various tests that we can't move into the default folder, but we want to have access with it.
Currently, when adding a new library/regenerating IDE fields, it does not pick up these source paths, and I can't find a succinct discussion in the buildr manual for how to actually add them, rather than re-adding everything manually in eclipse (which just gets wiped out on the next regen).
Any idea how to have multiple source paths get picked up explicitly by buildr so that the idea/eclipse targets generate properly?
There are two ways that I know will work with IDEA. The second one might also work with Eclipse, while the first is specific to the idea task.
The IDEA-specific solution:
define 'proj' do
# ...
iml.main_source_directories << _('src/other')
end
iml also has test_source_directories and excluded_directories arrays you can append to.
The possibly eclipse-compatible solution, with more background than you probably want:
The iml object gets its default values for the main and test source directory arrays from project.compile.sources and project.test.compile.sources (slight simplification; resources are considered also). Buildr defines these .sources project attributes from the layout, so instead of explicitly appending to the iml attributes, you could use a custom layout for your project that includes your special source paths. That might work with the eclipse task, but I haven't tried it.

IBM Eclipse WSDL Editor: How do I include an external wsdl/schema?

I am trying to create Web Services from the Top-Down approach. I downloaded Eclipse and am using the WSDL gui editor in it to build my WSDL files.
I am splitting up my Services based on "modules". The Types I am adding to the WSDLs all need to reference common stuff, such as PersonEntity, AddressEntity, States enumeration (simple type), Countries enumeration (simple type), and AbstractEntity. Since those items are all common I created a seperate WSDL file (named Commons.wsdl) that contains the type information for those types.
I want to "import" that WSDL into my other WSDL files to use:
For example, I have an entity named RegistrationEntity which inherits from AbstractEntity and contains a PersonEntity as well as an AddressEntity. I'm not sure how to do this... I saw that the WSDL spec has "import" and "include" and am not sure which one to use. Also, how do I actually import (or include) the Commons.wsdl file so that I can use the Types defined within it?
Thanks!
Oh, and I'm not sure if I'm supposed to stick this stuff in a seperate WSDL but another type of file such as an xsd or something. I really wanna follow best practices so if that's the proper way to do it then I'd rather do that.
I found out that the problem I had was I was creating a WSDL file for my commons and using an inline scheme for that, rather than creating an XSD file to be imported by my other WSDLs.
So instead I just created an Commons.XSD as my "Common Schema".

XML schema for Eclipse target definition files

Where can I find the XML schema and/or documentation for Eclipse target definition files (*.target)?
May be this schema might fit the target files created for an RCP platform.
Part of that schema file is visible in the Eclipse help page.
There is no schema or documentation defining the structure of a target definition file (.target). This is because the file structure is not intended to be API (it may change between release).
The structure has changed several times already. The code used to serialize/deserialize the file can be found in the following classes:
org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper
org.eclipse.pde.internal.core.target.TargetPersistence38Helper
org.eclipse.pde.internal.core.target.TargetPersistence36Helper
org.eclipse.pde.internal.core.target.TargetPersistence35Helper
org.eclipse.pde.internal.core.target.TargetPersistence34Helper