473,785 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can XSL do this, and if so... how?

Hi there,

this may be a bit out there but I have a XML data file of a hierarchy and
I'd like to output the file using XSL, the thing is I don't know if it works
like that? I've now got an got a SVG file
http://camshag.co.uk/svg/NHSTrust/index.html which reads the data and
outputs the hierarchy as an image using a shed-load of ecmascript, this
works but I'm wondering if there is a simpler way of doing it? I came across
a script in the XML Journal which did it, but only with preformatted XML,
the XML I have isn't formatted :-(.

Please do check the link above as, apart from anything, I'd welcome
constructive criticism on it.

Thanks in advance,

Dominic
Jul 20 '05 #1
3 2357
Hi Dominic,

Yes, it is possible - transforming XML data to SVG is, in essence, 'just' an
XML-to-XML transformation in XSLT. ('just' being quantitive based on your
previous XSLT experience ;)). How - would be difficult to answer without
seeing the XML data (which doesn't appear to be available anywhere on your
web site).

I would imagine the most likely difficulties you would encounter in trying
to do this in XSLT would be:-
* calculating the overall size (height and width) or the viewport/whatever -
because this will need to be based in some way on the data;
* determining how to draw the tree lines (the complexity of this may depend
a lot on the structure of your initial XML data).

A couple of examples of XML-to-SVG using XSLT (not related to your
requirements - but may be of some use):-

http://www.topxml.com/code/default.a...l=svg&sw=categ

http://www.topxml.com/code/default.a...l=svg&sw=categ

http://www.topxml.com/code/default.a...l=svg&sw=categ
I came across
a script in the XML Journal which did it, but only with preformatted XML,
the XML I have isn't formatted :-(.
"Preformatt ed XML"? "XML isn't formatted"? What do you mean by
"formatted" ?

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Dominic Myers" <an***********@ msn.com> wrote in message
news:2u******** *****@uni-berlin.de... Hi there,

this may be a bit out there but I have a XML data file of a hierarchy and
I'd like to output the file using XSL, the thing is I don't know if it works like that? I've now got an got a SVG file
http://camshag.co.uk/svg/NHSTrust/index.html which reads the data and
outputs the hierarchy as an image using a shed-load of ecmascript, this
works but I'm wondering if there is a simpler way of doing it? I came across a script in the XML Journal which did it, but only with preformatted XML,
the XML I have isn't formatted :-(.

Please do check the link above as, apart from anything, I'd welcome
constructive criticism on it.

Thanks in advance,

Dominic

Jul 20 '05 #2
"Marrow" <ma****@somewhe re.so.fu> wrote in message
news:vo******** *******@newsfe1-gui.ntli.net...
Hi Dominic,

Yes, it is possible - transforming XML data to SVG is...

-- snip --

Cheers for the reply Marrow,

To give an example of the "formatted" text it's be something like:

<employee id="3rd in Command">
<name>Eve Grindstaff</name>
<details>0122 3 603302</details>
<superior>
<employee id="2nd in Command">
<name>Lance Lenker</name>
<details>0122 3 608062</details>
<superior>
<employee id="1st in Command">
<name>Maricel a Defore</name>
<details>0122 3 602362</details>
<superior/>
</employee>
</superior>
</employee>
</superior>
</employee>

Whereas the data I have is of this format:

<employee id="3rd in Command">
<name>Eve Grindstaff</name>
<details>0122 3 603302</details>
<superior id="#2nd in Command"/>
</employee>
<employee id="2nd in Command">
<name>Lance Lenker</name>
<details>0122 3 608062</details>
<superior id="#1st in Command"/>
</employee>
<employee id="1st in Command">
<name>Maricel a Defore</name>
<details>0122 3 602362</details>
</employee>

That's what I meant by formatted XML, if you see what I mean? ;-)
The XML file is here <http://camshag.co.uk/svg/NHSTrust/NHSTrust.owl>, the
link was a bit obscure, blame it on my CSS!

I used masses of script to format the position of the employees within the
hierarchy but was wondering about the processing abilities of XSL?

Cheers, Dom
Jul 20 '05 #3
Hi Dominic,

OK, I see what you mean - probably the phrase that would suit the first
(formatted) example would be hierarchical. The second example, the one you
are actually having to use, is flat. The process in XSLT to process the
flat into hierarchical isn't that difficult because you have references to
the superior. Although listing it from bottom up as the hierarchy seems a
little odd (as it would enevitably lad to repetition of data)? To structure
it top (most superior) down would look something like...

