xslt value-of select stops at first value

XSLT noob here, and I would appreciate any help, hints or suggestions.

I have a XML structured like this (this is an application-generated xml that I cannot modify):

<doc>

<host>hostname1</host>
<ip>192.168.1.100</ip>
<os>windows xp</os>
<host>hostname2</host>
<ip>192.168.1.101</ip>
<os>mac os x</os>

</doc>


I have a XSL structured like this:


<xsl:template match="/" >

<html>

<body>

<h2>System Summary</h2>
<table border="1">

<tr>

<th align="left">Host</th>
<th align="left">IP Address</th>
<th align="left">Operating System</th>


</tr>

<xsl:for-each select="/Doc" >
<tr>

<td><xsl:value-of select="hostname" /></td>

<td><xsl:value-of select="ip" /></td>

<td><xsl:value-of select="os" /></td>


</tr>
</xsl:for-each>
</table>
</body>
</html>

</xsl:template>


My output stops at the first value per element (i.e., "hostname1, 192.168.1.100, Windows XP").

What do I do to make the XSLT continue through all elements of the XML? Thanks in advance.
LVL 3
tnapolitanoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nayernaguibCommented:
Change the XML document to look like this:

_______________________________________

<doc>
      <host>
            <hostname>hostname1</hostname>
            <ip>192.168.1.100</ip>
            <os>windows xp</os>
      </host>
      <host>
            <hostname>hostname2</hostname>
            <ip>192.168.1.101</ip>
            <os>mac os x</os>
      </host>
</doc>

_______________________________________

Next, replace the statement

  <xsl:for-each select="/Doc" >
 
with the statement

  <xsl:for-each select="/Doc/host" >

_______________

  Nayer Naguib  
0
tnapolitanoAuthor Commented:

Thanks for getting back to me. But this is an XML generated by an application and modification is not an option.

0
nayernaguibCommented:
Modifying the XML document manually or using a small program to automate the task is not the problem. You will not get the required output (using XSLT) unless you modify the XML file structure.

_______________

  Nayer Naguib
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

tnapolitanoAuthor Commented:
Thanks for getting back to me on this.

Any sources you can point me to on scripting the modification/reformat of a xml document?
0
nayernaguibCommented:
Take a look at these pages on how to programmatically read/write XML files. It should take a few lines to read the file and store it in memory, and a few other lines to write the file with the new structure.

  http://samples.gotdotnet.com/quickstart/howto/doc/Xml/ReadXMLFile.aspx
  http://samples.gotdotnet.com/quickstart/howto/doc/Xml/WriteXMLFile.aspx

You can find a lot of online resources on how to do that using other programming/scripting languages.

_______________

  Nayer Naguib
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tnapolitanoAuthor Commented:
Thanks. The more I thought about it, the better I decided modifying the structure and creating a new XML doc will work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.