[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]


Subject: XSLT and SVG
From: "Andrea Pertosa" <andrea.pertosa@xxxxxxxxx>
Date: Tue, 18 Jul 2006 13:08:28 -0400
svg orgchart
HI all and thanks for reading!!

First I have to confess that I'm a beginner, so please be forgiving!!

I started looking at XML/XSLT some time ago, and I have to admit that
the learning curve is a bit too steep for me.

The scenario: my XML file contains bodies and joints and represents a
mechanical system.

The idea: instead of looking at the XML text in order to figure out if
the mechanism is well-formed, wouldn't it be cool to develop an XSLT
that transforms the XML file so that the mechanical system is
presented in a graphical way?

The (I think) solution: define an XSLT that creates a block diagram
made of rectangles (or circles...) for each body and a connecting line
between the two rectangles that a joint connects.

Sounds easy, no?

  Unfortunately I'm running into problems and I thought that if I
published what I have done so far, perhaps someone could tell me if
I'm on the right track or not, since I'm sure there   are many
examples of XSLT that create graphical representation of hierarchical
structure. Think of an org chart...

--------- the XML file ------------

    label               = "Ground"
    id                  = "30101"
    label               = "Body 1"
    id                  = "30301"
    label               = "Body 2"
    id                  = "30302"
    body1_id            = "30101"
    body2_id            = "30301"

------------ the xslt file ---------------

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" version="1.0" encoding="ISO-8859-1"/>
  <xsl:template match="Model">
     <svg width="800" height="500">
        <g id="Body_Rigid" transform="translate(0, 220)">
           <xsl:for-each select="Body_Rigid">
              <text x="{position()*145 + 40}" y="-70"
style="font-family: arial; text-anchor: middle;">
                 <xsl:value-of select="@label"/>
              <text x="{position()*145 + 40}" y="-55"
style="text-anchor:end;">ID = </text>
              <text x="{position()*145 + 60}" y="-55"
style="font-family: arial; text-anchor: middle;">
                 <xsl:value-of select="@id"/>
              <rect x="{position()*145}" y="-100" height="70"
width="115" style="fill:none; stroke:black;"/>


The output is an XML file that contains svg elements, rectangles
representing bodies.
I'm completely at loss on how to represent the connection between body
1 and body 2.

Has anyone run into a similar issue? Can anyone share their experience
or a working example where a relationship between nodes was
represented graphically using SVG?

Thanks for your help.
Andrea P.

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.