Jump to content

XML to SVG (using xslt)


Guest mariak_csd

Recommended Posts

Guest mariak_csd

Hello, I am new here and I would like some help about a project I'm working on.I want to transform an xml document to an svg document.The xml xas some coordinates in the following form : <gml:LinearRing ><gml:coord ><gml:X >20</gml:X><gml:Y >20</gml:Y></gml:coord><gml:coord ><gml:X >40</gml:X><gml:Y >20</gml:Y></gml:coord><gml:coord ><gml:X >50</gml:X><gml:Y >30</gml:Y></gml:coord><gml:coord ><gml:X >40</gml:X><gml:Y >40</gml:Y></gml:coord><gml:coord ><gml:X >20</gml:X><gml:Y >40</gml:Y></gml:coord><gml:coord ><gml:X >10</gml:X><gml:Y >30</gml:Y></gml:coord></gml:LinearRing>The number of this coords is undefined...... I want to take this coordinates and use them as an attribute to the next svg shape: <g> <polygon fill="green" stroke="blue" stroke-width="2" points= 20 20, 40 20, 50 30..../> </g>How can I get this coordinates as one string and use them in the above "points" attribute? Thank you!

Link to comment
Share on other sites

Hello, I am new here and I would like some help about a project I'm working on.I want to transform an xml document to an svg document.The xml xas some coordinates in the following form : <gml:LinearRing ><gml:coord ><gml:X >20</gml:X><gml:Y >20</gml:Y></gml:coord><gml:coord ><gml:X >40</gml:X><gml:Y >20</gml:Y></gml:coord><gml:coord ><gml:X >50</gml:X><gml:Y >30</gml:Y></gml:coord><gml:coord ><gml:X >40</gml:X><gml:Y >40</gml:Y></gml:coord><gml:coord ><gml:X >20</gml:X><gml:Y >40</gml:Y></gml:coord><gml:coord ><gml:X >10</gml:X><gml:Y >30</gml:Y></gml:coord></gml:LinearRing>The number of this coords is undefined...... I want to take this coordinates and use them as an attribute to the next svg shape:  <g>    <polygon fill="green" stroke="blue" stroke-width="2"            points= 20 20, 40 20, 50 30..../>  </g>How can I get this coordinates as one string and use them in the above "points" attribute? Thank you!

Link to comment
Share on other sites

Ok,I'm a novice (I don't think I've put a reply in without this disclaimer), but could you use <xsl:for-each> to select the values of the points into a string somewhere in a stylesheet?I'm thinking something like <xsl:attribute name="points"><xsl:for-each select="gml:coord"><xsl:value-of select="gml:x" />,<xsl:value-of select="gml:y" /></xsl:for-each></xsl:attribute>If this works then I puff my chest out with pride, otherwise I hang my head in shame. Give it a try and let me know.Dooberry Firkin
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...