Java Generator is generating spaces in the package names [message #1803540] |
Sun, 03 March 2019 15:46  |
Eclipse User |
|
|
|
Hi,
I am using papyrus 2018-12 (4.10) and the designer update site: http://download.eclipse.org/modeling/mdt/papyrus/components/designer/. I have created a UML model and I have managed to generate Java Project however, I have two issues:
1- The package names have spaces in them
e.g.
package com.reservation.model.Common Business Entities Domain.Calendar ABE;
2- the prefix which i have defined in the project stereotype of the package is defined as per the below. This means that other packages are not referenced correctly.
import com.reservation.model.;
I have looked everywhere for hints but I couldn't find any. Appreciate, your support Ansgar.
Thanks
|
|
|
|
Re: Java Generator is generating spaces in the package names [message #1804055 is a reply to message #1804010] |
Sat, 16 March 2019 17:06  |
Eclipse User |
|
|
|
Hi Ansgar,
Thanks for your reply. I like the option of using a label with space while keeping the package names without space. I've written a perl script to rename all of the packages to remove the spaces between name attribute. HYG.
use strict;
use warnings;
#use XML::Simple;
use XML::LibXML;
my $filename = $ARGV[0];
my $dom = XML::LibXML->load_xml(location => $filename);
my $e= $dom->findnodes( "//packagedElement");
foreach my $e (@$e)
{ print $e->nodeName;
if($e->nodeName eq "packagedElement")
{
# text needs to be trimmed or line returns show up in the output
my $text= $e->textContent;
$text=~s{^\s*}{};
$text=~s{\s*$}{};
# if( ! $e->getChildrenByTagName( '*') && $text)
# {
# print "=$text"; }
print "\n";
my @attrs= $e->findnodes( "./@*");
my $arrLength = scalar @attrs;
# print "the number of attributes found is $arrLength";
# or, as suggested by Borodin below, $e->attributes
foreach my $attr ($e->attributes)
{
# print "attribute: $attr \n";
if($attr->nodeName eq "name" and ($attr->value =~ / /) )
{
#print $e->nodeName, " ", $attr->nodeName. "=", $attr->value, "\n"; }
my $string = $attr->value ;
$string =~ s/\s+//g;
my $originalString = $attr->value;
print "$originalString will be replaced with $string\n";
$attr->setValue($string);
}
}
}
}
$dom->toFile("output.xml",1);
|
|
|
Powered by
FUDForum. Page generated in 0.24205 seconds