This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
selecting all * named elements
- From: Jarkko dot Moilanen at uta dot fi
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 22 Aug 2002 11:36:15 +0300 (EEST)
- Subject: [xsl] selecting all * named elements
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi!
I am having somekind of break in my brains or something cause
I am asking this kind of simple question.
I managed to get svg output, but not excatly with desired content.
My question is: why is my stylesheet only selecting the first Event
element and not the other one also. I tried also xsl:for-each, but
I did nto get what I wanted.
XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Events>
<Event class="Military">
<Eventdata>
<Timestamp>2002/03/31, 12:03:48</Timestamp>
<Coords>
<CoordX>45</CoordX>
<CoordY>91</CoordY>
</Coords>
<Persons>5</Persons>
<Vehicles>1</Vehicles>
<Linkvalue>http://hyplt05.uta.fi/xslt/foo1.html</Linkvalue>
</Eventdata>
</Event>
<Event class="Civilian">
<Eventdata>
<Timestamp>2002/03/31, 23:56:00</Timestamp>
<Coords>
<CoordX>201</CoordX>
<CoordY>110</CoordY>
</Coords>
<Persons>1</Persons>
<Vehicles>1</Vehicles>
<Linkvalue>http://hyplt05.uta.fi/xslt/foo2.html</Linkvalue>
</Eventdata>
</Event>
</Events>
XSLT: (sorry about the messy output)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- stylesheet.xsl -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
media-type="application/xml"/>
<xsl:template match="/">
<xsl:apply-templates select="Events/Event"/>
</xsl:template>
<xsl:template match="Event">
<xsl:variable name="coordX">
<xsl:value-of select="Eventdata/Coords/CoordX"/>
</xsl:variable>
<xsl:variable name="coordY">
<xsl:value-of select="Eventdata/Coords/CoordY"/>
</xsl:variable>
<xsl:variable name="timestamp">
<xsl:value-of select="Eventdata/Timestamp"/>
</xsl:variable>
<xsl:variable name="tyyppi">
<xsl:value-of select="Eventdata/Vehicles/@tyyppi"/>
</xsl:variable>
<xsl:variable name="persons">
<xsl:value-of select="Eventdata/Persons"/>
</xsl:variable>
<xsl:variable name="lkm">
<xsl:value-of select="Eventdata/Vehicles"/>
</xsl:variable>
<xsl:variable name="link">
<xsl:value-of select="Eventdata/Linkvalue"/>
</xsl:variable>
<svg>
<g transform="translate(10,20)">
<text font-size="20">XML Paikkatieto</text>
<text x="500" y="10" font-size="12">
SORSA TAHAN</text>
<rect x="0" y="0" width="800" height="500" fill="none" stroke="blue" />
<rect x="{($coordX)+5}" y="{$coordY}" width="146" height="33" fill="none"
stroke="blue" />
<circle cx="{$coordX}" cy="{$coordY}" r="2"
style="fill:black;stroke:blue;"/>
<text x="{($coordX)+10}" y="{($coordY)+13}" font-size="10">
<xsl:value-of select="@class"/></text>
<text x="{($coordX)+50}" y="{($coordY)+13}" font-size="10">
<xsl:value-of select="$timestamp"/></text>
<text x="{($coordX)+10}" y="{($coordY)+26}" font-size="10">Vehicles:</text>
<text x="{($coordX)+52}" y="{($coordY)+26}" font-size="10">
<xsl:value-of select="$lkm"/></text>
<text x="{($coordX)+72}" y="{($coordY)+26}" font-size="10">Persons:</text>
<text x="{($coordX)+115}" y="{($coordY)+26}" font-size="10">
<xsl:value-of select="$persons"/></text>
</g>
</svg>
</xsl:template>
</xsl:stylesheet>
Cheers
Jarkko
****************************************************************
Jarkko Moilanen "Erehtyminen on inhimillista,
Researcher/ ITCM mutta todella suuret mokat
jm60697@uta.fi vaativat tietokoneen käyttöä."
www.uta.fi/~jm60697
GSM: +358 50 3766 927
****************************************************************
* ITCM | Information Technology and Crisis Management
* http://www.itcm.org
****************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list