|
|
#1 |
|
Lively Member
Join Date: Jun 02
Location: Reading
Posts: 70
![]() |
XSL Problems
Hi,
I'm trying to write a style sheet to transform one XML document into another. For example I start off with the Document below: - <Employee> - <Details> <name>Martin</name> <surname>Steven</surname> <phonecode>999</phonecode> <phone>0870</phone> <address1>12-50 Somewhere</address1> <address2>Somewhere</address2> <address3>SS1 SS1</address3> </Details> - <Details> <name>Someone</name> <surname>Else</surname> <phonecode>999</phonecode> <phone>0870</phone> <address1>99 Somewhere Str</address1> <address2>Somewhere</address2> <address3>SS1 SS1/address3> </Details> </Employee> Which I am trying to transform to - <Employee> - <Details> <Fullname>Martin</Fullname> <phone>999 0870</phone> <Fulladdress>12-50 Somewhere, Somewhere, SS1 SS1</Fulladdress> </Details> - <Details> <Fullname>Someone Else</Fullname> <phone>999 0870</phone> <Fulladdress>99 Somewhere, Somewhere, SS1 SS1</Fulladdress> </Details> </Employee> I am using the following stylesheet: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match="/"> <Employee> <xsl:for-each select="K2_Employee/Details"> <Details> <fullname> <xsl:value-of select="//name"/> <xsl:text> </xsl:text> <xsl:if test="surname=Fer"> <xsl:value-of select="//surname"/> </xsl:if> </fullname> <phone> <xsl:value-of select="//phonecode"/> <xsl:text> </xsl:text> <xsl:value-of select="//phone"/> </phone> <fulladdress> <xsl:value-of select="//address1"/> <xsl:text>, </xsl:text> <xsl:value-of select="//address2"/> <xsl:text>, </xsl:text> <xsl:value-of select="//address3"/> </fulladdress> </Details> </xsl:for-each> </Employee> </xsl:template> but what it actually gives me is: - <Employee> - <Details> <Fullname>Martin</Fullname> <phone>999 0870</phone> <Fulladdress>12-50 Somewhere, Somewhere, SS1 SS1</Fulladdress> </Details> - <Details> <Fullname>Martin</Fullname> <phone>999 0870</phone> <Fulladdress>12-50 Somewhere, Somewhere, SS1 SS1</Fulladdress> </Details> </Employee> It looks as if the for-each statement is working to an extent as it is giving back two records, but it's failing to do a 'movenext' on the records, can anybody tell me where I'm going wrong? Thanks. |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|