Skip to main content
Question

Working with SVG format


lazarlubomir
Contributor
Forum|alt.badge.img+7

Hello everybody,

I have huge problem - working with SVG format, Im new one in work with this format. I have many questions please, how to figure it out in FME:

1.) How could I create body of SVG like this:

It means create tags <title>; <defs>; <pattern> etc.

2.) How could I put 'elem_type' attribute into <g> quotes (like above)?

3.) How could I put text content between <text> quotes without prefix CDATA, check below?

My aim is to get line like this: <text stroke=rgb(0,0,0).................................>22.11.1999</text>

Please, help me! :-)

Thanks, Lubo

14 replies

itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • January 13, 2017

Looks like a job for the XMLTemplater to me.


lazarlubomir
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • January 13, 2017
itay wrote:

Looks like a job for the XMLTemplater to me.

Are You sure? Even in situation, when I need to export SVG file? And what about [CDATA] - is ther any possibility, how export data without brackets please?

 

 


redgeographics
Celebrity
Forum|alt.badge.img+49

There is actually a SVG writer in FME, have you tried that?


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • January 13, 2017
redgeographics wrote:

There is actually a SVG writer in FME, have you tried that?

 

Good call @redgeographics, didnt know that and it looks like XML to me, hence the suggestion.

itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • January 13, 2017
lazarlubomir wrote:
Are You sure? Even in situation, when I need to export SVG file? And what about [CDATA] - is ther any possibility, how export data without brackets please?

 

 

See @redgeographics answer's below, I would try that first.

 


redgeographics
Celebrity
Forum|alt.badge.img+49
itay wrote:

 

Good call @redgeographics, didnt know that and it looks like XML to me, hence the suggestion.
It is an XML flavor alright, but having a decidated writer means you don't have to worry about the inner workings of the format, that saves a lot of trouble.

 

 


lazarlubomir
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • January 13, 2017
redgeographics wrote:
It is an XML flavor alright, but having a decidated writer means you don't have to worry about the inner workings of the format, that saves a lot of trouble.

 

 

Yes I have tried SVG writer, but still have problem with body structure. When I export string values, there is everytime prefix [CDATA...]. And when I create some attributes, their values are put into brackets and all entities are at same level (check below).

 

I need structured body as I mentioned in my first contribution.

 

 

 

 


redgeographics
Celebrity
Forum|alt.badge.img+49

I'm no SVG expert, but I think you have to have the CDATA elements. However, if you really don't want them you can always write the SVG using the writer and then read it as text in a 2nd workspace and use a StringReplacer to get rid of the CDATA tags, then an XMLFormatter to pretty print the output.


Hi,

did you find any solutions?

I have the same problem, i need to put a <pattern> around a <path> output from svgwriter

f.e.

<pattern id="diagonalHatch" patternUnits="userSpaceOnUse" width="4" height="4">

<path d="M-1,1 l2,-2

M0,4 l4,-4

M3,5 l2,-2"

style="stroke:black; stroke-width:1" />

</pattern>


lazarlubomir
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • January 15, 2019
sebastiangoerck wrote:

Hi,

did you find any solutions?

I have the same problem, i need to put a <pattern> around a <path> output from svgwriter

f.e.

<pattern id="diagonalHatch" patternUnits="userSpaceOnUse" width="4" height="4">

<path d="M-1,1 l2,-2

M0,4 l4,-4

M3,5 l2,-2"

style="stroke:black; stroke-width:1" />

</pattern>

Hello @sebastiangoerck,

finally, I had to leave SVG writer and I used XMLTemplater - Its better for my purposes (I have free hands in creating of template for our customer). The hardest thing was to find way, how to convert geometries to SVG, but combination of expressionevaluators and geometryextractor can do that.

Hope I helped You!

Lubo


lazarlubomir wrote:

Hello @sebastiangoerck,

finally, I had to leave SVG writer and I used XMLTemplater - Its better for my purposes (I have free hands in creating of template for our customer). The hardest thing was to find way, how to convert geometries to SVG, but combination of expressionevaluators and geometryextractor can do that.

Hope I helped You!

Lubo

thanks for the feedback...this is not the solution i had hoped for, but i will have a look at it :-)


srg
Forum|alt.badge.img+10
  • January 17, 2019

@lazarlubomir

Did you try using the pre-defined template in SVG Writer Parameter?

FME SVG Writer

hope that helps

happy fme-ing :-)

srg


srg wrote:

@lazarlubomir

Did you try using the pre-defined template in SVG Writer Parameter?

FME SVG Writer

hope that helps

happy fme-ing :-)

srg

i miss the approach at this Point, an example would be very helpful.

:-)


rahulsharma
Safer
Forum|alt.badge.img+10

 Hi @lazarlubomir, unfortunately, there is currently no support in FME Desktop to accomplish this through SVG Writer. But doing some post-processing with XMLFragmentor and XMLQueryUpdator 

 

Here is how workflow would go

 

Transform your file to SVGWriter Directly

 

Now using FeatureReader, Read back the file and use the above-mentioned transformers

For XMLQueryUpdator use following syntax 

NOTE: this is just sample add the tags as you desire 

declare namespace x='http://www.w3.org/2000/svg';
for $n in /x:g
return
insert node attribute elem_type{'elem_id'} into $n

0684Q00000ArK5iQAF.png

Please find attached a sample workflow. 

none2svg_2018.fmw


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings