 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 12th, 2009, 02:02 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Well you keep editing code samples so it is a fast moving target to write XPath expressions against those code samples.
Now your variable has type element(layers) and the only child elements, if I am able to read that correctly, are 'groundLayer' elements.
So the outer xsl:for-each should select your variable and then the inner xsl:for-each needs e.g.
Code:
<xsl:for-each select="groundLayer">
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|
|

March 12th, 2009, 02:12 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
Holy crapper! It's producing the correct output all except for the first point (which is not contained within the inner loop)
Output:
Code:
<path stroke="blue" stroke-width="2" fill="none"
d="M L 0 200, 363 449, 574 599, 901 599"/>
<path stroke="blue" stroke-width="2" fill="none"
d="M L 0 0, 363 299, 574 499, 901 549"/>
My desired output is:
Code:
<path stroke="blue" stroke-width="2" fill="none"
d="M0 200 L 0 200, 363 449, 574 599, 901 599"/>
<path stroke="blue" stroke-width="2" fill="none"
d="M0 200 L 0 0, 363 299, 574 499, 901 549"/>
Is there a quick fix for this?
@Martin - I'm sorry about the changes I was making - kept spotting more irrelevant bits I had and you were much quicker at replying than I could have wished for!
Thanks - hopefully we can get this last bit fixed up
|
|

March 12th, 2009, 02:27 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
Okay well it now fully works! I just added another for-each loop and constrained it a predicate of [1]
Here's the path loop:
Code:
<path stroke="blue" stroke-width="2" fill="none">
<xsl:attribute name="d">
<xsl:for-each select="groundLayer[1]">
<xsl:sort select="xs:double(distanceGL)" order="descending"/>
<xsl:text>M</xsl:text>
<xsl:value-of select="$distance - distanceGL"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$height - altitudeGL + layerTopDepth"/>
</xsl:for-each>
<xsl:text> L </xsl:text>
<xsl:for-each select="groundLayer">
<xsl:sort select="xs:double(distanceGL)" order="descending"/>
<xsl:value-of
select="concat($distance - distanceGL, ' ', $height - altitudeGL + layerTopDepth)"/>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:attribute>
</path>
Now it works for this case I'm throwing at it and produces the lines! I am just getting some dinner and then will be back to expand number input data and then see how it copes.
I'm really pleased/relieved! Thanks to both that helped, much much appreciated. I will post back with info a bit later on about how it's going and what the result of it looks like. Cheers 
|
|

March 13th, 2009, 05:56 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
hello again.
Here's an image showing how the xsl code help I received here has helped so far with showing soil/rock ground layers on a slope cross section. Hopefully over the weekend I shall make it all look/function in more advanced ways but now the hard part is over which is great, so thank you!
http://i3.photobucket.com/albums/y90...icture1-25.png
(The ground layers shaded on the image are just examples to test various parts of the feature. In reality it will be made to look more realistically in terms of shapes and where the boundaries are.)
edit: I do have a question though and it's regarding XSLT 2.0. I currently use the software Oxygen to write and test my xml and xsl files. The translation used is Saxon-B9..etc. No browsers yet seem to support translating XSLT 2.0 and so this adds a slight inconvenience for other users. It will be fine on my server because I can write a php script that will perform the translation server-side, then save the results to then be viewed. For other people however this is an inconvenience when compared to simple XML being translated at a click of a button by the browser's in built XSLT 1.0 processor. Will we be seeing the adoption of 2.0 by browsers in the near future?Cheers
Last edited by jamesdurham; March 13th, 2009 at 06:17 PM..
|
|

March 14th, 2009, 11:05 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
Please help me again!
Hi
This is going to sound ridiculous but it turns out that the professor in charge of my project now wants the data to be held almost exactly as it is by another standard (whereas before he just wanted some). This means that the same data is required as before, however it is all located/sorted differently and now more awkward
So the xml data is now held like this (explanation briefly after):
Code:
<geo:groundLayers>
<diggs:Hole diggs:id="1">
<diggs:location>
<gml:Point>
<gml:pos>316865 504940</gml:pos>
</gml:Point>
<geo:height>749</geo:height>
</diggs:location>
<diggs:layerSystems>
<diggs:LayerSystem>
<diggs:layers>
<diggs:Layer>
<diggs:id>1</diggs:id>
<diggs:primaryName />
<diggs:top>
<gml:pos>0</gml:pos>
</diggs:top>
<diggs:base>
<gml:pos>400</gml:pos>
</diggs:base>
<diggs:descriptions>
<diggs:Description/>
</diggs:descriptions>
</diggs:Layer>
<!--More <diggs:Layer>'s, each representing one layer within the Hole-->
</diggs:LayerSystem>
</diggs:layerSystems>
</diggs:Hole>
<!--More diggs:Hole elements to represent other hole locations. <diggs:id>'s will be shared across holes-->
So now the data is held per Hole location whereas before it was held per ground layer (which would then contain data from several hole locations). Now that it's per hole it means that a <diggs:id> is required to store which layer it is; this is so that in a different hole we can still identify if it's the same layer type. My goal is to draw a path connecting each layer of the same type (therefore same diggs:id).
Over the past 24hours I have gotten close on several occasions but it still ends up drawing the wrong thing!
At the moment I still use this function for the location coordinate tuple:
Code:
<xsl:function name="geo:point3" as="xs:integer+">
<xsl:param name="location3" as="element(diggs:Hole)"/>
<xsl:variable name="point3" as="xs:string" select="$location3/diggs:location/gml:Point/gml:pos"/>
<xsl:sequence select="xs:integer(substring-before($point3, ' '))"/>
<xsl:sequence select="xs:integer(substring-after($point3, ' '))"/>
</xsl:function>
Here is my latest code main code for storing variables from the calculations etc:
Code:
<xsl:variable name="groundLayers" as="element(layers)+">
<xsl:for-each
select="geo:slope/geo:groundLayers/diggs:Hole/diggs:layerSystems/diggs:LayerSystem/diggs:layers/diggs:Layer/diggs:id">
<xsl:variable name="layerName" select="following-sibling::diggs:primaryName"/>
<xsl:variable name="layerTopDepth" select="following-sibling::diggs:top/child::gml:pos"/>
<xsl:variable name="layerBaseDepth" select="following-sibling::diggs:base/child::gml:pos"/>
<layers xmlns="">
<xsl:variable name="groundLayer" as="xs:integer+"
select="parent::diggs:Layer/parent::diggs:layers/parent::diggs:LayerSystem/parent::diggs:layerSystems/parent::diggs:Hole/geo:point3(.)"/>
<xsl:variable name="coordinateX1" as="xs:integer" select="$groundLayer[1]"/>
<xsl:variable name="coordinateY1" as="xs:integer" select="$groundLayer[2]"/>
<xsl:variable name="c2" as="xs:decimal" select="$groundLayer[2] - (($m2)*$groundLayer[1])"/>
<xsl:variable name="cdiff" as="xs:decimal" select="$c1 - $c2"/>
<xsl:variable name="xi" as="xs:decimal" select="$cdiff div $mdiff"/>
<xsl:variable name="yi" as="xs:decimal" select="($m2*$xi)+$c2"/>
<xsl:variable name="xdiff" as="xs:decimal" select="$toe[1] - $xi"/>
<xsl:variable name="ydiff" as="xs:decimal" select="$toe[2] - $yi"/>
<xsl:variable name="distanceGL" select="xs:integer(round(math:sqrt($ydiff * $ydiff + $xdiff * $xdiff)))" as="xs:decimal" />
<xsl:variable name="heightGL" as="xs:integer"
select="parent::diggs:Layer/parent::diggs:layers/parent::diggs:LayerSystem/parent::diggs:layerSystems/preceding-sibling::diggs:location/geo:height"/>
<xsl:variable name="altitudeGL" as="xs:integer">
<xsl:choose>
<xsl:when test="$altitude[1] < 0">
<xsl:value-of select="$heightGL - $altitude[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$heightGL - $altitude[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each-group
select="." group-by=".">
<xsl:sort select="current-grouping-key()" />
<xsl:variable name="layerId" select="." as="xs:integer"/>
<xsl:variable name="layerDescription"
select="following-sibling::diggs:descriptions/child::diggs:Description/child::diggs:value"/>
<groundLayer xmlns="">
<distanceGL>
<xsl:value-of select="$distanceGL"/>
</distanceGL>
<altitudeGL>
<xsl:value-of select="$altitudeGL"/>
</altitudeGL>
<heightGL>
<xsl:value-of select="$heightGL"/>
</heightGL>
<coordinateX1>
<xsl:value-of select="$coordinateX1"/>
</coordinateX1>
<coordinateY1>
<xsl:value-of select="$coordinateY1"/>
</coordinateY1>
<layerTopDepth>
<xsl:value-of select="$layerTopDepth"/>
</layerTopDepth>
<layerBaseDepth>
<xsl:value-of select="$layerBaseDepth"/>
</layerBaseDepth>
<layerId>
<xsl:value-of select="$layerId"/>
</layerId>
<layerDescription>
<xsl:value-of select="$layerDescription"/>
</layerDescription>
<layerName>
<xsl:value-of select="$layerName"/>
</layerName>
</groundLayer>
</xsl:for-each-group>
</layers>
</xsl:for-each>
</xsl:variable>
Here is my code for svg path (kind of same as before because I can't get the above but right)
Code:
<path id="groundLayer{$layerId}" stroke="url(#{$grad})" stroke-width="2">
<xsl:attribute name="d">
<xsl:for-each select="groundLayer[1]">
<xsl:sort select="xs:double(distanceGL)" order="descending"/>
<xsl:text>M</xsl:text>
<xsl:value-of select="$distance - distanceGL"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$height - altitudeGL + layerTopDepth"/>
</xsl:for-each>
<xsl:text> L </xsl:text>
<xsl:for-each select="groundLayer">
<xsl:sort select="xs:double(distanceGL)" order="descending"/>
<xsl:value-of
select="concat($distance - distanceGL, ' ', $height - altitudeGL + layerTopDepth)"/>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>, </xsl:text>
<xsl:for-each select="groundLayer">
<xsl:sort select="xs:double(distanceGL)" order="ascending"/>
<xsl:value-of
select="concat($distance - distanceGL, ' ', $height - altitudeGL + layerBaseDepth)"/>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>z</xsl:text>
</xsl:attribute>
</path>
My result is 10 paths (1 path for each <diggs:id> found I guess) but it should be 3paths (as there are only three unique <diggs:id>'s given (1,2 and 3) and therefore 3 ground layers shown).
The paths shown are vertical lines that represent the boreholes! So the paths are not being drawn by grouping the unique diggs:id's.
So essentially what I want the main XSLT code to do is: for each <diggs:id> found (which can be 5 or more per diggs:Hole), store some variables and store variables in relation to the location calculations (as location is only held once per hole and therefore each set of info relating to an id needs to be stored with the location info). Then all of this info needs to be grouped by each unique <diggs:id> (here only 3) and not by the location they are from. (The location variables just needs to be attached.) This would then allow me to draw paths as per each unique <diggs:id>.
If anyone could help see where my grouping or anything is going wrong, it would be deeply appreciated! This is the final step for me in this project as I have, since last posting here, sorted out all of the animation and interactivity with it etc...it just needs to handle this new XML format!
Last edited by jamesdurham; March 14th, 2009 at 11:30 PM..
|
|

March 15th, 2009, 07:49 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Your current code does not really group anything as you first have an xsl:for-each select="geo:slope/geo:groundLayers/diggs:Hole/diggs:layerSystems/diggs:LayerSystem/diggs:layers/diggs:Layer/diggs:id" so inside of that for-each the context node is an 'diggs:id' element, then you have an inner xsl:for-each-group select="." group-by="." which is a void operation as each 'diggs:id' element simply forms its own group.
So you will need an outer xsl:for-each-group I think, maybe
Code:
<xsl:for-each-group select="geo:slope/geo:groundLayers/diggs:Hole/diggs:layerSystems/diggs:LayerSystem/diggs:layers/diggs:Layer" group-by="diggs:id">
That way you would get groups of 'diggs:Layer' elements where the key is the 'diggs:id' child element.
If you post some longer sample data and the corresponding grouped transformation result (or intermediary result as you group into a variable) then it should be possible to provide the exact grouping code.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

March 15th, 2009, 09:35 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
Hi. Thanks for getting back to me so swiftly again.
Here is the amended XSLT:
Code:
<xsl:variable name="groundLayers" as="element(layers)+">
<xsl:for-each-group
select="geo:slope/geo:groundLayers/diggs:Hole/diggs:layerSystems/diggs:LayerSystem/diggs:layers/diggs:Layer" group-by="diggs:id">
<xsl:sort select="current-grouping-key()" />
<xsl:variable name="layerName" select="diggs:primaryName"/>
<xsl:variable name="layerTopDepth" select="diggs:top/gml:pos"/>
<xsl:variable name="layerBaseDepth" select="diggs:base/gml:pos"/>
<layers xmlns="">
<xsl:variable name="groundLayer" as="xs:integer+"
select="parent::diggs:layers/parent::diggs:LayerSystem/parent::diggs:layerSystems/parent::diggs:Hole/geo:point3(.)"/>
<xsl:variable name="coordinateX1" as="xs:integer" select="$groundLayer[1]"/>
<xsl:variable name="coordinateY1" as="xs:integer" select="$groundLayer[2]"/>
<xsl:variable name="c2" as="xs:decimal" select="$groundLayer[2] - (($m2)*$groundLayer[1])"/>
<xsl:variable name="cdiff" as="xs:decimal" select="$c1 - $c2"/>
<xsl:variable name="xi" as="xs:decimal" select="$cdiff div $mdiff"/>
<xsl:variable name="yi" as="xs:decimal" select="($m2*$xi)+$c2"/>
<xsl:variable name="xdiff" as="xs:decimal" select="$toe[1] - $xi"/>
<xsl:variable name="ydiff" as="xs:decimal" select="$toe[2] - $yi"/>
<xsl:variable name="distanceGL" select="xs:integer(round(math:sqrt($ydiff * $ydiff + $xdiff * $xdiff)))" as="xs:decimal" />
<xsl:variable name="heightGL" as="xs:integer"
select="parent::diggs:layers/parent::diggs:LayerSystem/parent::diggs:layerSystems/preceding-sibling::diggs:location/geo:height"/>
<xsl:variable name="altitudeGL" as="xs:integer">
<xsl:choose>
<xsl:when test="$altitude[1] < 0">
<xsl:value-of select="$heightGL - $altitude[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$heightGL - $altitude[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="layerId" select="diggs:id" as="xs:integer"/>
<xsl:variable name="layerDescription"
select="diggs:descriptions/diggs:Description/diggs:value"/>
<groundLayer xmlns="">
<distanceGL>
<xsl:value-of select="$distanceGL"/>
</distanceGL>
<altitudeGL>
<xsl:value-of select="$altitudeGL"/>
</altitudeGL>
<heightGL>
<xsl:value-of select="$heightGL"/>
</heightGL>
<coordinateX1>
<xsl:value-of select="$coordinateX1"/>
</coordinateX1>
<coordinateY1>
<xsl:value-of select="$coordinateY1"/>
</coordinateY1>
<layerTopDepth>
<xsl:value-of select="$layerTopDepth"/>
</layerTopDepth>
<layerBaseDepth>
<xsl:value-of select="$layerBaseDepth"/>
</layerBaseDepth>
<layerId>
<xsl:value-of select="$layerId"/>
</layerId>
<layerDescription>
<xsl:value-of select="$layerDescription"/>
</layerDescription>
<layerName>
<xsl:value-of select="$layerName"/>
</layerName>
</groundLayer>
</layers>
</xsl:for-each-group>
</xsl:variable>
Is that what you meant?
Here is a longer sample of the XML (deleted out some unimportant elements):
Code:
<geo:slope>
<geo:groundLayers>
<diggs:Hole diggs:id="1">
<diggs:location>
<gml:Point>
<gml:pos>316865 504940</gml:pos>
</gml:Point>
<geo:height>749</geo:height>
</diggs:location>
<diggs:layerSystems>
<diggs:LayerSystem>
<diggs:layers>
<diggs:Layer>
<diggs:id>1</diggs:id>
<diggs:primaryName>Layer1</diggs:primaryName>
<diggs:top>
<gml:pos>0</gml:pos>
</diggs:top>
<diggs:base>
<gml:pos>400</gml:pos>
</diggs:base>
<diggs:descriptions>
<diggs:Description>
<diggs:value>Clay</diggs:value>
</diggs:Description>
</diggs:descriptions>
</diggs:Layer>
<diggs:Layer>
<diggs:id>2</diggs:id>
<diggs:primaryName>Layer2</diggs:primaryName>
<diggs:top>
<gml:pos>400</gml:pos>
</diggs:top>
<diggs:base>
<gml:pos>550</gml:pos>
</diggs:base>
<diggs:descriptions>
<diggs:Description>
<diggs:value>Mudstone</diggs:value>
</diggs:Description>
</diggs:descriptions>
</diggs:Layer>
<diggs:Layer>
<diggs:id>3</diggs:id>
<diggs:primaryName>Layer3</diggs:primaryName>
<diggs:top>
<gml:pos>550</gml:pos>
</diggs:top>
<diggs:base>
<gml:pos>750</gml:pos>
</diggs:base>
<diggs:descriptions>
<diggs:Description>
<diggs:value>Gravel</diggs:value>
</diggs:Description>
</diggs:descriptions>
</diggs:Layer>
</diggs:layers>
</diggs:LayerSystem>
</diggs:layerSystems>
</diggs:Hole>
<diggs:Hole diggs:id="4">
<diggs:location>
<gml:Point>
<gml:pos>316065 505418</gml:pos>
</gml:Point>
<geo:height>200</geo:height>
</diggs:location>
<diggs:layerSystems>
<diggs:LayerSystem>
<diggs:layers>
<diggs:Layer>
<diggs:id>1</diggs:id>
<diggs:primaryName>Layer1</diggs:primaryName>
<diggs:top>
<gml:pos>0</gml:pos>
</diggs:top>
<diggs:base>
<gml:pos>50</gml:pos>
</diggs:base>
<diggs:descriptions>
<diggs:Description>
<diggs:value>e.g.clay</diggs:value>
</diggs:Description>
</diggs:descriptions>
</diggs:Layer>
<diggs:Layer>
<diggs:id>3</diggs:id>
<diggs:primaryName>Layer3</diggs:primaryName>
<diggs:top>
<gml:pos>50</gml:pos>
</diggs:top>
<diggs:base>
<gml:pos>220</gml:pos>
</diggs:base>
<diggs:descriptions>
<diggs:Description>
<diggs:value>e.g.gravel</diggs:value>
</diggs:Description>
</diggs:descriptions>
</diggs:Layer>
</diggs:layers>
</diggs:LayerSystem>
</diggs:layerSystems>
</diggs:Hole>
</geo:groundLayers>
</geo:slope>
That's code for a two boreholes (diggs:Hole). In my example code I have 4 altogether of these and have used up to 3 different layers (this hole has two layers). They each share layer id's and where the layer id's are shared, they need to have paths drawn between.
I think the problem at the moment is attaching the location (found by calculating distanceGL and heightGL) to each of the layer's found at that location (or Hole). The way I thought would work (and maybe it does?) is by nesting those calculations inside the for-each of (what is now) the diggs:Layer element.
So the aim is to group each diggs:Layer (with the location of it from inside Hole) by it's diggs:id, which will have to work across several Hole's. Does it make sense?
You asked if I could post the resultant code for the grouping I think...could you tell me as to how you wish it to be done please? I will try a simple list in a second but reply to that as soon as you read this if you can.
Thanks again
Oh, and the result of this last attempt gives the correct number of paths (i.e.3) but again their content isn't correct.
Last edited by jamesdurham; March 15th, 2009 at 10:26 AM..
Reason: added another Hole to the xml list to show two now
|
|

March 15th, 2009, 09:55 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
The resultant data
Here is what I think you asked for - the data found within the variable $groundLayers.
Code:
<g id="tests">
<distanceGL>1003</distanceGL>
<altitudeGL>819</altitudeGL>
<heightGL>749</heightGL>
<coordinateX1>316865</coordinateX1>
<coordinateY1>504940</coordinateY1>
<layerTopDepth>0</layerTopDepth>
<layerBaseDepth>400</layerBaseDepth>
<layerId>1</layerId>
<layerDescription>e.g.clay</layerDescription>
<layerName>Layer1</layerName>
<distanceGL>1003</distanceGL>
<altitudeGL>819</altitudeGL>
<heightGL>749</heightGL>
<coordinateX1>316865</coordinateX1>
<coordinateY1>504940</coordinateY1>
<layerTopDepth>400</layerTopDepth>
<layerBaseDepth>550</layerBaseDepth>
<layerId>2</layerId>
<layerDescription>eg. gravel</layerDescription>
<layerName>Layer2</layerName>
<distanceGL>1003</distanceGL>
<altitudeGL>819</altitudeGL>
<heightGL>749</heightGL>
<coordinateX1>316865</coordinateX1>
<coordinateY1>504940</coordinateY1>
<layerTopDepth>550</layerTopDepth>
<layerBaseDepth>750</layerBaseDepth>
<layerId>3</layerId>
<layerDescription>eg mudstone</layerName>
</g>
I don't know how this information is showing up wrong :/ Basically this is showing the information from the first diggs:Hole element in the tree.
What it should be showing is groups of information like this but each grouped by <layerId> (aka diggs:id) but as you can see here these each
have a different layerId - 1,2 and 3. Also, I dont know why but this is the only set of information - the other information from Hole elements is
missing. I'll take a look still while waiting to hear from you.
edit: The information that should be varying in this group is: 'layerTopDepth, layerBaseDepth, CoordinateX1, CoodinateY1, altitudeGL and distanceGL'
Therefore the constants should be 'layerId, layerDescription, heightGL'.
Thanks
Last edited by jamesdurham; March 15th, 2009 at 10:06 AM..
Reason: updated
|
|

March 15th, 2009, 10:56 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
I think what you want to do is have the outer xsl:for-each-group as you now have it and there at the beginning you output the variables/elements common to the group (e.g. layerId, layerDescription). Then you need an inner xsl:for-each
Code:
<xsl:for-each select="current-group()">
<!-- output variable values/elements here e.g. layerTopDepth, layerBaseDepth ...
</xsl:for-each>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Last edited by Martin Honnen; March 15th, 2009 at 10:56 AM..
Reason: typo
|
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|
|

March 15th, 2009, 11:09 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
ah...I thought it had worked but on closer inspection of the numbers, there is still something wrong!
Here's my new output:
Code:
<g id="tests">
<layers>
<layerId>1</layerId>
<layerDescription>Medium dense red brown clayey very sandy
angular to rounded fine to coarse quartz, igneous material,
sandstone and concrete GRAVEL.</layerDescription>
<layerName>Layer1</layerName>
<heightGL>749</heightGL>
<groundLayer xmlns="">
<distanceGL>1003 1003 1003 1003</distanceGL>
<altitudeGL>819 819 819 819</altitudeGL>
<coordinateX1>316865 316865 316865 316865</coordinateX1>
<coordinateY1>504940 504940 504940 504940</coordinateY1>
<layerTopDepth>0 0 0 0</layerTopDepth>
<layerBaseDepth>400 400 400 400</layerBaseDepth>
</groundLayer>
</layers>
<layers>
<layerId>2</layerId>
<layerDescription>Very weak green grey MUDSTONE. Fractures are closely spaced,
horizontal, clean and smooth. (Eldersfield Mudstone
Formation)</layerDescription>
<layerName>Layer2</layerName>
<heightGL>749</heightGL>
<groundLayer xmlns="">
<distanceGL>1003 1003</distanceGL>
<altitudeGL>819 819</altitudeGL>
<coordinateX1>316865 316865</coordinateX1>
<coordinateY1>504940 504940</coordinateY1>
<layerTopDepth>400 400</layerTopDepth>
<layerBaseDepth>550 550</layerBaseDepth>
</groundLayer>
</layers>
<layers>
<layerId>3</layerId>
<layerDescription>Medium dense to dense red brown slightly clayey SAND and
GRAVEL with rare cobbles. Gravel is subangular to rounded fine
to coarse of quartz, igneous material and sandstone. Cobbles are
subangular to rounded of quartz and igneous material. (River
Terrace Deposits)</layerDescription>
<layerName>Layer3</layerName>
<heightGL>749</heightGL>
<groundLayer xmlns="">
<distanceGL>1003 1003 1003 1003</distanceGL>
<altitudeGL>819 819 819 819</altitudeGL>
<coordinateX1>316865 316865 316865 316865</coordinateX1>
<coordinateY1>504940 504940 504940 504940</coordinateY1>
<layerTopDepth>550 550 550 550</layerTopDepth>
<layerBaseDepth>750 750 750 750</layerBaseDepth>
</groundLayer>
</layers>
</g>
|
|
 |