[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Newbie getting desperate

Subject: Newbie getting desperate
From: "Ouagadougou Womp" <gogge1@xxxxxxxxx>
Date: Sat, 25 Feb 2006 09:14:16 -0500
desperate 123
Hello
First of all I would like to apologies for this probably simple question. But
since english is not my first language I have failed to find all the solutions
that is probably out there.

To my problem. I am trying to extract data from an XML file using this
script:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<head></head>
<table border="1">

<xsl:for-each select="//data">
<tr>
<td><xsl:value-of select="//field[@tag='123']/subfield[@id='a']"/></td>
<td><xsl:value-of select="//field[@tag='123']/subfield[@id='b']"/></td>
<td><xsl:value-of select="//field[@tag='321']/subfield[@id='a']"/></td>
<td><xsl:value-of select="//field[@tag='999']/subfield[@id='a']"/></td>
</tr>
</xsl:for-each>

</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

I get a table with the first found instance of each select, repeated as many
times as there are <data> tags. Here is an abbreviated XML example.

<file>

<data>
<field tag="123">
<subfiled id="a">I belong to the first data</subfield>
</field>
<field tag="321">
<subfield id="a">No1</subfield>
</field>
</data>

<field tag="123">
<subfiled id="a">I belong to the second data</subfield>
</field>
<field tag="999">
<subfiled id="a">I am a proud representative of No2</subfield>
</field>
</data>

And here is the result as translated into HTML (put in quotes to prevent
unexpected things):

<!--
<html>
<head></head>
<body>
<table>
 <tr>
  <td>I belong to the first data</td><td></td><td>No1</td><td>I am a proud
representative of No2</td>
 </tr>
 <tr>
  <td>I belong to the first data</td><td></td><td>No1</td><td>I am a proud
representative of No2</td>
 </tr>
</body>
</html>
//-->

as opposed to the expected result:

<!--
<html>
<head></head>
<body>
<table>
 <tr>
  <td>I belong to the first data</td><td></td><td>No1</td><td></td>
 </tr>
 <tr>
  <td>I belong to the second data</td><td></td><td></td><td>I am a proud
representative of No2</td>
 </tr>
</body>
</html>
//-->

I have tried an XML set with many <data> entries. And every table row starts
with the first found <field tag='123'><subfield id='a'>, continues with the
first (and in my case only) found <field tag='321'><subfield id='a'> belonging
to a different <data> and of course ends with the first found 999+a. This
leaves me with a table filled with identical rows, allthough my XML data
differs. What do I do wrong?

Again foregive me for asking such a simple question, but I am getting
frustrated. I have succeeded earlier with simpler scripts. But now have hit
rock bottom.

Cheers
Anders

--
_______________________________________________

Search for businesses by name, location, or phone number.  -Lycos Yellow
Pages

http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?
SRC=lycos10

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.