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
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



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

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Mar 30th, 2004, 04: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 Search this Thread
Search this Thread:

Advanced Search
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 11:56 AM.




To view more projects, click here

Acceptable Use Policy


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.