xsl-list
[Top] [All Lists]

[xsl] value-of select - then multiply : For X3D

2008-06-18 04:55:37
Sorry for not being clear.
I'm working on a XSLT for X3D, and this node deals with x,y,z co-ordinates within such a 3d world, derived from <Work_Location_longitude>, <Work_Location_latitude>, and <Work_Year> respectively - each of which are elements in the XML source file.

Here's an edited version of the source XML:

/////

<?xml version="1.0" encoding="iso-8859-1" ?> <?xml-stylesheet type="text/xsl" href="X3D-XSLT_Work_Year.xsl"?>
<works>
   <work>
       <Work_Year>1981</Work_Year>
       <Work_Name>Rainfall at Launching Place</Work_Name>
       <Work_Location>Australia</Work_Location>
       <Work_Location_longitude>133</Work_Location_longitude>
<Work_Location_latitude>-27</Work_Location_latitude> </work>
    <work>
<Work_Year>1981</Work_Year> <Work_Name>A Walk Through the City</Work_Name>
       <Work_Location>Canada</Work_Location>
       <Work_Location_longitude>-95</Work_Location_longitude>
       <Work_Location_latitude>60</Work_Location_latitude>
   </work>
    <work>
<Work_Year>1981</Work_Year> <Work_Name>Five Silent Studies</Work_Name> <Work_Location>Canada</Work_Location>
       <Work_Location_longitude>-95</Work_Location_longitude>
       <Work_Location_latitude>60</Work_Location_latitude>
   </work>

etc
etc

<works>
/////

I want to get the <Work_Location_longitude> values for each record, -1.4 from this, and if there are previous records, offset each of the subsequent results by 5. This will determine the x value of the node position.

Similarly,

I want to get the <Work_Location_latitude> values for each record, -2.2 from this, and if there are previous records, offset each of the subsequent results by 5. This will determine the y value of the node position.

Here's the XSLT (shortened version)

/////

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> <xsl:output media-type="model/x3d=xml" doctype-system="http://www.web3d.org/specifications/x3d-3.2.dtd"; method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>

   <xsl:template match="/">
<X3D profile="Immersive">&#10;

           <head>&#10;<title/></head>
               <Scene>
                    <xsl:apply-templates/>
               </Scene>
       </X3D>

   </xsl:template>
   <xsl:template match="works">
<Group>
 <xsl:for-each select="work">
       <Group>

<Transform translation='0 0 0'> /<!-- i.e the x,y,z co-ords for the node>/

<xsl:attribute name="translation">
<xsl:value-of select="Work_Location_longitude"/>/ <!-- get this value-of select, -1.4, and add 5 if there is a previous record with the same value value-of select "Work_Location_longitude">/ <xsl:value-of select="Work_Location_latitude"/>/<!-- get this value-of select, -2.2, and add 5 if there is a previous record with the same value-of select "Work_Location_latitude">/ <xsl:value-of select="Work_Year div 10"/></xsl:attribute>
              <Shape>
<Appearance> <Material />
                   </Appearance>
<xsl:element name="Text"><xsl:attribute name="string"> <xsl:value-of select="Work_Year"/> </xsl:attribute> </xsl:element>
               </Shape>
</Transform> </Group> </xsl:for-each> </Group>
etc
etc
etc

</xsl:template>

</xsl:stylesheet>

/////

And the output i want would be something like this:

/////

<!DOCTYPE X3D SYSTEM "http://www.web3d.org/specifications/x3d-3.2.dtd";>
<X3D profile="Immersive">
<head>
<title/>
</head>
<Scene>
<Group>

<Group>
<Transform translation="*131.6 -29.2 198.1*"> /<!-- i.e longitude -1.4, latitude -2.2, year / 10>/
<Shape>
<Appearance>
<Material/>
</Appearance>
<Text string="&quot;Rainfall at Launching Place&quot;"></Text>
<!-- Text string="Australia"></Text> -->
</Shape>
</Transform>
</Group>

<Group>
<Transform translation="*-93.6 57.8 198.1*"> /<!-- i.e longitude -1.4, latitude -2.2, year / 10>/
<Shape>
<Appearance>
<Material/>
</Appearance>
<Text string="A Walk Through the City"></Text>
<!-- <Text string="Canada"></Text> -->
</Shape>
</Transform>
</Group>

<Group>
<Transform translation="*-88.6 62.8 198.1*"> /<!-- i.e longitude -1.4 +5, latitude -2.2 +5, year / 10>/
<Shape>
<Appearance>
<Material/>
</Appearance>
<Text string="Five Silent Studies"></Text>
<!-- <Text string="Canada"></Text> -->
</Shape>
</Transform>
</Group>

etc
etc

</Group>
</Scene>
</X3D>

////

Can anyone shed any light on this?

Best Regards
Milo

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>