XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Kurt MartinSubject: Translating svg path data to x,y
Author: Kurt Martin
Date: 31 Aug 2006 09:51 AM
I am creating an XSLT to convert some XML data to SVG. The data is
exported from a program the customer is using, and it exports text
data, but the actual SVG text is written out as paths. I need to
find the x,y data in path/@d so I can position the text properly on
the screen. Here is a snippet of code:

<CADConverterDwgEntity>
<Type>AcDbText</Type>
<Handle>604</Handle>
<Layer>TEXT</Layer>
<Linetype>CONTINUOUS</Linetype>
<Text>2</Text>
</CADConverterDwgEntity>
<path d="M556.42 509.02L556.42 508.86M556.42 508.86L556.58
508.54M556.58 508.54L556.74 508.37M556.74 508.37L557.07
508.21M557.07 508.21L557.72 508.21M557.72 508.21L558.05
508.37M558.05 508.37L558.21 508.54M558.21 508.54L558.37
508.86M558.37 508.86L558.37 509.19M558.37 509.19L558.21
509.51M558.21 509.51L557.88 510M557.88 510L556.26 511.62M556.26
511.62L558.53 511.62"
fill="none" stroke="black" stroke-width="0.1"/>
<EndCADConverterDwgEntity>
</EndCADConverterDwgEntity>

What I need is:

<text x="nnn" y="nnn" fill="none" stroke="black" stroke-
width="0.1">2</text>

where the values of x and y are derived from the information in
path/@d.

Any help would be greatly appreciated.

Postnext
Ivan PedruzziSubject: Translating svg path data to x,y
Author: Ivan Pedruzzi
Date: 01 Sep 2006 12:11 AM
Hi Kevin,

Which numbers you need to pick inside @d?


Ivan Pedruzzi
Stylus Studio Team

Postnext
Kurt MartinSubject: Translating svg path data to x,y
Author: Kurt Martin
Date: 01 Sep 2006 06:02 AM
From the path element, d attribute:
<path d="M556.42 509.02L556..."/>

should be:

<text x="556.42" y="509.02">text_value</text>

The placement of the lower, left corner is where the text should be placed, so the strings contain between "M" and "L", delimited by a space, should be placed into x and y respectively.

so, taken the snippet of code I provided:

<CADConverterDwgEntity>
<Type>AcDbText</Type>
<Handle>604</Handle>
<Layer>TEXT</Layer>
<Linetype>CONTINUOUS</Linetype>
<Text>2</Text>
</CADConverterDwgEntity>
<path d="M556.42 509.02L556.42 508.86M556.42 508.86L556.58
508.54M556.58 508.54L556.74 508.37M556.74 508.37L557.07
508.21M557.07 508.21L557.72 508.21M557.72 508.21L558.05
508.37M558.05 508.37L558.21 508.54M558.21 508.54L558.37
508.86M558.37 508.86L558.37 509.19M558.37 509.19L558.21
509.51M558.21 509.51L557.88 510M557.88 510L556.26 511.62M556.26
511.62L558.53 511.62"
fill="none" stroke="black" stroke-width="0.1"/>
<EndCADConverterDwgEntity>
</EndCADConverterDwgEntity>


should turn out to be:

<text x="556.42" y="509.02">2</text>

Thanks,

kev

Postnext
Ivan PedruzziSubject: Translating svg path data to x,y
Author: Ivan Pedruzzi
Date: 01 Sep 2006 11:33 AM
Hi Kevin,

See attached solution

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


Documentx_y.xsl

Posttop
Kurt MartinSubject: Translating svg path data to x,y
Author: Kurt Martin
Date: 01 Sep 2006 11:41 AM
Works great! Thanks!

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.