To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Other Languages > XML, HTML, Javascript, Web and CSS

Reply Post New Thread
 
Thread Tools Display Modes
Old Mar 30th, 2004, 03:21 AM   #1
Auld Nick II
Lively Member
 
Join Date: Jun 02
Location: Reading
Posts: 70
Auld Nick II is an unknown quantity at this point (<10)
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.
Auld Nick II is offline   Reply With Quote
Reply

Go Back   VBForums > Other Languages > XML, HTML, Javascript, Web and CSS


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:18 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.