<?xml version="1.0"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:key name="kSubordin ates" match="employee "
use="substring-after(superior/@id,'#')"/>

<!-- template to match root element -->
<xsl:template match="/*">
<!-- copy root element as is -->
<xsl:copy>
<!-- start with employees that have no superior -->
<xsl:apply-templates select="employe e[not(superior)]"/>
</xsl:copy>
</xsl:template>

<xsl:template match="employee ">
<!-- copy the employee element -->
<xsl:copy>
<!-- aply templates to attributes and child nodes of this employee so
they get copied -->
<xsl:apply-templates select="@* | node()"/>
<!-- create a <subordinates > element as a child of the <employee>
element -->
<subordinates >
<!-- and find all the employees whose superior is the current
employee -->
<xsl:apply-templates select="key('kS ubordinates',@i d)"/>
</subordinates>
</xsl:copy>
</xsl:template>

<!-- copy all elements -->
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<!-- stop the <superior> element being copied - not needed in hierarchical
form -->
<xsl:template match="superior "/>

<!-- copy attributes and other nodes -->
<xsl:template match="@* | text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>

But you wouldn't need to do this in the XSLT to produce the final SVG - as
the above logic would be built into the process of generating the final SVG.
But a similar approach would be roughly the pattern the SVG building would
require.

Cheers
Marrow
"Dominic Myers" <an***********@ msn.com> wrote in message
news:2u******** *****@uni-berlin.de...
"Marrow" <ma****@somewhe re.so.fu> wrote in message
news:vo******** *******@newsfe1-gui.ntli.net...
Hi Dominic,

Yes, it is possible - transforming XML data to SVG is...

-- snip --

Cheers for the reply Marrow,

To give an example of the "formatted" text it's be something like:

<employee id="3rd in Command">
<name>Eve Grindstaff</name>
<details>0122 3 603302</details>
<superior>
<employee id="2nd in Command">
<name>Lance Lenker</name>
<details>0122 3 608062</details>
<superior>
<employee id="1st in Command">
<name>Maricel a Defore</name>
<details>0122 3 602362</details>
<superior/>
</employee>
</superior>
</employee>
</superior>
</employee>

Whereas the data I have is of this format:

<employee id="3rd in Command">
<name>Eve Grindstaff</name>
<details>0122 3 603302</details>
<superior id="#2nd in Command"/>
</employee>
<employee id="2nd in Command">
<name>Lance Lenker</name>
<details>0122 3 608062</details>
<superior id="#1st in Command"/>
</employee>
<employee id="1st in Command">
<name>Maricel a Defore</name>
<details>0122 3 602362</details>
</employee>

That's what I meant by formatted XML, if you see what I mean? ;-)
The XML file is here <http://camshag.co.uk/svg/NHSTrust/NHSTrust.owl>, the
link was a bit obscure, blame it on my CSS!

I used masses of script to format the position of the employees within the
hierarchy but was wondering about the processing abilities of XSL?

Cheers, Dom

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3363
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company Order By Company ASC";
5
2758
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to $location_other I keep getting "Notice: Undefined index: location_other" referring to (!($_POST)) { $location_other = $location; } else
2
2734
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form page************************************************************ <form action="/process.php" method="get" name="formOne" id="formOne"> <select name="owner" size="6" multiple id="owner"> <option value="one">one</option> <option...
2
2557
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") || ($x=="two") || ... || ($x=="seven")) ... or 2) switch ($x){ case("one"):
0
3284
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records each!!!) Dan ==================== <style> body, table, tr, td { font-family: 'verdana'; font-size: 12px;
5
3233
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
10057
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function func1()
6
2670
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE s.nnet_produkt_storrelse.id = sv.nnet_produkt_storrelse_id AND sv.nnet_produkt_varegruppe_id = v.nnet_produkt_varegruppe_id AND sv.nnet_produkt_varegruppe_id IN ( SELECT nnet_produkt_varegruppe_id FROM nnet_produkt_varegruppe
1
2198
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
3186
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in /home/krecik/public_html/silnik.php on line 251 Line 208: print ( "error: " . mysql_error()); Line 251: session_register("uprawnienia", "zalogowany"); I can understand that sth, is wrong in line 251 after line 208 and it is logical to
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.